4

When typing 'variable0' in a math mode, only the letters are italicised. How can I force the 0 to be italicised as well?

jak123
  • 4,252
  • 5
  • 26
  • 49
  • 1
    words shouldn't be treated as "ordinary" math. the whole thing should be treated as a unit; if all italic, then $ \mathit{variable0} $ – barbara beeton Jun 10 '15 at 20:13

2 Answers2

6

Usually numbers are not italicized, but it is possible, for example:

\documentclass{article}
\begin{document}
\[\mathit{01234567890}\]
\end{document}

Result

Heiko Oberdiek
  • 271,626
2

My suggestion would be to define a macro that handles the formatting of your "variable names", so you can have some consistent output in your document, regardless of where you use it:

enter image description here

\documentclass{article}
\usepackage[T1]{fontenc}
% http://tex.stackexchange.com/a/139980/5764
\newcommand{\var}[1]{\texttt{\detokenize{#1}}}
\begin{document}
\[
  \var{variable}_0 \quad
  \var{AbC}_{13} \quad
  \var{some_thing}_i
\]
\end{document}

I've used \texttt, but you can use whatever text formatting you want to highlight a text-related variable.

Werner
  • 603,163
  • This does not seem to answer the question. – Randy Cragun Oct 12 '19 at 18:26
  • @RandyCragun: Correct. I was more trying to suggest that one should define macros for consistency that you can change as needed. For example, if you're working with variables within you math environment(s), define a macro that formats these variables (say, \var). Then you can change it to use \mathit or \texttt, depending on what you want it to be formatted as. – Werner Oct 12 '19 at 20:44