0

Need to use a variable "n_" in mathmode, which returns error in case to be coded like $n_{ _}$

1
  • Welcome to TeX.SX! Please always show a minimal but working example instead of only a code snippet and please always cite the exact error message you get. Without those information we need to speculate instead of being able to analyze the problem and show you a verified solution. Oct 14, 2017 at 13:38

3 Answers 3

0

If you need the symbol _ you can use, e.g., \_ or an \underline with a proper white space argument:

\documentclass{article}

\begin{document}
$n\_$ vs. $n\underline{\enskip}$
\end{document}

enter image description here

1

IMHO, $n_-$ is most simple and sufficient.

0

You can use \mathunderscore or \text{$\mathunderscore$}: they are equivalent if the symbol is only used in text style and not in subscripts/superscripts. Take your pick.

\documentclass{article}
\usepackage{amsmath}

\newcommand{\usvarA}[1]{#1\mathunderscore}
\newcommand{\usvarB}[1]{#1\text{$\mathunderscore$}}

\begin{document}

$\usvarA{n}$ and $X_{\usvarA{n}}$

$\usvarB{n}$ and $X_{\usvarB{n}}$

\end{document}

enter image description here

You must log in to answer this question.

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