Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

1 Answer 1

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.