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

Discussion Overview

The discussion revolves around the issue of inserting new lines into an output file using TeX commands. Participants explore various methods and alternatives for achieving this, focusing on the specific requirements of writing new lines rather than typesetting them.

Discussion Character

  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant presents a code snippet attempting to use the \newlinechar and \write commands to insert new lines into an output file.
  • Another participant suggests exploring alternative methods for adding new lines, referencing external resources for potential solutions.
  • A participant clarifies that commands like \newline and \par are intended for typesetting new lines, not for writing them into an output file, expressing frustration that previous suggestions did not meet their needs.
  • There is mention of using Overleaf and importing AMS packages, although the relevance to the original problem is unclear.
  • One participant expresses a preference for using PlainTeX and seeks clarification about an AMS package mentioned by another participant.
  • A later reply acknowledges a misunderstanding regarding the reference to LaTeX instead of TeX, indicating some confusion in the discussion.

Areas of Agreement / Disagreement

Participants do not appear to reach a consensus on the best method for inserting new lines into an output file, with multiple competing views and suggestions remaining unresolved.

Contextual Notes

Participants express uncertainty about the effectiveness of various commands and methods, indicating that the solutions may depend on specific definitions or contexts within TeX.

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
4K
  • · Replies 17 ·
Replies
17
Views
3K
Replies
0
Views
903