I stumbled about some, to my understanding, unexpected behaviour of the expl3 command \hbox_overlap_right:n. I was expecting all examples below to produce the same result, that is, the frame box sitting at the same position as the yellow box. But only the \makebox example produces the expected result. The expl3 examples even insert a line break between the yellow and the frame boxes. What is going wrong?


%doesn't work
%doesn't work either
%LaTeX2e working as expected

enter image description here

  • 2
    You're forgetting, at the least, that \hbox doesn't start horizontal mode. – egreg Mar 21 '14 at 10:58

The function \hbox_overlap_right:n is just the same as the Plain TeX \rlap (apart being \protected), while \hbox_to_zero:n is the same as \hbox to 0pt:

> texdef -t latex -p expl3 'hbox_overlap_right:n'

\protected\long macro:#1->\hbox_to_zero:n {#1\tex_hss:D }

> texdef -t latex -p expl3 'hbox_to_zero:n'

\protected\long macro:#1->\tex_hbox:D to\c_zero_dim {#1}

> texdef -t latex frame

\long macro:#1->\leavevmode \hbox {\hskip -\@wholewidth \vbox {\vskip -\@wholewidth \hrule \@height \@wholewidth \hbox {\vrule \@width \@wholewidth #1\vrule \@width \@wholewidth }\hrule \@height \@wholewidth \vskip -\@wholewidth }\hskip -\@wholewidth }

Since the primitive \hbox doesn't start horizontal mode, while \frame and \makebox do, the result you get is normal.

Add \leavevmode before \hbox_overlap_right:n.

| improve this answer | |
  • @cgnieder: Thank you both! Good to know. There were blank lines in the package file within macro definitions (for increasing readability). Now I know that I have to avoid them (or use commented blank lines) because they switch back to vertical mode, neutralizing the \leavevmode I put at the start of the user command definition. – AlexG Mar 21 '14 at 11:23
  • 1
    Also thanks for the example use of the texdef command! – AlexG Mar 21 '14 at 11:29
  • @AlexG Blank lines for readability are good in the LaTeX3 programming environment, not in any other situation. – egreg Mar 21 '14 at 11:30
  • Within my package I am well in an L3 environment. Something else, not the blank lines, must be the cause for switching back to vertical mode then. – AlexG Mar 21 '14 at 11:49
  • We can discuss of course the logic, but my understanding is that thee 'low level' box operations are meant for places where the programmer is in 'full control': for example, they are also not colour-safe. – Joseph Wright Mar 21 '14 at 13:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.