Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

So I have a rule pointing at the middle of the following text. I have achieved this with the following code:

\newlength{\Fraiseheight}
\setlength{\Fraiseheight}{1ex}
\addtolength{\Fraiseheight}{-\Flinewidth}

\newlength{\Fbaselength}
\setlength{\Fbaselength}{20pt}

\newlength{\Flinewidth}
\setlength{\Flinewidth}{0.5pt}

\rule[\Fraiseheight]{\Fbaselength}{\Flinewidth}

The height 1ex is the height of an x in current font. This raises my rule higher than the centre of an open bracket that follows. This looks awkward especially for curly brackets. My question is: What height above the baseline do I need to achieve the following effect: "-(x" or "-{x" where the - is supposed to represent my rule and the x is present to show the discrepancy between the height 1ex and that of the - character.

share|improve this question
    
Just in case you didn't know, you can measure the height of the bracket with \settoheight\height, where \height is a length variable. You can then write 0.5\height to get half the height. –  Marc van Dongen Aug 8 '12 at 7:31
    
I should have known that. –  Psachnodaimonia Aug 8 '12 at 7:58
1  
@MarcvanDongen -- just the height of the bracket doesn't give the needed value. brackets also have depth, so the actual vertical span of the bracket is height plus depth. but heiko has the more direct answer: the middle of all "fences" in tex math is the math axis, which also happens to be the vertical center of the equals sign and plus. however, in fonts that were designed to be used mainly (or only) for text, the brackets, parntheses, etc., may not have sufficient depth to be visually vertically centered for tex math. –  barbara beeton Aug 8 '12 at 12:23
    
@barbarabeeton Thanks for that. I should have pointed that out. Heiko's solution is much better, which is why I gave him credit for it. –  Marc van Dongen Aug 8 '12 at 12:33
add comment

1 Answer 1

up vote 12 down vote accepted

The middle of the brackets is the math axis. Command \vcenter centers its contents at the math axis.

$\vcenter{\hrule width \Fbaselength height \Flinewidth}$

This is syntax of plain TeX that also works in LaTeX. But it can also be expressed in "pure LaTeX":

\parbox[c]{\Fbaselength}{\rule{\FBaselength}{\Flinewidth}}
share|improve this answer
    
I appreciate getting both the plain TeX and pure LaTeX in the answer. –  Psachnodaimonia Aug 8 '12 at 7:59
add comment

Your Answer

 
discard

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.