TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

It's all in the title. How is it possible to output a carriage return in a \message. For debugging purposes, I need to get readable messages. The obvious doesn't work : \message{A\cr B} outputs A\cr B and \message{A\\B} produces an error like this

Undefined control sequence.
\\  ->\let \reserved@e
                        \relax \let \reserved@f 

Thanks for your help !

share|improve this question
up vote 6 down vote accepted

You don't say, but \reserved@a suggests that you are using latex in which case

\message{ab^^Jcde} 

works although it is better to use latex constructs such as \typeout or \PackageInfo

In plain TeX the above \message will work if you set

\newlinechar=`\^^J
share|improve this answer
1  
Thanks for the answer and the hint to use \typeout, that actually solves the whole problem. – Tom-Tom Jan 20 at 9:23

The \message primitive expands input in the same way as \edef and needs something which produces a 'raw' new line to get the desired effect. On the other hand, \\ is a command to produce a line break in typesetting, so fails here (it is also not expandable, hence the odd error). You therefore need to insert a character equal to \newlinechar. In the LaTeX format this is ^^J:

\message{a^^JB}
\stop

In formats where this is not set (such as plain), you'll also need to cover that

\begingroup
  \newlinechar=`^^J %
  \message{a^^JB}
\endgroup
\end
share|improve this answer
    
Thanks for the pedagogical answer ! – Tom-Tom Jan 20 at 9:21

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.