LaTeX forum ⇒ Text FormattingHow to make a list in an external file? Topic is solved

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

How to make a list in an external file?

Postby fpires » Thu Oct 13, 2016 1:34 pm

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:

  1. \documentclass[a4paper,12pt]{report}
  3. \begin{document}
  5. Hello, world.
  7. \newwrite\temp
  8. \immediate\openout\temp=Rel
  9. \immediate\write\temp{Annex A}
  10. Some text.
  11. \immediate\write\temp{Annex B}
  12. \immediate\closeout\temp
  14. \input{Rel}
  16. \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!



User avatar
Stefan Kottwitz
Site Admin
Posts: 9504
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Thu Oct 13, 2016 1:49 pm

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:

  1. \immediate\write\temp{Annex A}
  2. Some text.
  3. \immediate\write\temp{}
  4. \immediate\write\temp{Annex B}


  1. \immediate\write\temp{Annex A\par}
  2. Some text.
  3. \immediate\write\temp{Annex B}

Site admin

Posts: 15
Joined: Wed Dec 23, 2015 7:10 pm

Postby fpires » Mon Oct 17, 2016 2:35 pm


thanks again! Great solution!

Return to “Text Formatting”

Who is online

Users browsing this forum: No registered users and 4 guests