TeX command write is not inserting new lines where expected

  • Context: LaTeX 
  • Thread starter Thread starter Eclair_de_XII
  • Start date Start date
  • Tags Tags
    Lines
Click For Summary
SUMMARY

The forum discussion focuses on the issue of the TeX command \write not inserting new lines as expected when writing to an output file. The user attempts to use the newline character defined by \newlinechar and various commands like \newline and \par, but these only produce line breaks in typesetting, not in the output file. The discussion highlights the need for alternative methods to achieve the desired output in PlainTeX, as the user expresses a preference for this over using LaTeX or AMS packages.

PREREQUISITES
  • Understanding of TeX and PlainTeX syntax
  • Familiarity with the \write command in TeX
  • Knowledge of newline character handling in TeX
  • Basic experience with output file management in TeX
NEXT STEPS
  • Research alternative methods for inserting new lines in TeX output files
  • Learn about the differences between PlainTeX and LaTeX
  • Explore the use of the AMS packages in TeX
  • Investigate the \newlinechar command and its applications in TeX
USEFUL FOR

This discussion is beneficial for TeX users, particularly those working with PlainTeX, developers looking to manage output files effectively, and anyone encountering newline issues in TeX document processing.

Eclair_de_XII
Messages
1,082
Reaction score
91
TL;DR
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.
 
  • Like
Likes   Reactions: jedishrfu
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.
 

Similar threads

  • · Replies 8 ·
Replies
8
Views
12K
  • · Replies 9 ·
Replies
9
Views
6K
  • · Replies 11 ·
Replies
11
Views
6K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 8 ·
Replies
8
Views
4K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 3 ·
Replies
3
Views
1K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 17 ·
Replies
17
Views
3K
Replies
0
Views
892