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

A user of my menukeys package found a strange error an if don’t have any idea what’s the cause and all the more how to fix it …

The following example make the bullet move to the right inside the text if there is a \menu including \lstinline right behind \item.


    \item Test
    \item \menu{Test \lstinline|test|}
    \item \lstinline|test|
    \item \menu{Test}
    \item \mbox{}\menu{Test \lstinline|test|}

strange result

The user found out the an \mbox can help but this should’t be the only way to fix this – I hope …

share|improve this question
Supplying \lstinline (or any verbatim content) as an argument to a macro is a problem. Look at how the formatting differs from item 3 (correct) and that inside \menu. For small inline verbatim content, boxing before passing as an argument is almost always an option. – Werner Sep 16 '12 at 16:09
The problem disappears if \leavevmode is put at the beginning of the definition of \menu. This shouldn't be a problem, because the all the "menu" commands are to start a new paragraph. – egreg Sep 16 '12 at 16:18
Finally fixed in version 1.2, which will be available on CTAN soon. – Tobi Jul 23 '13 at 11:15
up vote 5 down vote accepted

LaTeX's \item of environment itemize delays the setting of its label by using \everypar. The label is stored in a box, printed at the start of the paragraph to the left (\parindent is 0pt) and the box is void afterwards.

\menu of menukeys uses \tikz. That stores the contents in a box first and afterwards the box is set. Very simplified:


The contents of \menu/\tikz contains \lstinline. It calls \leavevmode right at the beginning. This explains, why \lstinline right after \item works. Inside an \hbox \leavevmode does not start a paragraph. \lstinline calls \lst@Init, an excerpt from its definition:

  \ifhmode\ifinner \lst@boxtrue \fi\fi
    \hbox to\z@\bgroup
      $\if t\lst@boxpos \vtop
    \else \if b\lst@boxpos \vbox
    \else \vcenter \fi\fi
    \bgroup \par\noindent

Default for \lst@boxpos is b, thus \noindent starts a paragraph inside a \vbox. At the begin of the paragraph \everytoks is executed and the label is set. Afterwards the label box is void (by \box, up to the group level of \item). This explains the label inside the menu item.

Then the menu item that has been stored in a box is set as entry in the itemize environment, correctly using \leavevmode. But it is too late now, the label is already set and is not repeated, the label box is void.

Fix suggestions:

  • As egreg already said, \menu (and the other similar macros) should call \leavevmode right at the beginning. Anyway \menu will print material that will start a paragraph.

    Manually it can be redefined:

    \protected\def\menu{\leavevmode\org@menu}% or
    % \renewcommand*{\menu}{\leavevmode\org@menu}
  • \lst@Init uses the hook \lsthk@BoxUnsafe if a vertical box is used. \everypar can be cleared there:


Both ways fix the issue:


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.