6

I want to know if it's possible to change how LaTeX typesets superscripts and subscripts (separately, that is, not both at once) for an element where the default kerning doesn't cut it for me. Some kind of set-and-forget in the preamble.

\documentclass{minimal}
\usepackage{amssymb}

\newcommand\F{\mathbb{F}}
\newcommand\f[2]{\F_{\mkern-1mu{#1}}^{\mkern1mu{#2}}}

\begin{document}
I want to type $\F_q^d$ and achieve $\f{q}{d}$
\end{document}

default and preferred kerning of a mathbb letter F with super- and subscripts

I know I can simply create a short macro like \f in the example and give it empty arguments for missing portions, but I find that solution dissatisfying: \f{}{} unnecessarily cluttered when the letter is bare, and things like \f{q}{} and \f{q}{d} are confusing and not immediately clear which script is filled in by which argument.

In case it is relevant, I am using pdflatex.

9

The positioning of subscripts and superscripts are done by character width (CHARWD) and italic correction (CHARIC) if the nucleus is one character. Suppose the typesetting point before nucleus is typeset. Then subscript is placed to CHARWD and superscript to CHARWD+CHARIC positions.

This is not very well concept in TeX because this metric information is used for another purposes: CHARWD when next character is typeset in normal text and CHARIC when \/ primitive is used.

You can change the mentioned metric information if you know that the symbol will not used in normal text without sub/superscript. But this is very rare situation, so the following hint is only as an academic experiment.

Do tftopl msbm10 > msbm10.pl in your working directory. Then edit the file msbm10.pl in the section (CHARACTER O 106 ... this is blackboard F mentioned in your example. Decrease the CHARWD by 1mu, ie. by .05555 and add the CHARIC as 2mu, i.e. .111111. The result looks like:

 (CHARACTER O 106
   (CHARWD R 0.555557)
   (CHARHT R 0.688889)
   (CHARIC R 0.111111)
   )

Then run pltotf msbm10.pl. This process creates metric msbm10.tfm in your working directory where it has a precedence, if you are working here. You can try your example in this directory. You will see that the positioning of F sub/super-scripts are as you desired without correction at macro level.

But I don't recommend this. The reason was mentioned above.

You can define the \F macro more presicely. Instead

\newcommand\F{\mathbb{F}}

you can do (for example) following:

\def\F{\mathbb{F}\sbcorr{-2mu}{1mu}}
\def\sbcorr#1#2{\def\tmpa{#1}\def\tmpb{#2}\futurelet\next\sbcorrA}
\def\sbcorrA{\ifx\next_\expandafter\sbcorrB\fi}
\def\sbcorrB_#1{_{\mkern\tmpa#1}\futurelet\next\sbcorrC}
\def\sbcorrC{\ifx\next^\expandafter\sbcorrD\fi}
\def\sbcorrD^#1{^{\mkern\tmpb#1}}

Test: $\F(x), \F_a^b, \F$.
  • Concerning "This is not very well concept in TeX": As I understand it, this is not true. In a math font, CHARIC is only used for positioning of subscripts, nothing else. The italic correction is always included if you use a character, as in A=W or WA. See also this answer of mine and this question. – Hendrik Vogt May 1 '15 at 4:47
  • @HendrikVogt But you need typically two dimen parameters for positioning subscript and superscript. For example the positioning of subscript needs negative value but superscript positive or zero. The third dimension is the character width which is used when characters are typeset one after second. The missing of a dimen value for subscript "is not very well concept in TeX", I mean. Your example mentioned math font with zero word space \fontdimen2 but msbm10 has non-zero space. So the rule about italic correction after each character from msbm10 isn't true. – wipet May 1 '15 at 5:10
  • Re #1: Right, it might be better to have two parameters. There's none for superscripts, which becomes apparent when one types A_2^2. What I was addressing with "not true" was that you wrote "used for another purpose". I don't know any instance where one would use \/ for a math font. Re #2: Ah, that's interesting! Right, I meant fonts with zero \fontdimen2. I didn't know that for msbm10 it's non-zero, and I find that very strange. I haphazard a guess that all characters from msbm10 have zero CHARIC - then it makes some sense. If I were to manipulate the font, I'd set \fontdimen2=0. – Hendrik Vogt May 1 '15 at 5:26
  • Hmm, it appears my guess was not quite correct: CHARACTER O 173 is the only one with non-zero italic correction - no idea what character that is. And I have really no idea what could possibly have led to the decision to set \fontdimen2 to 0.3. – Hendrik Vogt May 1 '15 at 5:40
  • If font is intended only to math mode, then \fontdimen2 would be zero and we have: real width=charwd+corrital, subsript position: charwd, superscript position: charwd+corrital and this seems to be sufficient. But we have fonts designed for text and math typesetting together, then \fontdimen2 is nonzero and one dimen parameter per each character is missing. For example `${\rm F}_a^b$ is positioned by text italic correction and this "is not very well concept in TeX", I mean. – wipet May 1 '15 at 7:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.