# xelatex vs. xelatexmk compilation – what’s the difference?

I'm using TeX Live 2012 in a Windows environment.

I used to compile with xelatexmk, which isn't included in TeX Live's "Processing tools". When I wanted to switch from LaTeX to XeLaTeX, I read somewhere that I had to compile with xelatexmk, and it gave instructions for its configuration.

My xelatexmk configuration looks like this:

Then I recently switched to TeX Live's built-in XeLaTeX compiler, because I noticed it was faster and always gave the same result. That configuration looks like this:

But I've noticed a difference when I draw arrows with TikZ. Below is a MWE:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tabular}{cc}
\tikz[baseline, remember picture] \node[inner sep = 0pt, anchor = base] (finisharrow) {a}; & \tikz[baseline, remember picture] \node[inner sep = 0pt, anchor = base] (startarrow) {c};
\end{tabular}
\begin{tikzpicture}[remember picture, overlay, shorten <=.1ex, shorten >=.1ex]
\draw [semithick, ->] (startarrow) -- (finisharrow);
\end{tikzpicture}
\end{document}


When I compile with xelatexmk, it gives me this:

When I compile with XeLaTeX, on the other hand, it gives me this:

I need to compile with XeLaTeX a second time to get the proper outcome:

I'm sure there's a perfectly good reason why XeLaTeX behaves this way, but for novice users like me, it resulted in a lot of frustration, since I couldn't figure out why my arrows didn't turn out the way they used to before (when I used xelatexmk).

Could this perhaps be a reason why XeLaTeX in the future versions of TeX Live should do two compiling iterations, or why xelatexmk should be included? Again, I need to stress that this is from the perspective of a novice user, who generally expects (or hopes) that their .tex document compiles easily by using some default built-in compiler.

-
When you use remember picture, there's need of a second run of LaTeX (whichever variant), because during the first a note is kept for the location of the picture; it's similar to the \label-\ref system. A new run in necessary whenever the picture is modified or its position in the page changes. – egreg Apr 14 '13 at 13:58
I've understood now, that this is precisely why latexmk was made (to perform as many runs as necessary). Maybe I should close my question as being too localized. – Sverre Apr 14 '13 at 14:06
@Sverre I disagree, why should this be too localized? Just because you understand now doesn’t mean it’s an illegitimate question that somebody might have as well. Voting to reopen. (After taking the liberty to generalize the question slightly.) – doncherry Apr 14 '13 at 16:16
I see what you mean after having reworded the question. I guess my thought was that it now boils down to whether or not TeX Live should include latexmk among its included compiling tools (which I think it should). And my initial question here was, in a way, too localized to address that properly. – Sverre Apr 14 '13 at 17:20

The xelatex command runs XeLaTeX exactly once: it does one typesetting run and produces a PDF. In contrast, xelatexmk runs XeLaTeX and other tools one or more times, using a script to (try to) determine what runs are required. Once you go beyond a 'trivial' document, introducing cross-references or similar then at least two XeLaTeX runs are required to 'completely' compile a document (here we have a 'label' of sorts in terms of position in the output). On the other hand, scripts don't always get things right, and resolving all links, etc. is normally only essential for the final 'production' PDF. As such, many people are happy not to use a script and to do the necessarily additional runs by hand, which means that intermediate runs are faster. Others are happier with a script doing this 'back end' stuff for them.