0

I feel like this question has probably already been asked, but I cannot find it...

I am using the default article class. I want to create a macro \ab which does the following: it simply prints "ab" in upright, Roman font in math mode. However, I want to be able to use this in settings where the current font is Sans Serif (\sffamily) and/or where the font is bold (using \bfseries \boldmath).

Just writing \newcommand{\ab}{\textup{ab}} does almost all of this: the only issue is that it obviously doesn't do anything with the font; so it's sometimes Sans Serif. I don't know how to change the font other than \normalfont or \textnormal, but these both destroy any bold information. So if I do \newcommand{\ab}{\textnormal{ab}} then I never get bold.

Any help would be most appreciated!

4
  • Please add a minimal example of code showing your font setup.
    – egreg
    May 28, 2020 at 21:41
  • \mathrm{ab} ? May 28, 2020 at 21:44
  • @DavidCarlisle Yes, that works, thank you :) -- I thought that was one of the first things I tried, but obviously not! (as evidenced by my forgetting to include it in the question text above). If you want to make an answer, I'll accept; otherwise I'll make one citing your comment :) -- whichever you prefer. I remember being surprised that \textrm didn't work (I must have been doing something wrong). Sorry to have posted such a trivial question!
    – Sam OT
    May 28, 2020 at 22:04
  • Ah, I see, it doesn't remove italics (which is, of course, not what I was asking). I think I accidentally tested it with italics, rather than bold. Thanks again, and sorry again!
    – Sam OT
    May 28, 2020 at 22:08

1 Answer 1

2

\mathrm{ab} will give the math Roman font (and math Roman bold font in \boldmath) note that isn't by default Times Roman, but you can chose a Times Roman clone style for your document with for example \usepackage{newtxtext,newtxmath}

1
  • Perfect, thanks. I actually had forgotten that the default font wasn't times, but a different Roman font!
    – Sam OT
    May 28, 2020 at 22:39

You must log in to answer this question.

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