I want to be able to have a LaTeX file automatically show the revision number. So basically, in the file have something like
File Revision {bzr revno}
And make it so when LaTeX is run it will replace {bzr revno} with the output of that command (in this case 12). Is there a way to do this? I don't want to actually edit the file because then it would need to be checked in again.
General ⇒ Insert output of a shell command into LaTeX file at compile?
NEW: TikZ book now 40% off at Amazon.com for a short time.
Insert output of a shell command into LaTeX file at compile?
I got partially there by using:
And then having my Makefile run bzr revno > revision.txt first. But this puts an extra space after the \input command, and I get:
This is revision 193 .
Code: Select all
This is revision \input{revision.txt}.
This is revision 193 .
Insert output of a shell command into LaTeX file at compile?
You have to change \endlinechar to avoid the space:
pdfTeX can also execute shell commands if that facility is enabled on the command line. Then you can say
Subversion users prefer using properties (special strings that get replaced automatically during each commit operation). Perhaps Bazaar provides a similar facility.
Code: Select all
\documentclass{article}
\newcommand*\Revision{%
\edef\RestoreEndlinechar{\endlinechar=\the\endlinechar\relax}%
\endlinechar=-1 %
\input{revision.txt}%
\RestoreEndlinechar
}
\begin{document}
Revision \Revision.
\end{document}
Code: Select all
\input "|bzr revno"
Re: Insert output of a shell command into LaTeX file at compile?
Thanks! The first one worked great. Unfortunately, it doesn't look like Bazaar supports anything like the "properties."