1. Vedran Miletić
  2. beamer
  3. Issues
Issue #93 resolved

Starting a frame with \verb

Anonymous created an issue


When I start a frame with a \verb command, the output looks wrong:



\documentclass{beamer} \begin{document} \begin{frame}[fragile] \verb|hello -> world| is broken \end{frame} \end{document}


The result is identical in Beamer 3.06 in TeX Live 2007 (Fedora 11) and Beamer 3.10 in MiKTeX 2.9 (WinXP). Instead of hello -> world, the output says |hello-¿ world-

The problem can be circumvented by adding extra whitespace in front of the \verb, but I believe the current behavior is a bug.

Thanks for your work on Beamer,


Comments (6)

  1. Joseph Wright

    Okay, this happens because beamer writes the fragile frame input to an intermediate file.

    TeX is inserting an additional space after the first token in the frame as it is being read as a control sequence. So you get

    \verb |hello -> world| is broken

    whereas with an additional blank line you get

    \par \verb|hello -> world| is broken

    I'll take a look and try to find why the first token is being read in this way.

  2. Joseph Wright

    Okay, here is the technical analysis of the issue. beamer is pretty flexible about reading the first line of the frame, and allows a lot of variation in what might be present. The way that this is done is to look ahead for a number of different things. This uses the \futurelet primitive, which will tokenize whatever it reads. Thus the very first token after


    will have been tokenized before any steps have been taken by beamer. For everything else in the frame, the input is read verbatim, avoiding any issues. Now, the question is 'can we find a good way to reverse this?'.

  3. Joseph Wright

    Right, I have a possible solution. This might be a bit risky, so I think it will need some serious testing. I've attached a diff which shows the approach: basically, you need to sanitize the first token in the input. That requires some adjustments to the reading mechanism, space-stripping from control sequence input and and adjustment to how titles are read.

  4. Joseph Wright

    Detect blank line read as \par when first line of verbatim frame (fixes issue #215)

    When reading verbatim, we have an issue as beamer is rather too flexible with the first token in the frame: see issue #93 for when this can go wrong. If the first token in the frame is a blank line, TeX will convert this to a \par token. The best way to deal with this is to detect such a token and write as a blank line to the .vrb file. (It is much more likely that a blank line has been read than an actual \par token.)


  5. Log in to comment