In my .emacs
I have
'(TeX-PDF-mode t)
set. So I'm using PDFLaTeX. I'm not sure why this is not the default these days.
I had also set
'(LaTeX-command "latex -shell-escape")
In hindsight this was a bad idea, but I didn't realise it till
I was trying to get SyncTeX to work, but it wouldn't.
I belatedly realized that because I had set LaTeX-command manually,
I was overwriting the
--synctex=1
option that would normally have been there.
Which brings to my question.
- Is
LaTeX-command
the right command to modify to add the
-shell-escape
option, and if so - What is the right way to add an option to
LaTeX-command
?
@David Carlisle suggested
(setq LaTeX-command (concat LaTeX-command " -shell-escape"))
which seems to be in the right ballpark, but this gives the error:
Symbol's value as variable is void: LaTeX-command
NOTE: Evaluating LaTeX-command
just gives "latex", so this may not be the right thing to append to.
Best Answer
Starting from version 11.88 of AUCTeX, you can add an option to the TeX processor with the file-local variable
TeX-command-extra-options
:As explained in the manual, you have to manually make this variable safe as a local variable because of the security holes it can open.
Note: this question inspired me to add this feature.
Until version 11.87, AUCTeX hadn't a facility to add easily an option to the compiler (at least I always missed to find it). I see at least three strategies you can follow:
LaTeX-command-style
(the suggested way if you want to activate shell escape for all documents)TeX-engine-alist
TeX-command-list
I'll try to outline 1 and 2. 3 is similar to 2 in spirit.
Note: in a previous version of the answer I suggested to edit
LaTeX-command
, but that variable should be reserved to the actuallatex
binary name. Setting it tolatex -shell-escape
doesn't play well with forward/inverse search (for the curious person:TeX-source-correlate-determine-method
would fail because there is nolatex -shell-escape
binary and so forward/inverse search would fall back on source specials, even if SyncTeX is actually available).LaTeX-command-style
This variable allows to change the options passed to the compiler, its syntax is a bit cumbersome, though. In addition, this isn't a file local variable so you can't set (by default) it on a per-document basis.
The customize way
Issue M-x
customize-variable
RETLaTeX-command-style
RET. In theString
field of the variable add-shell-escape
after%(latex)
. E.g., if the value of the field ischange it into
The do-it-for-me way
Add the following code to your
.emacs
.TeX-engine-alist
Insert a new element, called for example
default-shell-escape
, similar to thedefault
element ofTeX-engine-alist-builtin
. You can do it by using the customization interface or adding an Elisp code to your.emacs
.After creating this new engine, you'll be able to activate it by using the menu
Command > TeXing Options > Use Default with shell escape
. If you want to set it by default for all documents or on a per-document basis see below.The customize way
Issue M-x
customize-variable
RETTeX-engine-alist
RET. Press theINS
button and fill the fields in the following way:default-shell-escape
Default with shell escape
tex -shell-escape
latex -shell-escape
The do-it-for-me way
Add the following code to your
.emacs
Set the
default-shell-escape
engine as defaultNow you can set the new fictitious engine as default for all documents
TeX-engine
(M-xcustomize-varaiable
RETTeX-engine
RET) and selectingDefault with shell escape
in the drop-downValue Menu
, or;;
at the beginning of) theline in the previous Elisp code.
Use the
default-shell-escape
engine on a per-document basisAlternatively, you can leave the default engine as it is and pick up the
default-shell-escape
engine only in the documents in which you actually need it. In those documents, issue M-xadd-file-local-variable
RETTeX-engine
default-shell-escape
RET.