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

I'm trying to make a pdf language definition for the listings package, but I can't get the string definition to work correctly. This is what I have defined:

morekeywords={/Type,/Outlines, /Count, /Kids, /Page,
    /Parent, /Resources, /MediaBox, /Contents, /Length, /ProcSet, /PDF, /Size,
    /Root, /Pages, /Catalog, /Font, /F1, /F2, /Text, /Subtype, /Type1, /Name,
    /BaseFont, /Helvetica-Bold, /Encoding, /MacRomanEncoding, /Helvetica},

Here you can see the result:

enter image description here

It should either go from ( to ), or maybe from BT to ET (which is what vim does).

Okay. So I figured it out. For some reasons using breaklines=true creates this error.

Here is a minimal working example that produces the error:

\usepackage{babel, listings, color}

\lstset{ %
    breaklines=true,% Produces the error in the highlighting

    morekeywords={/Length, /F1},


5 0 obj
<< /Length 44 >>        
/F1 27 Tf
100 100 Td (Hello World) Tj


But I need to have breaklines set to true. So anybody know a reason why this is happening? Or is it just a bug in the listings package?

share|improve this question
Unfortunately I have no solution. Maybe you are interested in minted with the language postscript: pygments.org/demo/82411 – Marco Daniel May 25 '13 at 9:56
related: tex.stackexchange.com/questions/73795/… – Jubobs Mar 11 '14 at 21:18
Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count (see How do you accept an answer?). This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). It's part of this site's idea to identify good questions and answers through upvotes and acceptance of answers. – Jubobs Mar 18 '14 at 16:03
up vote 4 down vote accepted

There appears top be special code "currently only for )" when breakline is active (listings.dtx 1.4, l. 12576):

% \begin{macro}{\lst@breakProcessOther}
% is the same as |\lst@ProcessOther| except that it also outputs the current
% token string. This inserts a potential linebreak point.
% Only the closing parenthesis uses this macro yet.
%    \begin{macrocode}
    {\lst@ifbreaklines \lst@Def{`)}{\lst@breakProcessOther)}\fi}
%    \end{macrocode}

There are probably better ways to remove that from the hook again, but this seems to do, when put in the preamble:

\def\uglypatch #1\lst@ifbreaklines#2\fi#3\uglypatch{%
share|improve this answer

Your Answer


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.