“! You can't use \raise' in internal vertical mode” error

I used the command \raise to superimpose a title to a writing.

I got the error

! You can't use \raise' in internal vertical mode


which puzzled me for a while.

For those interested, here is my code :

\def\withHatTitle#1#2{% #1: title #2: content
\setbox1=\hbox{#2}
\ifdim\wd1<\wd0\wd1=\wd0\fi% if title longer than content, title gives the size
\setbox0=\hbox{\makebox[\wd1]{\box0\leaders\hrule height3pt depth-2pt\hfill}}% complete title with hrule
\wd1=0pt \box1 \raise 11pt \box0}% superpose title and content

• Maybe, if you tell what's the aim of this, you could receive advice about how to do it better. – egreg Dec 25 '15 at 11:01
• You might want to start your definition with \ifvmode\leavevmode\fi to enable \withHatTitle to start a paragraph. – Henri Menke Dec 25 '15 at 16:29
• I made this macro in order to be able to have one line with a title followed by a ruler to "group" underneath several items that include checkboxes. (I have a picture of the result but I cannot find out to download it here). I posted this because I had this error I was unable to cope with. – user1771398 Dec 25 '15 at 18:44
• @Henri Menke I adopted the solution since it is the more economical : nothing is added when it is not necessary (i.e. when already in horizontal mode). Thanks ! – user1771398 Dec 25 '15 at 22:51
• Note the definition is missing % from ends of lines and so adds two word spaces before the text, see the output from [\withHatTitle{The title}{This is the text to be titled}] which makes [ space space This...titled] – David Carlisle Jan 17 '16 at 12:14

The explanation for this error is that \raise is forbidden in vertical mode, that is roughly when Tex piles up boxes in vertical.

Thus, the solution is simple : exit from the vertical mode. A simple solution consists in enclosing my macro \withHatTitle with a \hbox command, as follows:

\hbox{\withHatTitle{The title}{This is the text to be titled}}


Hope this helps !

P.S. the former is true also with \lower.

• beware that such a command will not act like any other latex command, no latex box making command starts with a box in this way \mbox, \fbox, \includegraphics, \raisebox (which is the latex version of \raise of course) all start out with \leavevmode – David Carlisle Jan 17 '16 at 11:28

As your suggested code uses \makebox it is clear this is intended for LaTeX. LaTeX box commands always use horizontal mode to avoid this and other problems. The direct analogue of \raise is \raisebox but here a tabular seems more natural.

\documentclass{article}
\begin{document}

\newcommand\withHatTitle[2]{\begin{tabular}[b]{@{}l@{}}%
#1 \hrulefill\\%
#2\end{tabular}}

a \withHatTitle{The title}{This is the text to be titled}

\bigskip

\withHatTitle{The title}{This is the text to be titled}

\end{document}

• The initial idea was to have a box, with a black outline, that groups several items (checkboxes in fact), horizontally placed, and a title on the upper border to name that group. Later, I simplified the box with only the upper border outlined. Therefore, the name of the group is astride the border. – user1771398 Jan 24 '16 at 16:04