4

I have list of file names in a multicol environment. I can use sort commands on them when needed e.g. (sort -u).

I would like to temporarily make LaTeX recognize a single-newline (\n) as a new line. Normally LaTeX recognizes only two newlines (\n\n) as a new line.

The purpose is to get a nice list of file names without using a tabular environment. Multicols automatically determines the ideal height of the list based on the count of items and number of columns.

Code

\documentclass{article}
\usepackage{fontspec}
\usepackage{multicol}

\begin{document}
\begin{multicols}{2}
JPEG
JPEG2000
PDF
PNG
PPM
TIFF
XBM
ZIP
\end{multicols}
\end{document}

Current Output

enter image description here

Desired Output

enter image description here

2
  • 1
    Try \obeylines. If you don't like it, try \obeycr.
    – Mark
    Apr 15, 2015 at 9:26
  • 2
    \obeylines is the answer, which makes a newline a paragraph break (which is also what a blank line signifies: not a newline) Apr 15, 2015 at 9:37

1 Answer 1

7

Try \obeylines.

\documentclass{article}
\usepackage{fontspec}
\usepackage{multicol}

\begin{document}
\begin{multicols}{2}
\obeylines
JPEG
JPEG2000
PDF
PNG
PPM
TIFF
XBM
ZIP
\end{multicols}
\end{document}

enter image description here

4
  • 1
    Please, remove the mention to \obeycr that isn't relevant.
    – egreg
    Apr 15, 2015 at 11:10
  • @egreg Why is \obeycr not relevant? It seems to me that it could be if I were using a carriage return, no? (by the way, \obeylines is what I used of course) Apr 15, 2015 at 11:13
  • @macmadness86 \obeycr should be used only in connection with tables (but it's better not using it).
    – egreg
    Apr 15, 2015 at 11:19
  • 2
    Surely \obeycr is relevant. What if you don't want a paragraph indent at the start of each line?
    – Mark
    Apr 16, 2015 at 18:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.