How do I format words as variable names?

Some options you have for typesetting words as variables include:

As Operator Names

The \operatorname command from amsmath typesets its argument like the operators sin or log. In particular, you get a bit of extra spacing between α and Risk: \alpha \Risk_i is typeset exactly like \alpha \log_i.

One downside is that the spacing between \Risk and \cdot will be wrong, so you would need to write something like \Risk\! \cdot \alpha, or {\Risk} \cdot \alpha.

\documentclass{article}
\usepackage{amsmath}
\usepackage{fontspec}

%Formatting for a MWE on TeX.SX:
\usepackage[paperwidth=10cm]{geometry}
\pagestyle{empty}

\newcommand{\Risk}{\operatorname{Risk}}
\newcommand{\CEOPC}{\operatorname{CEO\_PC}}
\newcommand{\BRind}{\operatorname{BR\_ind}}

\begin{document}
\begin{equation}
  \begin{split}
    \Risk_{i,t} = c + &\alpha \Risk_{i,t-1} + \beta_{1}\CEOPC_{i,t} + \\
       &\beta_{2}\BRind_{i,t} + \beta_{k}Z_{i,t}+\epsilon_{i,t}
  \end{split}
\end{equation}
\end{document}

Latin Modern sample

As Formatted Text

You can use the command \textnormal in math mode to set short phrases of text, and use any text-mode formatting you want. In this example, I typeset them as slanted, not italic, text.

\documentclass{article}
\usepackage{amsmath}
\usepackage{fontspec}

%Formatting for a MWE on TeX.SX:
\usepackage[paperwidth=10cm]{geometry}
\pagestyle{empty}

\newcommand\variablename[1]{\mathop{\textnormal{\slshape #1}}\nolimits}

\newcommand{\Risk}{\variablename{Risk}}
\newcommand{\CEOPC}{\variablename{CEO\_PC}}
\newcommand{\BRind}{\variablename{BR\_ind}}

\begin{document}
\begin{equation}
  \begin{split}
    \Risk_{i,t} = c + &\alpha \Risk_{i,t-1} + \beta_{1}\CEOPC_{i,t} + \\
       &\beta_{2}\BRind_{i,t} + \beta_{k}Z_{i,t}+\epsilon_{i,t}
  \end{split}
\end{equation}
\end{document}

Slanted text sample

If you used \text, as in your example, the formatting of the text preceding the equation would bleed through. In some situations, though, you might want that: if you’re using \Risk in a heading that’s typeset as bold sans-serif, you might want your math symbols in bold sans-serif too.

Wrapping it in \mathop gives you spacing like the operator \lim, but then subscripts would be set beneath like \displaystyle lim_{\epsilon \to 0}. So, inhibit this with \nolimits.

At Mico’s suggestion, I moved the formatting into a new command \variablename and used it to define the other macros. This also lets you change the formatting of all full-word variables in one place, and write \variablename{Return} without having to declare a macro.

As Math Text Alphabets

This is what the alphabets \mathrm, \mathit, \mathbf, etc. are for.

\documentclass{article}
\usepackage{amsmath}
\usepackage{fontspec}

%Formatting for a MWE on TeX.SX:
\usepackage[paperwidth=10cm]{geometry}
\pagestyle{empty}

\newcommand\variablename[1]{\mathop{\mathit{#1}}\nolimits}

\newcommand{\Risk}{\variablename{Risk}}
\newcommand{\CEOPC}{\variablename{CEO\_PC}}
\newcommand{\BRind}{\variablename{BR\_ind}}

\begin{document}
\begin{equation}
  \begin{split}
    \Risk_{i,t} = c + &\alpha \Risk_{i,t-1} + \beta_{1}\CEOPC_{i,t} + \\
       &\beta_{2}\BRind_{i,t} + \beta_{k}Z_{i,t}+\epsilon_{i,t}
  \end{split}
\end{equation}
\end{document}

\mathit sample

By default and in most font packages, the shapes of the letters in \mathit are very similar to the math symbols in\mathnormal, but with \mathit, you get ligatures, kerning, and italic correction. You would definitely notice the difference between \mathit{fl} and \mathnormal{fl}.

Declaring a New Math Font

You can declare new math alphabets like \mathrm and \mathit as well. In unicode-math, you would use \setmathfontface, and in legacy NFSS, you would use \DeclareMathAlphabet.

\documentclass{article}
\usepackage{amsmath}
\usepackage{iftex}

\iftutex
  \usepackage{unicode-math}
  \setmathfontface{\mathvar}{lmsans10-oblique.otf}[Ligatures={Common,Rare}]
\else
  \usepackage[T1]{fontenc}
  \DeclareMathAlphabet{\mathvar}{T1}{lmss}{m}{sl}
\fi

%Formatting for a MWE on TeX.SX:
\usepackage[paperwidth=10cm]{geometry}
\pagestyle{empty}

\newcommand\variablename[1]{\mathop{\mathvar{#1}}\nolimits}

\newcommand{\Risk}{\variablename{Risk}}
\newcommand{\CEOPC}{\variablename{CEO\_PC}}
\newcommand{\BRind}{\variablename{BR\_ind}}

\begin{document}
\begin{equation}
  \begin{split}
    \Risk_{i,t} = c + &\alpha \Risk_{i,t-1} + \beta_{1}\CEOPC_{i,t} + \\
       &\beta_{2}\BRind_{i,t} + \beta_{k}Z_{i,t}+\epsilon_{i,t}
  \end{split}
\end{equation}
\end{document}

Latin Modern Sans Oblique sample

This example, which uses Latin Modern Sans Oblique, is somewhat contrived because either unicode-math or isomath define the alphabet \mathsfit.

Update

Henri Menke in the comments had another good suggestion, saying he uses

 \newcommand*\diff{\mathop{}\!\mathrm{d}}

to get operator-like spacing on the left and ordinary spacing on the right in expressions like dx.

If you write the equations the way you did, these variable names should be typeset as operators. Not everyone thinks this is correct. If you do not, you should be careful to always write, for example, \alpha \cdot \Risk instead of \alpha \Risk: you do not want to typeset a·mass as amass.


Not entirely sure what you mean by a better-looking equation, but if you place all of your longer variable names in a text box, it would look better to my eyes!

    \documentclass{article}
    \usepackage{amsmath}

    \begin{document}

    \begin{equation}
        \text{Risk}_{i,t}=c+\alpha \text{Risk}_{i,t-1}+\beta_{1}
        \text{CEO\_PC}_{i,t} +\beta_{2} \text{BR\_ind}_{i,t}+\beta_{k}
        \text{Z}_{i,t}+\epsilon_{i,t}
    \end{equation}

    \end{document}

Which would give:

enter image description here


I add my proposal, to have another very nice view as output.

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{amssymb}

  
\begin{document}
\begin{equation}
\mathsf{Risk}_{i,t}=c+\alpha \mathsf{Risk}_{i,t-1}+\beta_{1}
\mathsf{CEO\_PC}_{i,t}+\beta_{2} \mathsf{BR}\_\mathsf{ind}_{i,t}+\beta_{k}
\mathsf{Z}_{i,t}+\epsilon_{i,t}
\end{equation}
\end{document}

enter image description here

Using a macro \newcommand{\vn}[1]{\mathsf{#1}} as suggested by @Mico in the comment to have not many \mathsf:

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{amssymb}
\newcommand{\vn}[1]{\mathsf{#1}}

\begin{document}
\begin{equation}
\vn{Risk}_{i,t}=c+\alpha \vn{Risk}_{i,t-1}+\beta_{1}
\vn{CEO\_PC}_{i,t}+\beta_{2} \vn{BR}\_\vn{ind}_{i,t}+\beta_{k}
\vn{Z}_{i,t}+\epsilon_{i,t}
\end{equation}
\end{document}