9

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.

2 Answers2

7

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.

egreg
  • 1,121,712
  • 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 '20 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 '20 at 14:22
  • What do you mean by 'select' the file? – user65526 May 19 '20 at 14:24
  • @user65526 Single click on it. – egreg May 19 '20 at 14:43
3

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}
cmhughes
  • 100,947
  • 1
    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