# Define command for variable and use of capital Greek letters

as I read some time ago, it was recommended to define variable inside text within an environment, rather than using the mathmode $variable$ So I decided to introduce a new command in the preamble:

\newcommand{\variable}{%
$\mathit{#1}$
}


This approach is working good for alphabetic variable as well as variables with indices etc. But when it comes to greek letter, I encountered that capital Greek letters lead to a black dot instead of the correct symbol.

\variable{\omega_{Ind}} or $\mathit{\omega_{Ind}}$ -> is working
\variable{\Omega_{Ind}} or $\mathit{\Omega_{Ind}}$ -> is not working

So my questions would be first, is this the overall right approach to introduce variable inside the text and second how can I resolve this issue?

• Just use $#1$. – Steven B. Segletes Oct 16 '16 at 19:48
• You were told wrong. That way of doing is incorrect. – egreg Oct 16 '16 at 20:48

I'm quite certain you misinterpreted what you read. Using \mathit should be reserved to multiletter identifiers, not single letter ones.

An example.

\documentclass{article}
\usepackage{amsmath}

\begin{document}

Let $x$ and $y$ denote real variables. We define the function \emph{difference} by
$\mathit{diff}(x,y)=x-y$
just because we like fancy function names. We also define the
\emph{absolute difference} by
$\mathit{diff}_{\mathrm{abs}}=\lvert x-y\rvert.$
Note that typing \verb|$diff(x,y)$| would produce $diff(x,y)$
which is awful.

\end{document} Note that the single letter variables are typed in in normal way. This applies to Greek letters as well, so you'll simply type $\Omega$ for the single variable in text, like in

The quantity $\Omega$ is defined by $\Omega=x+y$.


Textual subscripts should generally be upright, so

The quantity $\Omega_{\mathrm{Ind}}$ is defined by
$\Omega_{\mathrm{Ind}}=x+y$.


Of course you want to abstract the definition, in case you use several multiletter identifiers and want a uniform style. So you'll say something like

\documentclass{article}
\usepackage{amsmath}

\newcommand{\variable}{\mathit{#1}}
\newcommand{\diff}{\variable{diff}} % a shorthand
\newcommand{\diffabs}{\variable{diff}_{\mathrm{abs}}} % a shorthand

\begin{document}

Let $x$ and $y$ denote real variables. We define the function \emph{difference} by
$\diff(x,y)=x-y$
just because we like fancy function names. We also define the
\emph{absolute difference} by
$\diffabs=\lvert x-y\rvert.$

\end{document}


in order to get the same output as before. First a generic wrapper is defined, then you can define shorthands for frequently used variable names in terms of the wrapper.

If your supervisor or a journal copy editor asks you to change the multiletter variables into Comic Sans Small Caps Boldface Reversed, you'll just change the definition of \variable.

## Note

The silly text given as example is just so. I wanted to use diff in order to emphasize the reason why multiletter identifier (if chosen to be set in italics to begin with) should use \mathit. I'm in by no means promoting such usage without a proper “operator” syntax; as observed by Gustavo in his comment, one should distinguish between variables and functions. In particular this would be “more correct”:

%% two different abstractions
\newcommand{\function}{\operatorname{\mathit{#1}}}
\newcommand{\variable}{\mathit{#1}}

\newcommand{\diff}{\function{diff}}
\newcommand{\diffabs}{\diff_{\mathrm{abs}}}


On the other hand, such multiletter identifiers in italics used either as variable names or function names should never appear next to another letter or object of the same kind in order to avoid confusion. Thus the distinction between variable and function is somewhat blurry.

• I was wondering whether \diff and \diffabs shouldn’t rather be operators: after all, this is not quite the same situation as in, say, $\mathit{counter}\gets\mathit{counter}+1$; it’s more like \sin – GuM Oct 16 '16 at 22:50
• @GustavoMezzetti For function names it would be perhaps better, not for variable names. I didn't want to think too much to a meaningful example. – egreg Oct 16 '16 at 23:20
• @ egreg, thanks for the detailed explanation! I think we can close the topic with this and I will follow accourding to your suggestions. – Jäger Oct 18 '16 at 22:35