When using the \lstinline macro from listings, like


some extra whitespace is added to the intended text. It is especially painful at the end of the line: it behaves as if it were a new paragraph, and adds some unwanted indentation. How can I get rid off this? See the example below: the comma immediately following \lstinline goes to the beginning of the next line.

enter image description here

normal text normal text \lstinline{reg1}, \lstinline{reg2}, normal text
  • Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – jub0bs Jan 18 '15 at 18:12
  • Will these \lstinlines always fit on one line or can the be expected to linebreak in the middle of the \lstinline? If one line, then \mbox{\lstinline{reg1},} would work. – Steven B. Segletes Jan 19 '15 at 13:00
  • Check out tex.stackexchange.com/a/200494/21891 – jub0bs Jan 19 '15 at 16:01
  • 1
    @Steven B. Segletes I simply want to write a continuous text, like "instructions like \lstinline|add|, \lstinline|sub| and \lstinline|mul|" and the unwanted space in \lstinline makes the output ugly, either by separating the inline text and the comma following it, or even starting an unwanted indentation in the next , starting with space and comma at the beginning. – katang Jan 24 '15 at 18:21
  • 1
    What is the purpose of the breaklines,postbreak=\kern-1ex options here when you say you don't need to break inline listings across lines? Removing those options fixes the issue – siracusa Oct 18 '18 at 21:45

Browse other questions tagged or ask your own question.