\textcolor{red}{\vrule width 1pt height 1pt}\\% I get a vrule with a height of 1pt as I expect.
\textcolor{red}{\vrule width 1pt height 1pt}% What I want is a vrule with a height of 1pt, so that it aligns with the bottom line of `\fbox` How can I get such a line by \vrule?

enter image description here

  • 1
    if you want consistent behaviour you should use latex commands, the latex command \rule would not have the implicit behaviour that you are seeing. If you use TeX primitives then you have to expect to get what you get. Mar 5, 2022 at 10:31
  • 1
    put xxxx after your last fbox so that you see the baseline, you will see marked red rule does have height 1pt above the baseline Mar 5, 2022 at 14:18

1 Answer 1


The working of \vrule is context dependent. If you don't specify a height, then the rule will be as high as the enclosing box.1 If width is not specified, it defaults to 0.4pt. The same will happen for depth, which seems the factor you're not aware of.

Examples (in plain TeX):

\hbox{\vrule a}

\hbox{\vrule b}

\hbox{\vrule Xy}

In the last example, you see that also the depth is adjusted to match the enclosing box depth.

If your box happens to have zero height, that will be used for the \vrule, so it will be invisible (but it will contribute its width).

Note that the box might be “implicit”: if you use \vrule in the middle of a paragraph, its height and depth will default to those of the \hbox built during paragraph making in which the \vrule will eventually be typeset in.

enter image description here

If you want specific height or depth, you must tell TeX with the suitable height or depth parameter.

What's happening in your example? Here is a picture:

enter image description here

The rule is indeed 1pt high, but it is as deep as the enclosing box, which happens to contain a \parbox which is centered around the baseline (take the formula axis height). A simpler picture:

\hbox{\vrule height 1pt Xy}

enter image description here

You can see that the height (the extent above the base line) is 1pt, but the depth is that of the enclosing box.


1 Since \vrule is a horizontal command, the enclosing box will necessarily be an \hbox (either explicit like in the shown example, or constructed during paragraph building).

Your aim








enter image description here

  • I modified my code, specific height is given(1pt) for the sencond \vrule, but does not get a vrule with a height of 1pt either. Why and how to achieve it? And why is \textcolorbox not an explicit for \vrule?
    – lyl
    Mar 5, 2022 at 10:26
  • @lyl It's the depth that kicks in. I added the explanation. Since I can't understand what you're after, in particular as to where you expect the rule to appear with respect to the context, it's difficult to say more.
    – egreg
    Mar 5, 2022 at 10:29
  • @lyl it's a bit antisocial to change the question after it has been answered, but you do get a rule of height 1pt, but as you did not specify depth 0pt it picks up the depth of the surrounding box as egreg explains Mar 5, 2022 at 10:29
  • I want the vrule is at the bottom of \fbox with a height of 1pt so that it is align with the bottom line of \fbox
    – lyl
    Mar 5, 2022 at 10:35
  • @lyl And what about the position of the \fbox with respect to the baseline?
    – egreg
    Mar 5, 2022 at 11:09

You must log in to answer this question.

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