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

When writing about LaTeX, I tend to use \verb, which could look like that:


Lorem ipsum dolor sit amet, consectetuer adipiscing elit. \verb+\documentclass{article}+

Thus I get the following result:


Is there another way to display LaTeX commands properly in continuous text or atleast some way to prevent \verb from going over the end of the line?

(For longer code I obviously would use something like listings)

share|improve this question
up vote 7 down vote accepted

The listings package provides lots of commands, including the \lstinline[<options>]!code!, and in particular, you can use



A complete MWE follows- you can explore global settings using \lstset in your preamble.


Lorem ipsum dolor sit amet, consectetuer adipiscing elit. \lstinline[breaklines=true]!\documentclass{article}!
share|improve this answer
Great, for I am using this somewhat regularly I put the option breaklines=true in the preamble to \lstset, which works like a charm. – polyfunc Dec 29 '12 at 7:34
@ChristianR. glad it works :) – cmhughes Dec 29 '12 at 17:19

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.