I want to use different variable styles in my dissertation. I'm currently using $x$ for a single random variable, $\mathbf{x}$ for a set of random variables and $\mathcal{X}$ for a state space. I also need to use 2D/3D variables in a different chapter. How could I define them? I already know:


but $\mathbf{x}$ and $\mathrm{x}$ are not very different.

  • bold roman is usually quite visually distinct from normal weight? but you can have 16 math fonts in normal tex or 256 in luatex \mathfrak, fraktur \bm{x} bold math italic x \mathscr{X} for script X (several packages eg rsfs) Then of course there is Greek or cyrillic alphabet and sans serif \mathsf or monospace \mathtt Mar 4, 2016 at 14:16
  • 1
    I understand this is a question of personal taste, but I have a bad experience with some (otherwise very good) electronic application notes (you know what I mean if you ever saw them) where serif and sans font is used to name normalized and no-normalized variables (s, no less), and it's practically unreadable. You can else use arrow, bars, dots, whatever above and below instead (easier to read aloud, too). Just my opinion, obviously.
    – Rmano
    Mar 4, 2016 at 14:41
  • A tip: If you indent lines by 4 spaces or enclose words in backticks `, they'll be marked as code, as can be seen in my edit. You can also highlight the code and click the "code" button (with "{}" on it).
    – Tobi
    Mar 4, 2016 at 15:27

1 Answer 1


Here’s a list of some fonts:


  • second \mathcal requires eucal package
  • \mathbb requires amsfonts package
  • \mathscrrequires mathrsfs package
  • not all of them support lowercase and/or greek letters
  • \mathtt is misisng in the image

But I strongly recommend not to use them directly but instead define a new markup macro like


and then use it like


(shorter names are certainly possible, like \stsp{X})

Doing this would be in the sense of TeX’s separation of content/structure and design/layout, i.e. logical markup instead of fixed formatting. Furthermore in this case it is easy to change the appearance later constant win the whole document, for example if your editor/publisher wants another style.

Can I use \mathsf{A} in bold??

If you got only latin letters (or a text font supporting greek) you could use the text font for this and define


(I added also \itshape because usually variable are set in italics.)

Another way is to define a new math alphabet: Bold , italic (and sans-serif) math symbols

How can I also incorporate a subscript in the \newcommand that you defined?

First, a note: It should be $\myvar{X}_{test}$ (the subscript outside of the variable argument). Furthermore If the subscript is a text like “max”, “eff.”, “min” etc. you should use \text from amsmath package! Only if the subscript is a variable itself (n, i, …) or a number you should write it like x_i.

If the subscript is always the same (text) you could just add it to the above definition:


(The \mkern2mu part insert a little space to shift the subscript a little to the right, which looks better.)

If you always have a subscript but a different one each time you can add a second mandatory argument:


and use it like $\myvar{X}{test}$.

If the subscript is optional you could use an optional argument which could be defined with \newcommand too but the test for an empty argument is easier with \NewDocumentCommand form the xparse package:

\NewDocumentCommand{\myvar}{ o m }{

and use it like $\myvar{X}$or $\myvar[test]{X}$. It is also possible to change the order of the arguments by replacing o m with m o, #1 with #2 and vice versa. Then the second argument would be optional but it could be problematic if the major without optional argument should be followed by a bracket.

  • Can I use \mathsf{A} in bold?? and if yes, does it work also for lower case letters? I need a bold and non-bold version of lower and upper case letters.
    – Kostas
    Mar 4, 2016 at 14:21
  • Why do you recommend not using them directly?
    – NVaughan
    Mar 4, 2016 at 14:59
  • 2
    re using the font command directly, if you decide later to change your notation, you will have to look in many places. if you use a "meaningful name" instead, you only have to change it in one place. Mar 4, 2016 at 15:12
  • @NVaughan: Jep … exactly what Barbara said :-)
    – Tobi
    Mar 4, 2016 at 15:14
  • 1
    @NVaughan -- if you are using multiple shapes of the same letter, and enter them all using the font specifier, a copyeditor won't be able to tell in an ambiguous situation if it's actually the correct form. (and you might have to look carefully more than once yourself to be sure.) so although it's a convenience, it's also an extra check that doesn't depend on the author alone. Mar 4, 2016 at 19:06

You must log in to answer this question.

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