OK, you really want to know how to create your own tfm
file with new extensible symbols? Then here are some explanations. I only give some toy example, working with the standard Computer Modern fonts. Here's the output I can produce; I don't claim that it's nice or useful:
Here's the LaTeX code:
\documentclass[12pt]{article}
\usepackage{amsmath}
\DeclareFontShape{OMX}{cmex}{m}{n}{<->sfixed*modcmex10}{}
\pdfmapline{+modcmex10 CMEX10 <cmex10.pfb}
\begin{document}
\[
\begin{pmatrix}
1&0&0&0 \\ 0&1&0&0 \\ 0&0&1&0 \\ 0&0&0&1
\end{pmatrix} +
\begin{Vmatrix}
1&0&0&0 \\ 0&1&0&0 \\ 0&0&1&0 \\ 0&0&0&1
\end{Vmatrix}
\]
\end{document}
In the 3rd and 4th line I tell LaTeX to use the tfm
file modcmex10
instead of cmex10
, and to use the usual glyphs from cmex10.pfb
with the modified tfm
file. The amsmath
environments pmatrix
and Vmatrix
internally use \left(...\right)
and \left\|...\right\|
, so apparently I redefined those extensible delimiters.
How does one do this? The short answer: on a Unix type system you can just run the following script that produces a virtual font modcmex10
consisting of two files modcmex10.tfm
and modcmex10.vf
that are needed to compile the above LaTeX code. Beware! This virtual font provides the three extensible delimiters shown above, but it also garbles many other delimiters.
# Create a patch file:
echo '22a23,29
> (MAPFONT D 0
> (FONTNAME cmex10)
> )
> (MAPFONT D 1
> (FONTNAME cmsy10)
> (FONTAT R 2)
> )
106c113
< (REP O 15)
---
> (REP O 75)
314a322
> (MID O 74)
324a333
> (MID O 75)
423a433,437
> (MAP
> (SELECTFONT D 0)
> (MOVELEFT R 0.1)
> (SETCHAR O 74)
> )
429,430c443,450
< (CHARWD R 0.888891)
< (CHARDP R 1.800018)
---
> (CHARWD R 0.888892)
> (CHARHT R 1.41)
> (CHARDP R 0.41)
> (MAP
> (SELECTFONT D 1)
> (MOVERIGHT R 0.08)
> (SETCHAR O 172)
> )' > cmex.diff
# Create modified cmex font:
tftopl $(kpsewhich cmex10.tfm) > modcmex10.vpl
patch modcmex10.vpl cmex.diff
vptovf modcmex10.vpl
rm cmex.diff
# Remove the following line if you want to study the virtual font:
rm modcmex10.vpl
How does the virtual font work?
As a basis I used cmex10.pl
, the property list of the Computer Modern font containing the extensible symbols. First of all, I added the lines
(MAPFONT D 0
(FONTNAME cmex10)
)
(MAPFONT D 1
(FONTNAME cmsy10)
(FONTAT R 2)
)
This means that both the fonts cmex10
and cmsy10
will be used, and that the latter is scaled by a factor of 2. I take the \ddagger
from this double sized cmsy10
and use it as a replacement for the constituents of the extensible \|
delimiter. In my vpl
file (virtual property list) this implemented in the following lines:
(CHARACTER O 15
(CHARWD R 0.555557)
(CHARDP R 0.600006)
(VARCHAR
(REP O 75)
)
)
This tells us that the character in slot 15 is a variable character that will be constructed from a REPeatable piece that should be taken from slot 75. (The original font uses slot 15 itself. Note that these are octal numbers, so actually it's the 13th and 61st slot!) And what's in slot 75? The answer is found in these lines:
(CHARACTER O 75
(CHARWD R 0.888892)
(CHARHT R 1.41)
(CHARDP R 0.41)
(MAP
(SELECTFONT D 1)
(MOVERIGHT R 0.08)
(SETCHAR O 172)
)
(VARCHAR
(REP O 167)
)
)
It's the character from slot 172 of the font D 1
, which above was defined as cmsy10
, so it's the double dagger. Moreover, the character is moved to the right a bit. I had to fiddle a bit to find the (relative) height and depth 1.41
and 0.41
.
How does TeX choose the appropriate delimiter size?
Let's have a look at the following lines that are from the original cmex10.pl
:
(CHARACTER O 0
(CHARWD R 0.458336)
(CHARHT R 0.039999)
(CHARDP R 1.160013)
(NEXTLARGER O 20)
)
This says (among other things) that the character in slot 0 (an opening parenthesis) has a larger version in slot 20. The chain of larger and larger versions continues via slots 20, 22 and 40 to the largest version of the character in slot 60. And this is what you find in slot 60 of my virtual font:
(CHARACTER O 60
(CHARWD R 0.875003)
(CHARHT R 0.039999)
(CHARDP R 1.760019)
(VARCHAR
(TOP O 60)
(MID O 74)
(BOT O 100)
(REP O 102)
)
)
It's again a variable character, and it consists of four types of pieces: a TOP, a MIDdle and BOTtom part, and inbetween a REPeatable part. I added the middle piece from slot 74, so that you get this crossbreed between a parenthesis and a brace. When TeX sees a \left...\right
construct, it goes through this line of larger and larger versions of a delimiter until it finds one that is large enough. In the best case, the last version is extensible!
\vert
,[
,]
,(
,)
, ... are called extensible and are actually constructed out of several pieces, rather than being stretched vertically. Of course, it is always possible to stretch symbols to a given length and make them look like a delimiter.