I am using this answer on TeX.SX to get multi-letter variables in math mode, so that $abc$
typesets as $\mathit{abc}$
, instead of being typeset as if it was the product of a
, b
and c
.
Unfortunately, that code forces the \mathit
even if another math font command was used, i.e. $\mathtt{abc}$
typesets as $\mathtt{\mathit{abc}}$
. My goal is therefore to detect what is the current font, and apply \mathit
to multi-letter variables only if the default math font is used.
I tried using \f@family
as shown in this answer, but it does not seem to work in math mode:
\documentclass{article}
\begin{document}
\makeatletter
\newcommand{\showfont}{
\message{encoding: \f@encoding,
family: \f@family,
series: \f@series,
shape: \f@shape,
size: \f@size
}
}
\makeatother
$foo \showfont bar$
$\mathtt{foo \showfont bar}$
\end{document}
The file above shows in the log:
encoding: OT1, family: cmr, series: m, shape: n, size: 10
encoding: OT1, family: cmr, series: m, shape: n, size: 10
It seems to me that \f@family
and the other \f@xxx
commands show the text mode font, instead of showing the math mode font.
Is there an equivalent to \f@family
which gives the information concerning the math mode font?
\mathit
and\mathtt
don't have cumulative effect and the font parameters such as\f@family
have no role in math mode.\mathit
when the current font is not the default one. As you said,\f@family
is not supposed to work in math mode, but is there a similar command which would give me information about the current math mode font?\the\fam
as I set to 4 actually in my answer to make things default to mathit, however the number allocation is dynamic it depends on the order that fonts are used in the document, as there are only 16 slots so if for example you declare\mathbb
but never use it that font is never allocated a familiy number at all, they are just set up the first time they are used, which is why in my answer I use\mathit
first to get the number and then set that for the rest of the expression.\the\fam
. I should be able to build what I want with this and the other TeX.SX answer. Thanks!