9

What is wrong with underbrace please, there is no text below after the compilation

\begin{equation}
\underbrace{{\color{red}I_j (x)} \ast \Delta_j(x,t_l,{\color{red}p})}_{\text{I_j(x)(x-v_j(t,p))}} \mathrm{d}x
\end{equation}
4
  • 3
    Unrelated, this will never work at \text switches to the text font where _ is not allowed. It ought to work if you remove the text command. And as mentioned, please always post full minimal examples, not sniplets.
    – daleif
    Commented Sep 1, 2019 at 7:42
  • 2
    ... Or probably related. (I tend to react heavily to bad usages of the text command as it is a very frequent issue that people does not realize)
    – daleif
    Commented Sep 1, 2019 at 7:49
  • 3
    Remove \text and it will work.
    – Leucippus
    Commented Sep 1, 2019 at 8:17
  • Thank you very much Commented Sep 1, 2019 at 8:44

1 Answer 1

13

\text is when the subscript is textual.

You should also prefer \textcolor and brace the whole \underbrace construct.

\documentclass{article}
\usepackage{amsmath}
\usepackage{xcolor}

\begin{document}

\begin{equation}
 {% make the \underbrace an ordinary atom
  \underbrace{\textcolor{red}{I_j (x)} \ast \Delta_j(x,t_l,\textcolor{red}{p})}%
    _{I_j(x)(x-v_j(t,p))}
 }\,\mathrm{d}x
\end{equation}

\end{document}

enter image description here

Why preferring \textcolor? Because you can redefine it to preserve the nature of math atoms:

\documentclass{article}
\usepackage{amsmath}
\usepackage{xcolor}

\makeatletter
\renewcommand{\@textcolor}[3]{%
  \relax
  \ifmmode
    \begingroup\color#1{#2}#3\endgroup
  \else
    \protect\leavevmode{\color#1{#2}#3}%
  \fi
}
\makeatother

\begin{document}

$a\textcolor{red}{=}b$

$a{\color{red}=}b$

\end{document}

enter image description here

5
  • Could you please elaborate on why \textcolor{...}{...} should be preferred over {\color{...} ...}?
    – GuM
    Commented Sep 1, 2019 at 11:37
  • @GuM \textcolor uses \begingroup...\endgroup rather than {...}, with obvious effects on the math list.
    – egreg
    Commented Sep 1, 2019 at 12:48
  • I didn’t know this. Is it a new feature? In version 2.12 (2016/05/11) of the xcolor package the definition of \@textcolor#1#2#3 is still \protect\leavevmode{\color#1{#2}#3}.
    – GuM
    Commented Sep 1, 2019 at 13:21
  • @GuM I seemed to remember this feature. Anyway, it's easy to add it.
    – egreg
    Commented Sep 1, 2019 at 13:45
  • Well, as you say, \begingrup ...\endgroup is indeed better, for obvious reasons. The same change should be made in the color package too. The latter is currently maintained by “The LaTeX3 Project”, which includes you. :-)
    – GuM
    Commented Sep 1, 2019 at 13:54

You must log in to answer this question.

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