5

This is a follow-up question to Line breaks in listings

My MWE with a very long line demonstrate the problem:

\documentclass{report}
\usepackage{listings}
\lstdefinelanguage{text}{}
\lstnewenvironment{mylang}{\lstset{language=text,breaklines=true,breakatwhitespace=false,extendedchars=true,basicstyle=\footnotesize\ttfamily,}}{}
\begin{document}
\begin{mylang}
demo demo demo demo demo demo demo demo demo demo demo demo demo demo demo demo demo demo demo

demodemodemodemodemodemodemodemodemodemodemodemodemodemodemodemodemodemodemodemodemodemodemo 
\end{mylang}
\end{document}
4

listings add break points only after chars of type "other". You tell it to add e.g. o to the list, but this will break the parsing of keywords:

\documentclass[a5paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{listings,xcolor}
\lstset{keywords=demo,keywordstyle=\color{red},breaklines}
\begin{document}
\begin{lstlisting}
    demo
    demodemodemodemodemodemodemodemodemodemodemodemodemodemodemodemodemodemodemodemodemodemodemo
\end{lstlisting}


\begin{lstlisting}[alsoother=o]
    demo
    demodemodemodemodemodemodemodemodemodemodemodemodemodemodemodemodemodemodemodemodemodemodemo
\end{lstlisting}

\end{document}
  • Do you have any idea how to manage adding other and parsing of keywords at the same time? – LaRiFaRi Jul 23 '13 at 10:25
  • @LaRiFaRi: what about the otherkeywords option? (see listings documentation) – masu Oct 25 '13 at 9:21

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.