5

For school we have to deliver all math with double lines under the result.

I have made a command that makes this easy. It looks like this:

\newcommand*{\uul}[1]{
\underline{\underline{#1}}
}

It works great, except when I use it with the align* environment. If there is a &= inside, like so:

\uul{x &= 14}

it throw up all kinds of errors. If I remove the & it works just fine.

I am guessing there is some problems arising from passing the content around, but is there any way to solve this?

  • 1
    Please supply us with a full working document (called a minimal working example (MWE)) that we can copy-and-paste to replicate your problem. – Werner Feb 24 '14 at 20:45
  • 1
    The Q&D solution is to use \uul{x}&\uul{= 4} – John Kormylo Feb 24 '14 at 20:51
5

I think the easiest way would be to retrace the "final equation" using an overlapped \phantom, where you set the underlines (as in the third set of equations below). That overcomes the problem of spreading the function across the alignment marker &, which is not easy to do otherwise:

enter image description here

\documentclass{article}
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\newcommand*{\uul}[1]{\underline{\underline{#1}}}
\begin{document}

\begin{align*}
  f(x) &= ax^2 + bx + c \\
     x &= 5
\end{align*}

\begin{align*}
  f(x) &= ax^2 + bx + c \\
     \text{\uul{$x$}} &\text{\uul{${}= 5$}}
\end{align*}

\begin{align*}
  f(x) &= ax^2 + bx + c \\
     x &= 5\llap{\uul{\phantom{$x=5$}}}
\end{align*}

\begin{align*}
  f(x) &= ax^2 + bx + c \\
       &\makebox[0pt][r]{\uul{$x$}}\text{\uul{${} = 5$}}
\end{align*}

\end{document}

\llap is similar to \makebox[0pt][r] which provides a left overlap of stuff.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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