2

For some reason, \underline doesn't work in \begin{flalign*}. I have a fragment of an equation which ends like

\begin{flalign*}
t&=10
\end{flalign*}

and I want to underline the last equation

\begin{flalign*}
\underline{t&=10}
\end{flalign*}

and I'm getting an error about a missing } which is not missing. Why?

inb4: yes, I know I can underline both sides of the equation, that's not what I'm asking for.

1 Answers1

4

The problem is that you cannot enclose the alignment point & within the \underline. Quick fix: overprint the line first.

\documentclass{article}

\usepackage{mathtools}

\begin{document}

\begin{flalign} \mathrlap{\underline{\phantom{t=10}}}t&=10 \ t &= 10 \end{flalign}

\end{document}

enter image description here

mathtools is an extension to amsmath (which is automatically loaded) and provides \mathrlap. You can obtain the same without mathtools with e.g.

\begin{flalign*}
\makebox[0pt][l]{\underline{$\phantom{t=10}$}}t&=10 \\
t &= 10
\end{flalign*}

or (more plain TeX)

\begin{flalign*}
\rlap{\underline{$\phantom{t=10}$}}t&=10 \\
t &= 10
\end{flalign*}

but I find the code hard to read. Furthermore, \mathrlap will always use the correct math style; not an issue in this specific case but it will be if you try to underline more complicated expressions.

Other ways are shown in Underlining an equation in an align block.

campa
  • 31,130
  • Neither of these really look nice, I find it baffling that the most basic of formatting options sometime srequire reinventing the wheel in this supposedly amazing language. But thanks. – gbgdhghfghfghfg May 24 '20 at 00:09