9

I know that the point of \crcr is to be a kind of "backup \cr" in \halign/\valign, in that it only adds a \cr if it wouldn't result in two in a row. Nonetheless it seems to find its way into the \halign preamble, where it seems merely like a slightly-longer version of \cr. For example, the plain Tex definition of \matrix:

*\show\matrix
> \matrix=macro:
#1->\null \,\vcenter {%
  \normalbaselines \m@th \ialign {%
    \hfil $##$\hfil &&\quad \hfil $##$\hfil \crcr
    \mathstrut \crcr
    \noalign {\kern -\baselineskip }%
    #1\crcr 
    \mathstrut \crcr
    \noalign {\kern -\baselineskip }%
  }%
}\,.

(I have added some formatting). I don't get why the preamble would end in \crcr when \cr works just as well, is the only option mentioned by the TeXbook, and when \crcr doesn't seem to function as a backup \cr in this case. Now, the third \crcr does have that particular function here, but in the very simple alignment

\halign{#\crcr x}

you will get a "Missing \cr inserted" error nonetheless. I have seen this idiom elsewhere so I assume it has some reason but I can't figure out what it is.

  • apart from the #1\crcr one I think they could all be \cr with no change in behaviour. – David Carlisle Sep 9 '13 at 23:44
  • I think it is so you can do this: \matrix{a\cr b} and/or this: \matrix{a\cr b\cr} (unless that's what you meant by "backup \cr"). – morbusg Sep 10 '13 at 5:41
  • 1
    @morbusg no that's what the #1\crcr one does the others are totally equivalent to \cr I think it is just Knuth's style to use crcr everywhere in macro definitions, presumably to save remembering, and to leave \cr for use in table bodies in the document – David Carlisle Sep 10 '13 at 7:21
  • 3
    @David, Ah, I see, thanks. Ryan: One thing that I remember used on this site, is that it leaves the redefinition of \cr open to the user, at least. – morbusg Sep 10 '13 at 8:19
  • @morbusg I think you nailed it. – egreg Sep 10 '13 at 8:56
7

One explanation of the use of \crcr could be that it leaves redefinition of \cr open to the user.

An example of this is in @TH.’s answer on How to use \valign? where he redefines \cr to mean

\def\cr{\crcr\noalign{\hfil}}

so one gets glue between columns in \valign. I think it is very clever.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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