Text FormattingHow to make a list in an external file?

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
fpires
Posts: 15
Joined: Wed Dec 23, 2015 7:10 pm

How to make a list in an external file?

Post by fpires »

Hello, all!

It's me again. This time I have the following problem: I cannot make a list of words in an external file. I will explain it better with the following example:

Code: Select all

\documentclass[a4paper,12pt]{report}

\begin{document}

Hello, world.

\newwrite\temp
\immediate\openout\temp=Rel
\immediate\write\temp{Annex A}
Some text.
\immediate\write\temp{Annex B}
\immediate\closeout\temp

\input{Rel}

\end{document}
With the above code I have the intention to make a list with the expressions Annex A and Annex B, i. e., I would like that Annex A be written in a line and Annex B be written in another line below Annex A, like this:

Annex A
Annex B

However, what I get is the two expressions written at the same line: Annex A Annex B.

There may be a way to write the two expressions in a list with the same \immediate\write command, but the question is that the information of the expression Annex B depends on what is written in Some text.. That is why I break up the code in two \immediate\write commands.

Well, sorry for the long text, and thank you again!

Felipe

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

How to make a list in an external file?

Post by Stefan Kottwitz »

Hi Felipe,

very good minimal example!

I noticed that it's written correctly to the file:

Annex A
Annex B

But a line break doesn't mean a paragraph break (or a line end) in TeX, it just means a space. For a paragraph break, you need an empty line or a \par command.

So, you could write:

Code: Select all

\immediate\write\temp{Annex A}
Some text.
\immediate\write\temp{}
\immediate\write\temp{Annex B}
Or:

Code: Select all

\immediate\write\temp{Annex A\par}
Some text.
\immediate\write\temp{Annex B}
Stefan
LaTeX.org admin
fpires
Posts: 15
Joined: Wed Dec 23, 2015 7:10 pm

Re: How to make a list in an external file?

Post by fpires »

Stefan,

thanks again! Great solution!
Post Reply