[texhax] Question about math fonts in LaTeX
Philipp Stephani
st_philipp at yahoo.de
Thu Jan 20 17:45:39 CET 2011
>
>Von: Vafa Khalighi <vafakhlgh at gmail.com>
>An: texhax at tug.org
>Gesendet: Donnerstag, den 20. Januar 2011, 14:41:15 Uhr
>Betreff: [texhax] Question about math fonts in LaTeX
>
>
>Can you change the font of \mathbf so that the font of only digits changes and
>everything else will be typeset in the default font. For example, say your
>default font for \mathbf is cmr but you only want to change the font of digits
>inside \mathbf to cmtt and nothing else so that $\mathbf{xyz0123}$ give you xyz
>
>in cmr but 0123 in cmtt. Is this doable? (of course without creating a new font
>
>or modifying an existing font)
Here is a hackish solution:
\documentclass{minimal}
\usepackage{xparse}
\DeclareSymbolFont{monospace}{OT1}{cmtt}{m}{n}
\ExplSyntaxOn
\cs_new_eq:NN \orig_mathbf:n \mathbf
\RenewDocumentCommand \mathbf { m } {
\orig_mathbf:n {
\prg_stepwise_inline:nnnn { `0 } { \c_one } { `9 } {
\mathcode ##1 = \numexpr "100 * \symmonospace + ##1 \relax
}
#1
}
}
\ExplSyntaxOff
\begin{document}
$abc 012 \mathbf{abc 012} abc 012$
\end{document}
More information about the texhax
mailing list