Quantcast
Channel: User David Z - Stack Overflow
Viewing all articles
Browse latest Browse all 49

Answer by David Z for How to execute shell script from LaTeX?

$
0
0

I would do something like the following (partially motivated by what Roman suggested): make your LaTeX file be

\documentclass{article}\begin{document}\input{scriptoutput.tex}\end{document}

and generate the file scriptoutput.tex using

/usr/local/bin/my-shell-script.sh > scriptoutput.tex

You could encode this in a makefile if you want to have it run automatically when necessary. Alternatively, you could use the TeX \write18 command,

\documentclass{article}\immediate\write18{/usr/local/bin/my-shell-script.sh > scriptoutput.tex}\begin{document}\input{scriptoutput.tex}\end{document}

and I think that would automatically run the shell script each time you compile the document. The \immediate is necessary to ensure that the script is run when LaTeX encounters the command, rather than waiting until a page of output is written. (See this question for more on the shipout routine.)


Viewing all articles
Browse latest Browse all 49

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>