This question already has an answer here:

I have written two equations for the report of my Master thesis:

$NLL_{k} = - \sum_{j=1}^n \ln(pdf(PD_{k}^{i},skill_{i}^{j}))$

$person_{k}(interest) = \dfrac{1}{n} \sum_{p=1}^n \dfrac{person_{k}(task_{p})}{\alpha_{k}^{i}}$

enter image description here

enter image description here

In math mode everything is italic (except \ln). Is this ok or how should this be correctly formated?

Second, let's say I would like to use part of the equation in text. For example, I would like to write "It is visible that $person_{k}$ has very high interest.". Should $person_{k}$ in this case be in italic?

marked as duplicate by Mico equations Jul 2 '16 at 9:43

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    For such words I would use \text{person} etc, not in italic font. The reason why \ln is set upright is its definition as \DeclareMathOperator – Christian Hupfer Jul 2 '16 at 9:03
  • 1
    never use the default math italic font for multi-letter words it is designed to make consecutive letters not look like a word, but as a product of variables. Even if you want the word in italic use \mathit{person} or \mathrm{person} for upright. (compare $difficult$ and $\mathit{difficult}$` – David Carlisle Jul 2 '16 at 9:10
  • 1
    Whatever you choose, define a symbolic and semantic command, which will make absolutely easy to change the definition later. For instance \var or \mvar (math variable) could look good, but you can choose the name you want. – Manuel Jul 2 '16 at 9:43

Opinion based answer: For variables that have human readable names or are acronyms (somehow), I would prefer \text or a \DeclareMathOperator approach (or \mathit and \mathrm, depending on personal taste)

If the symbols are used more than once, markup macros are a better way

\documentclass{article}
\usepackage{mathtools}


\DeclareMathOperator{\pdf}{pdf}

\begin{document}

Original version


$NLL_{k} = - \sum_{j=1}^n \ln(pdf(PD_{k}^{i},skill_{i}^{j}))$

$person_{k}(interest) = \dfrac{1}{n} \sum_{p=1}^n \dfrac{person_{k}(task_{p})}{\alpha_{k}^{i}}$

With \verb!\text!: 

\begin{equation}
  \text{NLL}_{k} = - \sum_{j=1}^n \ln(\pdf(\text{PD}_{k}^{i},\text{skill}_{i}^{j}))
\end{equation}

$\text{person}_{k}(\text{interest}) = \dfrac{1}{n} \sum\limits_{p=1}^n \dfrac{\text{person}_{k}(\text{task}_{p})}{\alpha_{k}^{i}}$


With \verb!\mathit!: 

\begin{equation}
  \mathit{NLL}_{k} = - \sum_{j=1}^n \ln(\pdf(\mathit{PD}_{k}^{i},\mathit{skill}_{i}^{j}))
\end{equation}

$\mathit{person}_{k}(\mathit{interest}) = \dfrac{1}{n} \sum\limits_{p=1}^n \dfrac{\mathit{person}_{k}(\mathit{task}_{p})}{\alpha_{k}^{i}}$


\end{document}

enter image description here

  • @machinery: Some purists say: yes, but I personally find italics math style for variable names awful – Christian Hupfer Jul 2 '16 at 9:09
  • Alright, but what about "NLL" for negative log-lieklihood or "AIC" for the Akaike information criterion? Are these also acronyms? – machinery Jul 2 '16 at 9:11
  • @machinery - "NLL" and "AIC" pretty much fit the very definition of acronym, don't they? – Mico Jul 2 '16 at 9:12
  • @machinery $NLL$ is the markup for N times N times L, so you want \mathrm{NLL} or \mathit{NLL} or, perhaps \text{NLL} according to taste. (\text picks up the surrounding text font which may or may not be what you want) – David Carlisle Jul 2 '16 at 9:13
  • 1
    @machinery The problem with \text is that it takes the surrounding style, so if you are in a theorem with italics, those words would be in italic. Above all, define \var and use \var{person} and then you can change definition after if you find that it doesn't work as expected. So, if you want upright, use \newcommand*\var{\mathrm} or with \newcommand*\var{\textnormal}, and if you want italics, use \newcommand*\var{\mathit} or \newcommand*\var[1]{\textnormal{\textit{#1}}}. – Manuel Jul 2 '16 at 9:38

Not the answer you're looking for? Browse other questions tagged or ask your own question.