8

Is there a way like wrap the line after at most 60 letters but it should not break inside some commands like listings does?

Example:

    \documentclass[a5paper]{article}
    \usepackage[T1]{fontenc}
    \usepackage[utf8]{inputenc}
    \usepackage{listings}
    \usepackage{xcolor}

    \lstset{%
      language=[LaTeX]TeX,
      backgroundcolor=\color{gray!25},
      basicstyle=\ttfamily,
      breaklines=true,
      columns=fullflexible
    }

    \begin{document}
    \begin{lstlisting}
    The roadrunner is the fastest running bird \remark{Check this again with a zoologist!}.
    \end{lstlisting}
    \end{document}

Output:

    The roadrunner is the fastest running bird         remark{Check this again with a zoologist!}.

That should not happen! In my eyes this problem is not discussed in verbatim environment that can break too long lines.

  • 4
    Would breakatwhitespace=true be good enough? – Torbjørn T. Feb 12 '13 at 0:26
4

Thanks to Torbjørn T., my question is answered:

One simply has to say:

\lstset{%
  breaklines=true,
  breakatwhitespace=true,
}

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.