Random Wisdom

LaTeX Shell Escape

by on Mar.13, 2011, under How To ..., LaTeX

One of the lesser known features of LaTeX is its “shell-escape” mode. This is achieved using the LaTeX command \write18{cmdlist} in the document. This facility can be used to incorporate dynamic content or simply run additional processes during the compilation phase. An example document may look something like:

  \immediate\write18{date > tmpdate.tex}
  \immediate\write18{rm tmpdate.tex}

As \write18 is usually disabled on most systems for obvious security reasons, it must be enabled explicitly:

$ latex -shell-escape input_file

More details are available in the MiKTeX documentation under the heading “Running Programs From Within TeX“.


1 Comment for this entry

  • mIR

    How can I do this on MAC? I have been looking for this problem and search almost every single thread regarding this, but failed to understand. Please, elaborate further on alternatives to activating the shell-escape on TexLive.

    Finally, my purpose is to convert a .pdf file into .eps file. I shall be thankful for your support.

Leave a Reply