Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Goal: I want a macro that changes the math font of only subscript and superscript. In TeX terms, I think this means I want to change only S, S' styles, which are typeset using scriptfont.

Graphically, I'd want

\bfscript{v_i}

to be displayed as $v_{\mathbf{i}}$.

Tries: I've been trying to do it the TeX way; that is, something like

\def\bfscript#1{\hbox{$\scriptfont0=\tenbf #1$}}

but this fails miserably, as scriptfont and the likes seem completely ignored by LaTeX. It seems that LaTeX only allows to make distinctions on the fontsize, with \DeclareMathSizes.

Nota: I was first interested in this as a real-life case, but I'm not even sure I'll need it any longer; I'm just really wondering what the answer is.

share|improve this question
1  
\tenbf is unknown in LaTeX, which uses quite a complicated way to set up math families. I'd say that $v_\mathbf{i}$ is really the best choice. –  egreg Sep 17 '12 at 22:40
    
There are many other places where script style is used (fractions, super scripts, …). –  Heiko Oberdiek Sep 17 '12 at 23:02

1 Answer 1

LaTeX loads math fonts and assigns them on demand so you need to have an initial math setup to ensure that there is a font to be used as scriptfont. Also you want fam 1 not 0 in the usual setup.

I don't recommend that you do this:

\documentclass{article}

\begin{document}
\showoutput

\def\bfscript#1{%
\setbox0\hbox{$\scriptstyle\mathbf{\xdef\tmp{\the\scriptfont\fam}}$}%
\hbox{$\scriptfont1=\tmp #1$}}

$\bfscript{v_i}$

$v_{\mathbf{i}}$

\end{document}
share|improve this answer
    
Ah! I was close then; just had the wrong font number. Thanks very much David. Of COURSE I won't use that. Probably. :-) –  Michaël Sep 18 '12 at 4:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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