[texhax] Writing explicit newline to external file

Oleg Katsitadze olegkat at gmail.com
Mon Jun 11 21:09:16 CEST 2007

On Mon, Jun 11, 2007 at 06:52:08PM +0200, Toby Cubitt wrote:
> > \newlinechar=`^^J
> > \write\@stream{blah blah^^Jfoo bar}
> That does the trick! Thanks very much!

You're welcome :)!

> In fact, it even seems to work without the first line.

I suspect that's because LaTeX (or something else) has already set it
like that (see below).

> I guess I was
> close with my attempt using ^^M, but picked the wrong control character.

In fact, you can use any ASCII character you like for \newlinechar.
This tells TeX to break a line at this character.  E.g., try this:


^^J is kind of a standard, though.  And if you set \newlinechar=-1
(which is the default in plain TeX), no such conversion will take

>   It works under both Windows and Unix, but I wonder if using linefeed
> instead of carriage return will cause problems in other ways?

I believe this will work on any system, because the TeX port knows the
native "line break" for the platform, so the \newlinechar will be
converted to whatever the line break on the system happens to be.


More information about the texhax mailing list