TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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}
share|improve this question
up vote 4 down vote accepted

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}
share|improve this answer
    
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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.