TeX command write is not inserting new lines where expected

  • #1
Eclair_de_XII
1,067
90
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}
 

Answers and Replies

  • #3
Eclair_de_XII
1,067
90
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.
 
  • #4
MidgetDwarf
1,406
557
You can always use overleaf and import the ams...
 
  • #5
Eclair_de_XII
1,067
90
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?
 
  • #6
MidgetDwarf
1,406
557
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.
 

Suggested for: TeX command write is not inserting new lines where expected

  • Last Post
Replies
5
Views
591
  • Last Post
Replies
2
Views
817
Replies
10
Views
475
Replies
2
Views
433
Replies
5
Views
718
  • Last Post
Replies
1
Views
1K
  • Last Post
Replies
4
Views
1K
Replies
1
Views
645
Replies
4
Views
1K
  • Last Post
Replies
1
Views
914
Top