8

I want to use the auto-pst-pdf package and therefore I need the --shell-escape option to be enabled. I did this in my TeXShop preferences as follows:

enter image description here

However when I use pdflatexmk (by writing % !TEX TS-program = pdflatexmk on the first line) to compile my document the option is not taken into account and auto-pst-pdf can not be used.
How do I enable the --shell-escape command with pdflatexmk?

I use TeXShop 3.24 on Mac OSX with pdflatexmk version 4.37.

  • The pdflatexmk works fine without the auto-pst-pdf package as this does not require the --shell-escape option. As far as I can tell the related questions are about getting latexmk to work basically, but I already have that working. – Saaru Lindestøkke Oct 16 '13 at 17:56
  • 2
    use as command pdflatexmk -pdf -pdflatex="pdflatex --shell-escape %O %S" – user2478 Oct 16 '13 at 18:24
6

Navigate to your ~/Library/TeXShop/Engines folder and duplicate the file pdflatexmk.engine to, say, pdflatexmk-shell.engine. Then open this file with TeXShop itself and add the -pdflatex="pdflatex --shell-escape %O %S" option: here's how the file should be:

#!/bin/bash
export TSBIN="$HOME/Library/TeXShop/bin/tslatexmk"
export LTMKBIN="$HOME/Library/TeXShop/bin/tslatexmk"
export LTMKEDIT="$HOME/Library/TeXShop/bin"
# make sure latexmkrcedit exists in bin
if [ ! -e "${LTMKEDIT}/latexmkrcedit" ] ; then
    cp "${LTMKBIN}/latexmkrcDONTedit" "${LTMKEDIT}/latexmkrcedit"
fi
"${LTMKBIN}"/latexmk -pdf -r "${LTMKEDIT}/latexmkrcedit" -r "${TSBIN}/pdflatexmkrc" -pdflatex="pdflatex --shell-escape %O %S" "$1"

Now, if you start your document with

% !TEX TS-program = pdflatexmk-shell

the shell escape will be enabled.

Here's a copy of the console when a file with that magic line is processed:

Latexmk: This is Latexmk, John Collins, 2 July 2013, version: 4.37.
**** Report bugs etc to John Collins <collins at phys.psu.edu>. ****
Rule 'pdflatex': File changes, etc:
   Non-existent destination files:
      'bart.pdf'
------------
Run number 1 of rule 'pdflatex'
------------
------------
Running 'pdflatex --shell-escape  -recorder  "bart.tex"'
------------
Latexmk: applying rule 'pdflatex'...
This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013)
 \write18 enabled.
entering extended mode
(./bart.tex
LaTeX2e <2011/06/27>
Babel <3.9f> and hyphenation patterns for 78 languages loaded.
(/usr/local/texlive/2013/texmf-dist/tex/latex/base/article.cls
Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
(/usr/local/texlive/2013/texmf-dist/tex/latex/base/size10.clo)) (./bart.aux)
[1{/usr/local/texlive/2013/texmf-var/fonts/map/pdftex/updmap/pdftex.map}]
(./bart.aux) )</usr/local/texlive/2013/texmf-dist/fonts/type1/public/amsfonts/c
m/cmr10.pfb>
Output written on bart.pdf (1 page, 11541 bytes).
Transcript written on bart.log.
Latexmk: Log file says output to 'bart.pdf'
Latexmk: All targets (bart.pdf) are up-to-date

The lines

This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013)
 \write18 enabled.

are the proof that shell escape is enabled.

| improve this answer | |
  • How can I duplicate the file pdflatexmk.engine? Plus, what is the full name of the file? is it a .text file? What is it? – user65526 May 19 at 14:02
  • @user65526 The file is in ~/Library/TeXShop/Engines. If you select the file, you can duplicate it from the menu or with Command-D, then change its name. It's a text file, you can open it for editing also with TeXShop itself. – egreg May 19 at 14:22
  • What do you mean by 'select' the file? – user65526 May 19 at 14:24
  • @user65526 Single click on it. – egreg May 19 at 14:43
2

If you're open to other automation tools, I would highly recommend arara. Integration with TeXShop (which I assumed is your chosen IDE) and any other editor is easy and is covered in the documentation.

To enable --shell-escape you simply give the directive

% arara: pdflatex: {shell: yes}
| improve this answer | |
  • Thank you for the suggestion, it looks like a powerful tool. However I'm looking for a quick way to use psfrag with pdflatexmk and using a whole new tool for this sounds like overkill to me. – Saaru Lindestøkke Oct 16 '13 at 21:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.