LaTeX TeX command write is not inserting new lines where expected

  • Thread starter Thread starter Eclair_de_XII
  • Start date Start date
  • Tags Tags
    Lines
AI Thread Summary
The discussion revolves around writing newlines into an output file using PlainTeX. The original poster expresses frustration that standard commands like \newline and \par only create line breaks in typesetting and do not function for writing newlines in an output file. They seek alternatives and mention a link to a resource that discusses newline commands, but those suggestions have not resolved their issue. There is a mention of using Overleaf and AMS packages, but the poster is specifically interested in solutions that work with PlainTeX. A clarification occurs regarding a misunderstanding about LaTeX versus TeX, indicating a focus on PlainTeX solutions.
Eclair_de_XII
Messages
1,082
Reaction score
91
TL;DR Summary
I'm trying to learn how to use the \write command in order to tell TeX to write files. I want to start a new line with each message inserted. According to TeX for the Impatient, whenever the program encounters the character whose charcode is given by the numerical \newlinechar parameter, the engine starts a new line. Such is not the case for the code below. Why is this?
Code:
\documentclass{article}

\newlinechar=`\^^J

\def\first{This is the first sentence.^^J}
\def\second{This is the second sentence.^^J}
\def\third{This is the third sentence.^^J}
\def\nth{You get the idea.^^J}

\def\outfile{outfile.txt}
\newwrite\myout

\begin{document}

\immediate\openout\myout=\outfile
\immediate\write\myout{\first}
\immediate\write\myout{\second}
\immediate\write\myout{\third}
\immediate\write\myout{\nth}
\immediate\closeout\myout

\end{document}
 
Physics news on Phys.org
The thing is, the commands there, like \newline and \par only typeset new-lines (line-breaks?). I want to write new-lines into an output file, and unfortunately, none of the commands I've tried in that link seem to work for that purpose. Thanks for the input, besides.
 
You can always use overleaf and import the ams...
 
I was sort of looking forward to doing this using just PlainTeX.

In any case, are you referring to an ams package that they have hosted on that web-site?
 
Eclair_de_XII said:
I was sort of looking forward to doing this using just PlainTeX.

In any case, are you referring to an ams package that they have hosted on that web-site?
Yes. my mistake. I read LaTek instead of TeX for some odd reason.
 
Back
Top