# [OS X TeX] pdflatexmk not running the first time

Herbert Schulz herbs at wideopenwest.com
Sun Mar 20 16:14:18 EDT 2022


> On Mar 20, 2022, at 2:21 PM, G. M.-S. <lists.gms at gmail.com> wrote:
>
>
> Hi Herb.
>
> Everything (TeXShop and TeX Live) is up to date.
>
> After some experimenting, I think I found the conditions for this to happen.
> 1) In TeXShop > Preferences > Engine, add the option --shell-escape and tick Shell Escape Warning.
> 2) Create a new file beginning with % !TEX TS-program = pdflatexmk.
> 3) Typeset it.  TeXShop will ask about using shell escape.  Whichever the answer it will ignore the program to use.
>
> It seems to me that on first typeset TeXShop puts a flag in the file saying if shell escape is to be used or not, but then it forgets the !TEX TS-program part.
>
> Guillermo
>
> On Sun, 20 Mar 2022 at 18:11, Herbert Schulz <herbs at wideopenwest.com> wrote:
> > On Mar 20, 2022, at 11:52 AM, G. M.-S. <lists.gms at gmail.com> wrote:
> >
> > Hello.
> >
> > Something must be misconfigured on my side, but I have been unable to find where.
> >
> > The first time I typeset a new LaTeX file test.tex containing
> >
> > % !TEX TS-program = pdflatexmk
> > \documentclass{article}
> > \begin{document}
> > Test.
> >
> > \label{eq}
> > 2+2=4
> >
> > As seen in \ref{eq}.
> > \end{document}
> >
> > with TeXShop I get
> >
> > This is pdfTeX, Version 3.141592653-2.6-1.40.23 (TeX Live 2022/dev) (preloaded format=pdflatex)
> >  restricted \write18 enabled.
> > entering extended mode
> > (./test.tex
> > LaTeX2e <2021-11-15> patch level 1
> > L3 programming layer <2022-02-24>
> > (/usr/local/texlive/2021/texmf-dist/tex/latex/base/article.cls
> > Document Class: article 2021/10/04 v1.4n Standard LaTeX document class
> > (/usr/local/texlive/2021/texmf-dist/tex/latex/base/size10.clo))
> > (/usr/local/texlive/2021/texmf-dist/tex/latex/l3backend/l3backend-pdftex.def)
> > No file test.aux.
> >
> > LaTeX Warning: Reference eq' on page 1 undefined on input line 29.
> >
> > [1{/usr/local/texlive/2021/texmf-var/fonts/map/pdftex/updmap/pdftex.map}]
> > (./test.aux)
> >
> > LaTeX Warning: There were undefined references.
> >
> >
> > LaTeX Warning: Label(s) may have changed. Rerun to get cross-references right.
> >
> >  )</usr/local/texlive/2021/texmf-dist/fonts/type1/public/amsfonts/cm/cmbx10.pfb
> > ></usr/local/texlive/2021/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb>
> > Output written on test.pdf (1 page, 23320 bytes).
> > SyncTeX written on test.synctex.
> > Transcript written on test.log.
> >
> > If I typeset again, latexmk is called and everything works as expected.
> >
> > So this seems to be related to the fact that there is only one file called test.*.
> >
> > Guillermo
>
> Howdy,
>
> This is very strange. What version of TeXShop are you using? When you say first time' do you mean first time ever (i.e., you are a new user of TeXShop) or does this happen with any file using the pdflatexmk engine the first time you typeset? What is the console output when pdflatexmk is actually used?
>
> Good Luck,
>
> Herb Schulz
> herbs at wideopenwest.com
>

Howdy,

Do you really want shell-escape to be enabled all the time? That's rather dangerous. I haven't checked that possibility and won't. So uncheck that option and remove the --shell-escape you added to the command(s) in the Engine tab of TeXShop preferences. PS: do you really want to go through a warning on every compile using pdflatex?

If you want to use the pdflatexmk engine (or any of the latexmk based engines) the best way to enable shell-escape on a file by file basis is to use the TeXShop directive

% !TEX parameter = -shell-escape

for that file. That keeps things safe.

There also is the sepdflatexmk engine whcih is like the pdflatexmk engine but with -shell-escape enabled. This method is still available but is deprecated.

Finally, on a completely separate issue... with the 2020/10/01 update of LaTeX using and of the latexmk based engines for simple files that only need a single typeset run (i.e., no cross-references, bibliography or indexes) suddenly started to typeset twice. Usually one uses the latexmk based engines for more complex jobs but I'm lazy and often use it even for these trivial'' typesetting jobs (I go back to a time when it took almost a minute to typeset a single page so the extra second or so to use the latexmk based engine is meaningless to me) but the extra typesetting run was disconcerting. There is a solution: go to <https://herbs.github.io> and download the LaTeX2020-10-01AndLatexmk.pdf.zip file for information on what is happening and how to solve the problem.

Good Luck,

Herb Schulz
herbs at wideopenwest.com