[Xy-pic] Really weird behavior

Michael Barr barr at math.mcgill.ca
Wed Dec 11 01:06:58 CET 2013


Does your explanation also explain the output of this file?

\documentclass{article}
\pdfoutput1
\usepackage{color}
\usepackage{xy}

\begin{document}
{\xy
%\relax
{\color{red}Test}
\endxy}
Test

\end{document}

I would have thought that enclosing the entire thing in curly braces would 
cause tex itself to confine all changes to the local group.

Michael

On Tue, 10 Dec 2013, Daniel Müllner wrote:

> 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
>>
>
>

-- 
        Every gun that is made, every warship launched, every rocket fired
signifies, in the final sense, a theft from those who hunger and are not
fed, those who are cold and are not clothed. -Dwight D. Eisenhower


More information about the xy-pic mailing list