tags:

views:

131

answers:

1

I want to generate a PDF of user-submitted text using LaTeX. To handle crazy user input, I first thought about using the verbatim package, but of course it doesn't break up too long lines. Is there some package that works similar to verbatim (i.e., accept any input) but formats the text nicely?

A: 

You can use \def\@xobeysp{ } in the preamble of your document to make all spaces regular (breaking) spaces. This will not hyphenate or break ultra-long words, though.

To format the text nicely, you can use the Verbatim environment, in the fancyvrb package:

\begin{Verbatim}[formatcom=\sffamily]
  Hello world hello world hello world
  Test
\end{Verbatim}

Will print the text in a Sans-seriF font family.

Though (I'm sorry!) the \def\@xobeysp{ } won't work with the Verbatim environment... So you must choose between the two.

Pindatjuh