I have a macro that takes an argument and bolds it (in addition to some other things). But I would like it not to bold the numbers.

For example, what I have right now is something like


and \mybold{R^2} gives

enter image description here

but what I want is for \mybold{R^2} to give

enter image description here

where the "2" is not bolded.

How can I do that?

  • 5
    \mybold{R}^2? Mar 16, 2015 at 15:49
  • 1
    @karlkoeller: Too easy ;-)
    – user31729
    Mar 16, 2015 at 16:53
  • @karlkoeller: yea no. I'd want the code as written but have it displayed as pictured. Mar 17, 2015 at 0:38
  • 2
    It is doubtless possible - egreg has just done it. But why do you want your code to not reflect your output. such a mismatch is misleading and against LaTeX's philosophy
    – Au101
    Dec 5, 2015 at 22:32

2 Answers 2


Change (locally) the math code of the digits.




enter image description here


Run with xelatex or lualatex:


enter image description here

The R must be in \mathit. However, if you do not like it you canchange it to \mathup

  • LaTeX Font Warning: Command \mathversion invalid in math mode on input line 7. Indeed, I recalled about \mathversion being forbidden in math mode. Package bm must go through complicated patches to bolden individual symbols.
    – user4686
    Dec 6, 2015 at 14:41
  • Naturally, the code seems to go through, however does LuaLaTeX or XeLaTeX document one can use \mathversion this way with no after-effects ?
    – user4686
    Dec 6, 2015 at 14:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .