Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Please look at the following minimal example:

\documentclass{article}
\usepackage[all]{xy}
\begin{document}
\(
\xymatrix{
\begin{pmatrix} 1 & 1\end{pmatrix}
}
\)
\end{document}

The output I get is the following:

[PDFLaTeX] test.tex => test.pdf (pdflatex)
[PDFLaTeX] finished with exit status 1
./test.tex:0:No file test.aux.
./test.tex:7:Extra }, or forgotten \endgroup. }
./test.tex:7:Missing \endgroup inserted. }
./test.tex:7:Missing } inserted. }
./test.tex:7:\begin{document} ended by \end{pmatrix}. }
./test.tex:7:Missing } inserted. }
./test.tex:7:Missing $ inserted. }
./test.tex:7:Missing } inserted. }
./test.tex:7:Missing } inserted. }
./test.tex:7:Missing } inserted. }
./test.tex:7:Missing } inserted. }
./test.tex:7:Missing \cr inserted. }
./test.tex:7:Misplaced \cr. }
./test.tex:7:Missing \cr inserted. }
./test.tex:7:Misplaced \cr. }
./test.tex:7:Missing \cr inserted. }
./test.tex:7:Misplaced \cr. }
./test.tex:7:Missing \cr inserted. }
./test.tex:7:Misplaced \cr. }
./test.tex:7:Missing \cr inserted. }

It goes on like that "for ever". What's the problem here? Does xymatrix not work well with pmatrix?

share|improve this question

2 Answers 2

up vote 4 down vote accepted

use it this way:

\documentclass{article}
\usepackage[all]{xy}
\usepackage{amsmath}
\begin{document}

\xymatrix{ {\begin{pmatrix} 1 & 1\end{pmatrix}} }

\end{document}
share|improve this answer
    
That works, indeed. Thanks a lot! –  Rasmus Mar 8 '11 at 17:37
    
@Rasmus: Don't forget that you can "accept" the answer if it worked for you -- click the checkbox on the left of this answer right below its score. This will notify the others that this solution worked for you. –  Martin Tapankov Mar 8 '11 at 17:47
    
@Martin: I'd usually wait with such comments (see our Building Blocks), but probably you've seen that. –  Hendrik Vogt Mar 8 '11 at 18:37
4  
@Martin: Thanks, I am aware of that (as becomes apparent when looking at my profile). I do not think that it is advisable to accept the first answer right after posting the question. This answer helped me very much, though, and I will soon accept it unless someone comes across who explaines me even why the extra parentheses are necessary. –  Rasmus Mar 8 '11 at 21:21
3  
@Rasmus: The alignment character & has a meaning both to \xymatrix and to pmatrix. By grouping the complete inner matrix in braces, you ensure that pmatrix evaluates it before \xymatrix does. –  Stefan Kottwitz Mar 8 '11 at 22:17

Notice that the xyguide explain that entries should not start with a macro.

But here, the real problem is the "&" who is interpreted by xypic like a separator in the xymatrix (and not in the pmatrix).

For exemple, \xymatrix{ \begin{pmatrix} 1 \end{pmatrix} } works fine.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.