# What is the cleanest way to adjust the dimensions (height, depth, width to the left and right) of a symbol?

Every once in a while the nominal (i.e. declared) dimensions of a symbol are not identical to the actual ones. This can be intentional or not, but sometimes it is inconvenient.

The dimensions of the double dagger (\ddag) from the cm fonts seem to be slightly inaccurate. Using \kern one can adjust the horizontal dimensions. The vertical dimensions can be changed with Steven B. Segletes' useful verbatimbox package:

(Disclaimer: Note that the horizontal extensions are intentional and less likely to cause any problems. Barbara Beeton pointed out that "the Metafont definition, which clearly includes the generous sidebearings, appears on pp. 536-537 of the book Computer Modern Typefaces, volume E of Knuth's Computers & Typesetting series". Nonetheless, my adjustment shall serve illustrative purposes. A better case for adjustments of the side spacing might be the slash / from txfonts; see below.)

(Disclaimer: txfonts is superseded by newtx, i.e. newtxtext and newtxmath. When I compile with it instead, the same glyphic problems appear. So I will let my question stand the way it is now. To what extent the metrics from the newtx packages are still in need of improvement I don't know.)

Looking at some symbols from txfonts, the symbol \ncong seems to have correct dimensions (I assume here that the horizontal spacing on both sides is fine and beneficial):

But some other symbols from there seem to be slightly miscalibrated:

Here, \dag, \ddag, \Vert, \#, and \equiv can benefit from vertical adjustment at the top (the declared height of \equiv is a tiny bit too small, though this is hard to see from the picture here). This is somewhat true for symbol / too, but horizontal adjustment is more needed for it to create equal spacing on both sides. (The slash from the cm fonts doesn't have such asymmetric horizontal spacing.)

Here is the code used for generating the above examples:

\documentclass{article}
\usepackage{txfonts} % comment out for "cm" font symbols
\usepackage{verbatimbox}

\begin{document}

{
\Huge
\fboxsep=0pt\fboxrule=.02pt
% \fbox-trick taken from Steven B. Segletes' answers here:
% http://tex.stackexchange.com/a/121946/14996
% http://tex.stackexchange.com/a/123108/14996

% cm fonts ("\usepackage{txfonts}" commented out):
\fbox{\ddag}
\fbox{\ddagMod}

% with "\usepackage{txfonts}":
\fbox{$$\ncong$$}
\par
\fbox{\dag}
\fbox{\ddag}
\fbox{$$\Vert$$}
\fbox{\#}
\fbox{$$\equiv$$}
\par
\fbox{/}
}

\end{document}


How can one adjust a symbol's vertical and horizontal dimensions in the cleanest way? Let's assume we have a symbol \symb and would like to adjust it in a way that is likely to work at different font sizes and in the different math mode styles. My \ddagMod does what I want for \ddag in text mode, but a robust, general approach is needed.

• \ddag is from the original cm fonts, designed by knuth; its origin is not amsmath. the metafont definition, which clearly includess the generous sidebearings, appears on pp.536-537 of the book "computer modern typefaces", volume e of knuth's "computers & typesetting" series. – barbara beeton Jan 29 '14 at 13:42
• txfonts are notorious for having not so good metrics, in particular sidebearings. – egreg Jan 29 '14 at 14:03
• @egreg You're entirely right. I noticed that half-way through composing my question and then forgot to add a disclaimer. Let me do that right now ... – Lover of Structure Jan 30 '14 at 2:12
• @barbarabeeton See my edit(s). If any of you know of better examples, do let me know ... though I think the question the way it stands now will serve its purpose. – Lover of Structure Jan 30 '14 at 2:39
• @LoverofStructure -- thanks for the disclaimer re \ddag. for something that might surprise you, take a look at the dimensions assigned to the minus sign, then compare with the plus. the explanation is in the definition of beginarithchar, volume e, p.483: "ensure constant dimensions for +, -, etc.". you might also take a look at the relationships between \Uparrow, \Downarrow, \Vert, \parallel and the glyph at octal 015 of cmext (the two-line extender). – barbara beeton Jan 30 '14 at 13:30

The basic answer is that (in classic TeX, at least, not sure about luatex) is that you can't.

For any symbol \foo you can use

\setbox\mybox{\kern..\raisebox{..}{\foo}\kern..}
\ht\mybox=..
\wd\mybox==..
\dp\mybox=..


To make a box of any required size with the glyph at any position within that bounding box, so \usebox\mybox will do more or less the right thing, but the main difference is that it is a box not a character and boxes only have three lengths (height depth width) whereas characters have four (+ italic correction) and take part in kerning and ligatures.

So for example $P_1$ does not look like $\hbox{$P$}_1$ as the font metric information is used to pull in the subscript. You can't easily get that if you rebox P.

So in classic TeX the clean way is to run tftopl to make a text version of the font metric file, edit the metrics, then run pltotf to make some new tfms then use those.

• Are there any special precautions to take (I am thinking about something with \text or \mathchoice) when modifying a math-mode symbol that is supposed to function in all 4 styles? – Lover of Structure Jan 30 '14 at 2:44
• @LoverofStructure If you are prepared to accept the symbol is a box you need \mathchoice (probably via its \mathpallet wrapper) so it works in all four styles and an outer \mathop or \mathrel or whatever to re-assert the required math class of the symbol. – David Carlisle Jan 30 '14 at 9:37
• @LoverofStructure Depending on what needs to be done in the 4 math styles, the use of scalerel's syntax \ThisStyle{...\SavedStyle...} can be a more compact way of expressing \mathchoice. That would not be the case, however, if unique kernings must be applied to each respective math style. – Steven B. Segletes Jan 30 '14 at 11:22