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 use \lstinline{foo} from the listings package to set pieces of code in regular text. To get automatic line-breaks I use the following options:


Sometime code fragments have to go into rather narrow table cells and the automatic line breaks just don't look very nice.

Is there any way to tell \lstinline (and lstlisting) where to insert line-breaks without actually putting them into the LaTeX source literally? If I do hard code them this will influence line numbers (in lstlistings) and also the line continuation symbol and indentation will be missing.

share|improve this question
Welcome to TeX.sx! – Rico Jan 20 '13 at 17:43
This may or may not be somewhat related, depending on your requirements and flexibility: tex.stackexchange.com/questions/124435/… – Steven B. Segletes Aug 5 '13 at 18:17

You can certainly escape into LaTeX and force a break manually, for example

 breaklines        = true,
 breakatwhitespace = true,
 breakindent       = 2ex,
 escapechar        = *,
 numbers           = left

Some text
Some more text Some more text Some more text Some more text
Some more text Some more text *\break* Some more text Some more text
Final text


Whether this is what is required I'm not 100% sure: telling listings where to break without adding anything to the source seems extremely difficult to imagine.

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.