0

longline*.txt files contain some text and in some files the text is inserted in an environment as indicated in the filename.

The following script:

\documentclass{article}
\usepackage{listings}
\begin{document}
\input{longline.txt}

\input{longline_verbatim.txt}

\input{longline_lstlisting.txt}

\end{document}

reveals a different rendering of the text:

enter image description here

The actual text contains characters such as _ and the lstlisting and verbatim environments are evaluated as a rescue.

The problem is that the paragraph is not broken down into lines in the verbatim and lstlisting environment.

How to solve the problem?

Viesturs
  • 7,895

1 Answers1

1

This example for the listings package can help you.

\documentclass{article}
\usepackage[cp1251]{inputenc}
\usepackage[english]{babel}
\usepackage{listings}
\usepackage{lipsum}

\begin{document}
    \lipsum[1]

    \lstset{
        linewidth=\linewidth,
        breaklines,
        breakatwhitespace=true,
        breakindent=0pt,
        basicstyle=\fontsize{9}{11}\usefont{T1}{cmr}{m}{n}\selectfont
    }
    \lstinputlisting{long.txt}
\end{document}

The file long.txt contains plain text divided into paragraphs: enter image description here

And the result: enter image description here

Vladimir
  • 436