4

With TeX Live 2009, with this MWE.

\documentclass{article}
\usepackage{fancyvrb, fancybox}  
\begin{document}
    \begin{Verbatim}[frame=single]
      auto eth0
    \end{Verbatim}
\end{document}

I get the following error when compiling

Runaway argument?
      auto eth0^^M    \end{Verbatim}^^M^^M\end{document} ! File ended while scanning use of \Verbatim. <inserted text> 

Using

\usepackage{fancybox, fancyvrb}

makes the error go away, but it is disturbing. I assume that fancyvrb depends on fancybox, but the packages don't handle this gracefully. This took me a while to track down. For reference, I was looking at Peter Flynn's example in http://groups.google.com/group/latexusersgroup/browse_thread/thread/c8c2e5dd1e9ff5cf

The message in question starts with

I don't understand the problem. What I wrote works in any class. Just copy and paste it into a report.

and his example has those packages loaded in that order, to be precise \usepackage{fancyvrb,fancybox,calc}. So my question is, what is going wrong here precisely, and how can I effectively debug these kinds of issues in the future?

UPDATE: The choice between's Enrico's solution and Werner's solution was basically a tossup. I did like Enrico's identification of a problem with the fancybox Verbatim environment. However, I still am not clear how one can efficiently identify these problems when they crop up. If anyone has debugging tips, I'd like to hear them.

7
  • \end{Verbatim} must start in the first column of a line
    – user2478
    Dec 25, 2011 at 21:04
  • @Herbert: Not sure what you mean. Dec 26, 2011 at 0:48
  • spaces before \end{Verbatim} are not allowed.
    – user2478
    Dec 26, 2011 at 6:47
  • @Herbert: Don't follow. Not allowed according to who/what? Dec 26, 2011 at 8:11
  • Debugging starts with patience! :) You literally have to pull the code apart by removing things (unnecessary packages, code or commands) in order to find the root of the problem. It's very subjective, since experience plays a big part in where to look and what to look for. For example, since load order played a part here, it definitely made me suspicious that one package might redefine a command. Completely dropping one was sufficient. Then, upon further investigation, I noticed the difference in notation, and experimented with either. Widdling it down to an MWE is always best.
    – Werner
    Dec 30, 2011 at 5:53

3 Answers 3

4

You should have noticed that in Peter Flynn's message the syntax used is

\begin{Verbatim}{frame=single}

and not

\begin{Verbatim}[frame=single]

This makes quite a big difference. Moreover, the Verbatim environment as redefined by fancybox seems not to like blank spaces in front of \end{Verbatim}: the following input

\documentclass{article}
\usepackage{fancybox}
\begin{document}
\begin{Verbatim}{frame=single}
   auto eth0
 \end{Verbatim}
\end{document}

raises the

Runaway argument?
{frame=single}^^M   auto eth0^^M \end{Verbatim}^^M\end{document}^^M
! File ended while scanning use of \FV@BeginScanning.

error.

Of course, both packages trying to redefine \VerbatimEnvironment is not very helpful to the user. However, if you load fancyvrb as second, you get all of its functionality, without losing fancybox's as regards to boxes and frames. The implementation of the verbatim environments in fancybox seems buggy (the requirement that \end{Verbatim} starts on column 1 is surely a bug), so I believe it's best to say

\usepackage{fancybox,fancyvrb}
4
  • Hi egreg. Thanks for the pointers. Firstly, Peter seems to think that he is using the fancyvrb package ("The Verbatim (capital V) environment from fancyvrb still has that restriction, but has options for a frame and a lot of other bells and whistles."), but as you point out, with the Verbatim env in fancyvrb you would have [frame=single] not {frame=single}. You imply (but do not say) that the latter usage is from fancybox. Unfortunately this is not clear from the fancybox docs. Dec 25, 2011 at 13:23
  • I'm not clear what you mean by "Moreover, the Verbatim environment as redefined by fancybox seems not to like blank spaces in front of \end{Verbatim}". I stuck blank spaces in various places, but it didn't seem to mind. As I mentioned in my answer to Werner, reformatting code gives an error, so there is something wrong here, but not sure what. Also, am even less clear what you mean by "the requirement that \end{Verbatim} starts on column 1 is surely a bug". Perhaps you could give an illustrative example? Thanks. Dec 25, 2011 at 13:25
  • Thanks for the illustrative example. I think you meant to put fancybox rather than fancyvrb in your example, at the current version doesn't really illustrate your point. With fancyvrb you get an error with and without a space in front of \end{Verbatim}. And I'm not sure about "redefined". Where is Verbatim earlier defined, such that fancybox is redefining it? Dec 26, 2011 at 0:46
  • @FaheemMitha Yes, it was fancybox and not fancyvrb
    – egreg
    Dec 26, 2011 at 11:07
5

The problem here is that both packages define internal commands that are very similar, yet conflicting. For example, fancyvrb defines

\def\VerbatimEnvironment{%
  \ifx\FV@EnvironName\relax\xdef\FV@EnvironName{\@currenvir}\fi}

while fancybox defines

\def\VerbatimEnvironment{%
  \ifx\@VerbEnvir\relax\xdef\@VerbEnvir{\@currenvir}\fi}

Not to say that this is the root of the problem, but it is meant to illustrate the similarities between some of the definitions. As such, switching the load order of the packages could make the one package work, but not the other.

Why does the load order

\usepackage{fancybox,fancyvrb}

work? Well, because you only used functionality provided by fancyvrb making the load/use of fancybox unnecessary. Why does Peter's suggested solution work? Well, because he didn't need to load fancyvrb in the first place, since he only used fancybox functionality.

How come you were not alerted of conflicting commands until compilation? That's because many macro definitions and environments are constructed using TeX's \def rather than LaTeX's \newcommand. The latter automatically checks to see whether a command already exists and issues an error if it does, while the former happily overwrites a previous definition.

Perhaps this could be considered a partial incompatibility between the two packages - an incompatibility none the less.

2
  • Thanks for the summary, Greg. Would best usage be to use \newcommand rather than \def? And do you think the errors in my example above stem from fancybox overwriting something that fancyvrb has defined? Actually, Peter's version gives errors too, but (improbably) whether there is an error seems to depend on how it is formatted. I didn't investigate carefully to make sure of this though. I see both fancybox and fancyvrb define a Verbatim environment. How can you tell Peter is not using fancyvrb functionality? Dec 25, 2011 at 8:12
  • @FaheemMitha: 1) Many package writers use \def which is pure TeX syntax. \newcommand, \renewcommand and \providecommand are from LaTeX and have the built-in checks for existence/not and overwriting. 2) The errors are a combination of the dual loading of conflicting packages, as well as probably an outdated version that you have (since you're running TeX Live 2009, I'm not sure how up-to-date it is; both packages are dated 15/05/2010). 3) Peter's MWE compiled the same with and without fancyvrb.
    – Werner
    Dec 25, 2011 at 15:57
0

The following works.

\documentclass{article}
\begin{document}
    \begin{verbatim}[frame=single]
      auto eth0
    \end{verbatim}
\end{document}
8
  • 1
    That doesn't answer my question, sorry. Dec 25, 2011 at 2:07
  • Is there a Verbatim environment?
    – Sony
    Dec 25, 2011 at 2:11
  • Yes, the Verbatim environment is from the fancyvrb package. Dec 25, 2011 at 2:15
  • OK thanks. Your code (without including fancybox package) works in TeX Live 2011. No errors.
    – Sony
    Dec 25, 2011 at 2:18
  • Yes, I know. My question is why including fancybox creates problems. If you look at the posting I cite, you'll see this is a stripped down version of code by Peter Flynn. Dec 25, 2011 at 2:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .