7

The example in this answer, illustrating the use of "spies" using the Tikz package, fails to typeset correctly when using XeLaTeX: the magnification circle appears empty. Using pdfLaTeX and LaTeXmk works fine, otherwise.

Do I need to configure my TeX distribution somehow in order to typeset TikZ code using XeLaTeX? (Currently using MacTex 2011 with TeXworks, on OS X Lion.)

1 Answers1

5

There indeed seems to be a problem with the use of "spies" under XeLaTeX. Consider the following MWE, which is a stripped-down version of the answer referred to by the OP:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{spy}
\pagestyle{empty}
\begin{document}
\begin{figure}
\begin{tikzpicture} 
  [spy using outlines={circle, magnification=4, 
   size=1cm, connect spies}]
\draw[help lines] (0,0) grid (2,2);
\draw[red] (0,0) -- (1,1);
\spy [blue] on (1,1) in node at (1.75,2.75);
\end{tikzpicture}
\end{figure}
\end{document}

When compiled under pdflatex, the following figure results:

enter image description here

In contrast, when the same program is compiled under XeLaTeX, one gets:

enter image description here

I.e., both the "cross-hairs" and the red line that terminates in the middle of the "target" aren't shown inside the spy-circle. :-(

Mico
  • 506,678
  • add the command and it doesn't work. – Pig Cry Nov 01 '11 at 02:47
  • 1
    @PigCry: Please be more specific regarding "it doesn't work". Which TeX distribution are you running, under which OS? Did you remove all aux files prior to recompiling under XeLaTeX? – Mico Nov 01 '11 at 03:23
  • sorry for my curt comment. I use texlive 2011 not mactex, maybe that's the point. – Pig Cry Nov 01 '11 at 06:41
  • @PigCry: please elaborate further on the exact error message you get. – Mico Nov 01 '11 at 08:00
  • 1
    I add the command \usepackage{fontspec}, compile it under xelatex without error warning, but the magnification circle appears almost empty, only with a vertical. I think the vertical is a grid line. – Pig Cry Nov 01 '11 at 09:01
  • @PigCry: After some more testing, I've determined that there is, in fact, a problem with the spies component of the TikZ package. I've modified my answer accordingly. – Mico Nov 01 '11 at 16:47
  • @PigCry and @ Mico: Indeed, the spy is not empty, just shifted some how. By simply changing slightly the coordinate values following "on" (in \spy [blue] on (1,1) in node at (1.75,2.75);), we can see some content appear. – Olivier Drolet Nov 03 '11 at 15:59
  • @OlivierDrolet: Thanks for this. Real quick: Where would one need to shift the spy center to (when running under xelatex)? – Mico Nov 03 '11 at 17:49
  • @Mico: You wouldn't. Prior my initial post, I attempted using TikZ' spies in a document, to highlight a button in a .png screen grab. The problem I had was that the magnified image was completely off wrt the coordinates of the spy. This is happening here as well, but is more difficult to see because these MWEs contain lots of white background. On rich image content, it's easier to spot. – Olivier Drolet Nov 03 '11 at 21:04
  • In the MWE above, change the line starting with \spy with the following: \spy [blue] on (-1,5) in node at (8,8); This should highlight the off-centeredness I'm referring to. – Olivier Drolet Nov 23 '11 at 19:32
  • 2
    Seems to work fine for TikZ 3.0.0 – someonr Jan 02 '14 at 08:04