# Underline inside of enumerate and align

MAIN QUESTION! This is my first question on here so bear with me. I would like to underline my last line of code where it says underline. I have tried to do so as you can see below, but I keep getting an error. I have looked at other posts, but they do not work for my situation as the users are not inside of enumerate or aligned.

For a bonus, I would also like to do the following

1 Align all numbers, operators, variables, andd insert blank spaces for variables not displayed. As shown in the second image below.

2 I would like to have the word solution and the following equations closer to the left because they appear too far to the right.

3 I would like to have a column for each question and/or answer similar to the format shown in the second image below.

4 I would also like to know how I can bring the word solution down without needing to put so many backslashes as shown below.

5 I cannot get the hyphen to appear where it shows exercises 1-4 when I compile my code.

Please note that I am a code minimalist as you can see, aha! So, if it is possible to code in the desired format using a small amount of code that would be much appreciated.

CODE FOR MAIN QUESTION

    \begin{document}
\begin{enumerate}
\item
\begin{aligned}[t] x_1+5x_2&= 7 \\ -2x_1-7x_2&=-5 \\ \end{aligned} \\\\\\ \textbf{Solution:} \\\\ \begin{aligned}[t] x_1+5x_2&=7 \\ -2x_1-7x_2&=-5 \\\\ 2(x_1 +5x_2&=7) & \text{Replacement Eq. 2}\\ \underline{+-2x_1-7x_2&=-5} \end{aligned}
\end{enumerate}
\end{document}


• Welcome to TeX.SE! The issue is not enumerate, nor aligned, but the fact that you want to underline some piece that contains an &. You can solve this issue by saying \underline{+-2x_1-7x_2}&\underline{=-5\vphantom{x_1}}. The \vphantom is just there to make sure that the underline is on the same level on both sides of the &. – marmot Aug 18 '18 at 3:52
• Welcome! 1) Follow the suggestions of the marmot, and 2) I like the red-black style :). – manooooh Aug 18 '18 at 4:06
• @Bernard Thanks for correcting my silly misspellings. Didn't know people could do that. – I. King Aug 18 '18 at 19:09
• @manooooh thanks! I use overleaf v1 night style. v2 does not havev this style. – I. King Aug 18 '18 at 19:09
• As Zarko answered, one problem per question works best on this site. The - disappears because you copy and pasted an en-dash from somewhere else instead of typing - on your keyboard. – Teepeemm Aug 18 '18 at 23:36

• please one problem per question ...
• your mwe is not complete and it produce different result from your illustration of problem
• main problem can be solved by use of \array instead of the aligned math environment

\documentclass{article}
\usepackage{amsmath}
\setlength\arraycolsep{1pt}

\begin{document}
\begin{enumerate}
\item
$\begin{array}[t]{rl} x_1+5x_2&= 7 \\ \hline -2x_1-7x_2&=-5 \\ \hline \end{array}$

\bigskip
\textbf{Solution:}
$\begin{array}[t]{rll} x_1+5x_2 &=7 & \\ -2x_1-7x_2 &=-5 & \\ 2(x_1 +5x_2 &=7) & \qquad\text{Replacement Eq. 2}\\ \pm 2x_1-7x_2&=-5 & \\ \cline{1-2} \end{array}$
\end{enumerate}
\end{document}


edit:

• array option [t] align array first row with text row where array is placed(without option the vertical center of array is aligned and with option [b] is aligne bottom array row
• cline{1-2}˛draw line from start of first column to end of the second column
• command \pm (plus minus) write symbol + over -`
• i suggest you to read some introductory texts about latex, for example The Not so short Introduction to LaTeX2e or for tables in math as are LaTeX/Tables and LaTeX/Mathematics
• Thanks for the quick reply and nice tips for using stack exchange! Since I am fairly new to LaTeX, some of what you have done I did not understand. What is \cline, connect line? Also, what is \pm? Also, I found [t] online but I do not know what that means. Can you explain it? Thanks again @Zarko – I. King Aug 18 '18 at 19:21