2013-03-11 46 views
3

我需要一個here文檔來將TeX上傳到聯機shell。我不想讓shell對內容做任何事情。以下MWE是迄今爲止我管理的最好的。here - 禁用shell解析的文檔

cat <<EOF> /tmp/mytex 
\documentclass{article} 
\begin{document} 
Test mathematics: $ 2^{10} = 1024$ works but 
$e^{i\pi} = -1$ is mangled because no space follows the $e$. 
"double" and 'single' quotes should be preserved too. 
\end{document} 
EOF 

回答

8

試試這個:

cat << 'EOF' > /tmp/mytex 
\documentclass{article} 
\begin{document} 
Test mathematics: $ 2^{10} = 1024$ works but 
$e^{i\pi} = -1$ is mangled because no space follows the $e$. 
"double" and 'single' quotes should be preserved too. 
\end{document} 
EOF 

From the bash reference manual

這裏,文件的格式爲:

<<[-]word 
     here-document 
delimiter 

如果引用了單詞中的任何字符,則定界符是 單詞上的引用刪除結果,並且此處的文檔 中的行未展開。

+0

這是閱讀手冊的教訓!對於我的用例,請參閱http://tex.stackexchange.com/questions/101479/how-to-build-two-different-tex-files-from-same-tex-file/101484#101484 – 2013-03-11 18:34:19