1

Ok, this may be an easy one but I've been googling a lot without success.

I have a long text with many lines separated by the new line character. What I want to do is itemize this text so that every line corresponds to an item in a list. I definitely can do:

\begin{itemize}
   \item
\begin{itemize}

but the lines are just too many to start adding an \item code at the beginning of every line. I can definitely write a script to automate this process, but I want to know: Is there a way make a list in latex with items separated by the new line character instead of writing \item at the beginning of every item?

Let me know if I can be more clear.

  • If you have blank lines in between you can use (more or less) \everypar{\textbullet} but if you really mean every line you need (in addition) \obeylines as normally an end of line is treated as a space. (But I'd just use your editor to add the \item) – David Carlisle Nov 10 '14 at 0:27
  • Welcome to TeX.SE. It would be helpful if you composed a fully compilable MWE including \documentclass and the appropriate packages that sets up the problem. You description is clear, but still would be nice to have something to start with. Furthermore, the test case would go a long way in clarifying any issues. Such as, are the lines all short text (a few words), or do they sometimes contain loner text that may spill over onto multiple lines in the output? Basically, produce a test case. – Peter Grill Nov 10 '14 at 1:37
  • Perhaps you'd like the easylist package. (Although it, too, reasonably expects something to mark an 'item'....) – jon Nov 10 '14 at 2:22
2

Expanding on David Carlisle's suggestion you can issue \obeylines and set \everypar in a way that produces a bullet and appropriate spacing. Enclosing everything in a \bgroup...\egroup will also limit the scope of these changes.

Sample output

\documentclass{article}

\begin{document}

\noindent
Some text to indicate the left margin.

\bgroup\obeylines\everypar{\hspace*{2em}\textbullet\enspace}
A text line that is to be an item.
A text line that is to be an item.
A text line that is to be an item.
A text line that is to be an item.
A text line that is to be an item.
A text line that is to be an item.
A text line that is to be an item.
A text line that is to be an item.
A text line that is to be an item.
A text line that is to be an item.
A text line that is to be an item.
A text line that is to be an item.
A text line that is to be an item.
A text line that is to be an item.
A text line that is to be an item.
A text line that is to be an item.
A text line that is to be an item.
A text line that is to be an item.
A text line that is to be an item.
A text line that is to be an item.
A text line that is to be an item.
A text line that is to be an item.
A text line that is to be an item.
A text line that is to be an item.
A text line that is to be an item.
A text line that is to be an item.
A text line that is to be an item.
A text line that is to be an item.
\egroup

\end{document}

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.