# How make LaTeX interpret each line as a new line within an environment?

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}


# Desired Output

• Try \obeylines. If you don't like it, try \obeycr.
– Mark
Apr 15, 2015 at 9:26
• \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

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}


• Please, remove the mention to \obeycr that isn't relevant. 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). Apr 15, 2015 at 11:19
• 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