[Xy-pic] Really weird behavior
Daniel Müllner
daniel at danifold.net
Tue Dec 10 20:08:02 CET 2013
Hi Michael,
here is an even more minimalistic example that shows what's going on:
\documentclass{article}
\pdfoutput1
\usepackage{color}
\usepackage{xy}
\begin{document}
\xy
%\relax
{\color{red}Test}
\endxy
Test
\end{document}
With the \relax, Xy-pic treats the curly brackets as a <decor>ation
(ibid., Figure 4). The curly brackets are passed through all levels of
Xy-pic parsing; hence the \color{red} has local scope.
Without the \relax, Xy-pic treats the curly brackets as a Xy-pic group
and interprets the content like a nested Xy-pic environment (Xy-pic
reference manual, Figure 1, line 22). The curly brackets are stripped
and are lost as a TeX group; therefore the \color{red} has global scope.
Regards,
Daniel
On 12/10/2013 05:51 PM, Michael Barr wrote:
> If you compile the following file:
>
> \documentclass{article}
> \pdfoutput1
> \usepackage{color}
> \def\red{\color{red}}
> \def\green{\color{green}}
> \usepackage[arrow]{xy}
>
> \begin{document}
> \newcount \xytest
> $$\xy
> \xytest0
> {\red\ar@{->}^{\green f}(20,0)}
> \endxy$$
> Test
> \end{document}
>
> you find nothing special about the output. In particular, the word Test
> is black. Now comment out the line \xytest0 and see what happens. On
> my computer the word Test is now red. How can this totally irrelevant
> assignment make a difference in the behavior? And how can this color
> assignment, which is inside a group, make a difference outside?
>
> This would appear to have something to do with something in xy-pic since
> the simple test line: {\red Test} Test gives the expected result, the
> first word in red and the second one black.
>
> Michael
>
More information about the xy-pic
mailing list