[texhax] Question about math fonts in LaTeX
jfbu
jfbu at free.fr
Thu Jan 20 19:01:29 CET 2011
Hi,
motivated by Philipp code, I can propose a further method
(of course OT1 can be T1, etc..)
\documentclass{minimal}
\DeclareSymbolFont{fontfordigits}{OT1}{cmtt}{m}{n}
\newcommand\hackit{%
\edef\tmp{0\the\symfontfordigits}%
\mathcode`\0=\expandafter"\tmp30\relax%
\mathcode`\1=\expandafter"\tmp31\relax%
\mathcode`\2=\expandafter"\tmp32\relax%
\mathcode`\3=\expandafter"\tmp33\relax%
\mathcode`\4=\expandafter"\tmp34\relax%
\mathcode`\5=\expandafter"\tmp35\relax%
\mathcode`\6=\expandafter"\tmp36\relax%
\mathcode`\7=\expandafter"\tmp37\relax%
\mathcode`\8=\expandafter"\tmp38\relax%
\mathcode`\9=\expandafter"\tmp39\relax}
\let\oldmathbf\mathbf
\renewcommand\mathbf[1]{{\oldmathbf{\hackit\relax#1}}}
\begin{document}
\[\mathbf{0s12{s3xyz098}76\alpha01234xyz}\quad
0s12{s3xyz098}76\alpha01234xyz\]
\end{document}
Regards,
Jean-Francois Burnol
Le 20 janv. 11, à 18:27, Vafa Khalighi a écrit :
>
>>
>> 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}
>>
>>
>
> I am not much familar with xparse. Can you tell me why this does not
> work:
>
> \documentclass{minimal}
> \usepackage{xparse}
> \DeclareSymbolFont{monospace}{OT1}{cmtt}{m}{n}
> \newcommand{\test}[1]{%
> \textbf{#1}
> \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}
> \test{test}
> $abc 012 \mathbf{abc 012} abc 012$
> \end{document}
>
> _______________________________________________
> 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