# Toggle permission to use shell escape in document itself

Permitting LaTeX to execute shell code (aka -enable-write-18) is dangerous. But I sometimes need it due to dot2texi. So in my IDE (which in my case is WinEdt) I manually switch it on when I work with dot2texi, and switch it off when when I do not longer work with dot2texi AND (important) do not forget it (weak spot). I vaguely recall that switching on shell escapes can be done as per document. That would be nice. Does anyone remember how?

-
Have you thought about using arara? –  StrongBad Apr 9 '14 at 16:54
You could use arara with the directive % arara: pdflatex: { shell: yes }. –  Henri Menke Apr 9 '14 at 16:54
By coincide or not, I stumbled upon arara some half hour ago, before asking my question. I admit it is a solution, and I am glad with it, but arara seems like a heavy solution for such a simple operation? –  user3498676 Apr 9 '14 at 17:03
There is not/should not be a solution at TeX macro level. Otherwise it would be easy for malicious code to turn on shell escape. –  Heiko Oberdiek Apr 9 '14 at 17:06
@cmhughes Done. –  Henri Menke Apr 9 '14 at 17:38

The tool arara is a great piece of software by our fellow duck-loving StackExchanger Paulo Cereda. It works somewhat like the TeXworks magic comments (see below) in that sense, that you can control the sequence of your typesetting process.

For example, to get the citation right, you normally need to run latex to generate the aux-file, then bibtex to generate the bbl-file, then again latex to include the bbl-file and to regenerate the aux-file with now right labels, and then a third time latex to get your references right. Phew!

Because this is a lot of typing exercise in your terminal, or a lot of keystrokes in your editor, there is arara. You just insert comments right in the first lines of your file, à la

% arara: pdflatex
% arara: bibtex
% arara: pdflatex
% arara: pdflatex


and then run arara on that file, e.g. arara example.tex. Hopefully you then see

  __ _ _ __ __ _ _ __ __ _
/ _ | '__/ _ | '__/ _ |
| (_| | | | (_| | | | (_| |
\__,_|_|  \__,_|_|  \__,_|

Running PDFLaTeX... SUCCESS
Running BibTeX... SUCCESS
Running PDFLaTeX... SUCCESS
Running PDFLaTeX... SUCCESS


You can also add further options to the single tasks, like shell escape:

% arara: pdflatex: { shell: yes }
% arara: bibtex
% arara: pdflatex: { shell: yes }
% arara: pdflatex: { shell: yes }


With TeXworks magic comments you can set typesetting engine, encoding, etc. Here an example:

% !TeX program = LuaLaTeX
% !TeX encoding = UTF-8
% !TeX root = example.tex
% !TeX spellcheck = en_GB

-
I believe that MiKTeX's implementation can specify options in the first input line. –  egreg Apr 9 '14 at 17:51
@egreg I never used MikTeX. If want to write some lines about this, feel free to edit. –  Henri Menke Apr 9 '14 at 17:55
I've never used it either. I believe to have seen something like that. –  egreg Apr 9 '14 at 17:58
@egreg Some googling revealed, that %& --enable-write18` as the first line should work, but I can't test it. From: docs.miktex.org/manual/tex.html –  Henri Menke Apr 9 '14 at 18:04