2

A small problem this time: I try to underline my result in an align environment using the package ulem. The problem: I want to underline the whole result (e.g. x=1) not only 1. But because I like the = aligned, I have to write x&=1. If I want to underline it, the & is inside the \uuline{} and it gives an error.

Is there a solution for this? I found a "solution" online, but they put a line below outside and brought it in position via hspace and vspace, and that's a very dirty solution.

Here's an MWE, commented is the line which doesn't work.

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{ulem}

\begin{document}
Here's an example:
\begin{align*}
x+2&=3\\
x&=\uuline{1}
%\uuline{x&=1}
\end{align*}
\end{document}
  • May I suggest it would look better boxed? The mathtools package (which loads amsmath) defines the \Aboxed{...} command, which accepts &. – Bernard Oct 8 '17 at 21:04
  • 1
    Shouldn't "not online 1" be "not only 1"? I've omitted this edition, waiting for your decision. – Przemysław Scherwentke Oct 8 '17 at 21:14
  • Yeah, it should be "not only 1", sorry. So in this case your solution given below is perfectly fine, thank you. – buecki Oct 9 '17 at 11:09
2

This underlines the second line of your pair, as required.

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{ulem}

\begin{document}
Here's an example:
\begin{align*}
x+2&=3\\
\makebox[0pt][l]{\uuline{\phantom{$x=1$}}}
x&=1
%x&=\uuline{1}
%\uuline{x&=1}
\end{align*}
\end{document}

enter image description here

If you need to use it many times, writing a macro should decrease the time needed.

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.