[texhax] Question about math fonts in LaTeX

jfbu jfbu at free.fr
Thu Jan 20 16:49:58 CET 2011


The following has its problems but it partially solves your problem:

\documentclass{minimal}
\DeclareSymbolFont{digitsfont}{OT1}{cmr}{m}{n}
\SetSymbolFont{digitsfont}{bold}{OT1}{cmtt}{m}{n}
\DeclareMathVersion{ttfordigits}
\SetSymbolFont{digitsfont}{ttfordigits}{OT1}{cmtt}{m}{n}
\DeclareMathSymbol{0}{\mathord}{digitsfont}{`0}
\DeclareMathSymbol{1}{\mathord}{digitsfont}{`1}
\DeclareMathSymbol{2}{\mathord}{digitsfont}{`2}
\DeclareMathSymbol{3}{\mathord}{digitsfont}{`3}
\DeclareMathSymbol{4}{\mathord}{digitsfont}{`4}
\DeclareMathSymbol{5}{\mathord}{digitsfont}{`5}
\DeclareMathSymbol{6}{\mathord}{digitsfont}{`6}
\DeclareMathSymbol{7}{\mathord}{digitsfont}{`7}
\DeclareMathSymbol{8}{\mathord}{digitsfont}{`8}
\DeclareMathSymbol{9}{\mathord}{digitsfont}{`9}
\let\oldmathbf\mathbf
\renewcommand\mathbf[1]{\mbox{{\mathversion{ttfordigits}$\oldmathbf{#1}$ 
}}}

\begin{document}
\[\mathbf{letters\ should\ be\ bold\ and\ digits\ in\ typewriter\  
face:1234567890}\]
We know try without \texttt{$\backslash$mathbf} but with  a  
\texttt{$\backslash$boldmath} declaration:\boldmath
\[these\ digits\ are\ again\ in\ tt\ font:1234567890\]
But perhaps one does want the digits to be also bold in that case, then  
the
\begin{verbatim}
\SetSymbolFont{digitsfont}{bold}{OT1}{cmtt}{m}{n}
\end{verbatim}
from the preamble should be
\begin{verbatim}
\SetSymbolFont{digitsfont}{bold}{OT1}{cmr}{bx}{n}
\end{verbatim}
However \$\texttt{$\backslash$mathbf}\{0123456789\}\$ would then give  
digits
in cmtt, and non bold, also after \texttt{$\backslash$boldmath}, which  
might
not be what is wanted.
\end{document}

Regards,
Jean-Francois Burnol

Le 20 janv. 11, à 14:41, Vafa Khalighi a écrit :

> 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)
>
> Thanks_______________________________________________
> TeX FAQ: http://www.tex.ac.uk/faq
> Mailing list archives: http://tug.org/pipermail/texhax/
> More links: http://tug.org/begin.html
>
> Automated subscription management:  
> http://tug.org/mailman/listinfo/texhax
> Human mailing list managers: postmaster at tug.org



More information about the texhax mailing list