I'm not satisfied by the command \overline: for example, sometines, not
allways, "\overline T" makes the line touching those of the T. I have
been unable so far to figure out at what conditions it was the case.
To fix that, i've tried to increase the space under the line, for
example with something like
\newcommand{\ovl}[1]{\overline{ \strut^{\text{\tiny\strut}} #1} }
Well, has expected, it makes the line to be higher, but :
- it is ugly code
- the highness of the line is still unconstant
Any suggestion?
Thx.
No comment on the overline stuff (I haven't looked to check if indeed
it is ugly), but if you wanted something of constant height you could
make your own strut with a zero-width rule:
\newcommand\ovl[1]{\overline{\rule{0pt}{2ex}#1}}
or if you just wanted to *increase* the space above a character
(doesn't seem right to have a line the same height when it's above an
"x" compared to a "T"), you'd want to use the various LaTeX
height/length macros:
\newlength\ovlheight
\newcommand\ovl[1]{%
\settoheight\ovlheight{#1}%
\addtolength\ovlheight{2pt}%
\overline{\rule{0pt}{\ovlheight}#1}}
(All totally untested.)
It would undoubtably be a better idea to redefine \overline, but I'll
leave this as an exercise...
Hope this helps,
Will Robertson
Yes, of course, but from my experience with the *same* character and the
same font size the height of the line is not constant.
Thx for the 0pt rule trick. I'm going to try.
Luc Mercier wrote:
> > (doesn't seem right to have a line the same height when it's above an
> > "x" compared to a "T")
>
> Yes, of course, but from my experience with the *same* character and the
> same font size the height of the line is not constant.
A small example showing that would help analyze the problem. An
\overline in TeX _should_ always produce a line with a clearance equal
to 3 times the thickness of the rule. For the font cmr10, that would be
1.2pt of space. If the heights vary then either:
1. the contents vary in height, or
2. the rule thickness has changed (can be caused by changing the math
extension font which contains the information about rule thickness as
font dimension 8).
You say the contents are the same, so I can only suppose that 2 is to
blame.
3. there is actually a third possibility: the rule and the letter below
it, when digitized, can (depending on where a true boundary lands
within a pixel) add or lose one pixel. At screen resolutions the 1.2pt
of space could be 1 or 2 pixels only, and therefore can range from
being doubled to completely filled in.
Even at a print resolution of 300 dpi, the space is only 5 pixels and
so could vary from 3 to 7 pixels. At 1200dpi the possible variation (18
to 22 pixels) in the space is much less noticeable. Acrobat has
typically been rather bad at digitizing rules, but viewing at high
magnification should reveal what TeX actually intended.
4. Actually also a fourth: a redefinition of \overline (perhaps by some
package).
>
> Thx for the 0pt rule trick. I'm going to try.
A 0pt rule is exactly what \strut places. Its height only varies with
the fontsize, which you claim is the same. Chances are the results will
be similar, since you have only reasons 2 -- 4 above, and they would
not be changed by adding anything to the contents of \overline{}.
Dan
Just to add some comment on you code (the previous posters has given
good alternatives).
1. Do not use \strut inside math, rather use \mathstrut which is
defined as \vphantom{(}. The amsmath package redefines \mathstrut to be
more sophisticated and works better with the different math sizes.
2. Be carefull of measured heights such as in the posted example
\newlength\ovlheight
\newcommand\ovl[1]{%
\settoheight\ovlheight{#1}%
\addtolength\ovlheight{2pt}%
\overline{\rule{0pt}{\ovlheight}#1}}
because \settoheight measured the height inside a text box which
may result in a different height to the math height. At least change
the line to \settoheight\ovlheight{$#1$} or for a more sophisticated
command use the \mathpalette construction that will ensure that the
heigth corresponds with the current math size.
3. Look at the mattens packages for tensors and vectors such as
forces, moments of inertia, etc. as is often used in engineering. The
\overline and over arrows causes a lot of problems when you add accents
for time derivatives and sub and superscripts for reference axes and
indexes. The packages was designed to overcome (some of) these
problems. I have included a struted options but it does not work to
well under all conditions.
Danie Els (dnjels at sun dot ac dot za)