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

Consider the following LaTeX document:


I would expect the \\ and \linebreak commands to produce a line break each, so the typeset output ought to look like


However, the actual output is

Foo               Bar

How do I produce an explicit line break inside a fancyvrb-based verbatim environment?

(Incidentally »Just hit Return« isn't the answer I'm looking for. I have lots of text based on the alltt environment which contains markup like

Foo\nextline Bar

I use this to introduce »typographic« line breaks in shell command output, where there is no actual line break in the output but I need to start a new line because there is no more room on the current line. In my document, these »typographic« line breaks can be distinguished from genuine line breaks because there is a special symbol before/after the line break, along the lines of


I'd much rather not change a couple thousand pages' worth of documentation.)

share|improve this question
Would using listings instead of (or together with) fancyvrb be acceptable? If this is the caso, you van keep your current environment in the doucment body and simply define it differently in your preamble; something like \documentclass{article} \usepackage{listings} \lstset{% basicstyle=\ttfamily, breaklines=true, columns=fullflexible, escapeinside = ||, breakindent=0pt, } \lstnewenvironment{example}{}{} \begin{document} \begin{lstlisting} Foo|\\|Bar \end{lstlisting} \end{document} – Gonzalo Medina May 9 '12 at 17:16
I'm afraid fancyvrb typesets each line in a \hbox. The listings package allows for line breaks and even provides hooks for symbols at end and start of broken lines. – egreg May 9 '12 at 17:24

I am afraid fancyvrb doesn't allow what you want to do; a possible workaround would be using the listings package instead of (or together with) fancyvrb (listings offers automatic line breaking and many other useful features; please refer to the package documentation for details). You can keep your current example environment in the document body, and simply define it using listings in your preamble; something like this:


  escapeinside = ||,




enter image description here

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.