Contrarily to pdfTeX and XeTeX, which send ^^M to the terminal for the character 13, LuaTeX sends the character 13 itself. This garbles the output of my terminal (bash under Ubuntu 10.04).

\message{\meaning\foo ab}



i.e., the same as


but smashed into a single line. How can I tell LuaTeX to output ^^M instead?

  • This seems like a bug.
    – egreg
    Commented Jul 31, 2012 at 19:39
  • @egreg I had started to submit a bug report, but then had doubts on whether it was a bug or simply that I should change how ^^M was displayed in my particular terminal. I'll submit a bug report. Commented Jul 31, 2012 at 20:01
  • Bug report submitted. Commented Jul 31, 2012 at 20:10

2 Answers 2


As @egreg says, it looks like a bug to me. For writing to files you can modify a lua callback but unfortunately the callback (as documented) is not called when writing to the terminal.


function  (s)
snew, n =  string.gsub(s,"\string\r","^^M")
return snew

\message{\meaning\foo ab}
\immediate\write\x{\meaning\foo ab}


On the terminal you get

ab )o:->\

but in the file you get:

$ cat nnl.out
  • I'll submit a bug report. Commented Jul 31, 2012 at 20:01

From LuaTeX Reference, beta 0.70.1, section 2.3 UNICODE text support:

Output to the terminal uses ^^ notation for the lower control range (c < 32), with the exception of ^^I, ^^J and ^^M. These are considered 'safe' and therefore print-as-is.

And in the manual are the terminal/log explicitely excluded for process_output_buffer: process_output_buffer (0.43)
[…] It is only called for output to an actual file (that is, excluding the log, the terminal, and \write18 calls).

  • Ah, so that is not a bug, rather a bad feature. However, it leads to a garbled terminal output, so a work-around would be useful. Do you agree with David that there is no appropriate callback for this? Commented Jul 31, 2012 at 21:00
  • 3
    Not really, the output of the terminal/log is messed up anyway with much loss of information (catcodes, line breaks, &hellip;). If you are debugging such stuff, then you can use a decent editor &mdash; the data are not lost, even less shows me the ^^M as control character. Not having a callback has its advantages. The user knows, nobody has messed up with the output, showing beautiful things while doing malicious things. Commented Jul 31, 2012 at 21:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .