4

The following output looks so dense. Could you make it more loose in both vertical and horizontal?

MWE

\documentclass[preview,border=12pt,12pt]{standalone}
\usepackage{amsmath,xcolor}
\let\temp\underbrace
\def\underbrace#1_#2{{\color{red}\temp{{\color{black}#1}}_{#2}}}

\begin{document}
$\displaystyle
\begin{aligned}
x^2+6x+10 
&= \underbrace{x^2}_{a^2} \underbrace{+2x (3)}_{+2ab} + 10\\
&= \underbrace{x^2}_{a^2} \underbrace{+2x (3)}_{+2ab} \underbrace{+(3)^2 -(3)^2}_{+b^2-b^2} +10\\
&= \underbrace{x^2+2x(3)+(3)^2}_{a^2+2ab+b^2}  -(3)^2 +10\\
&= \underbrace{(x+3)^2}_{(a+b)^2} -9 +10\\
&= (x+3)^2+1
\end{aligned}
$
\end{document}

enter image description here

Any constructive suggestions, advice, ideas, etc are always welcome!

5

I'd use \mathstrut to cover the most common cases avoiding phantoms; also \textcolor is better than \color in math mode.

You need to add {} in front of + to get decent spacing. I also added a couple of thin spaces for separating the braces.

\documentclass[border=12pt,12pt]{standalone}
\usepackage{amsmath,xcolor}

\let\latexunderbrace\underbrace
\def\underbrace#1_#2{%
  {\,\textcolor{red}{\latexunderbrace{\textcolor{black}{\mathstrut#1}}_{#2}}\,}%
}

\begin{document}
$\displaystyle
\begin{aligned}
x^2+6x+10 
&= \underbrace{x^2}_{a^2} \underbrace{{}+2x (3)}_{+2ab} + 10\\
&= \underbrace{x^2}_{a^2} \underbrace{{}+2x (3)}_{+2ab} \underbrace{+(3)^2 -(3)^2}_{+b^2-b^2} +10\\
&= \underbrace{x^2+2x(3)+(3)^2}_{a^2+2ab+b^2}  -(3)^2 +10\\
&= \underbrace{(x+3)^2}_{(a+b)^2} -9 +10\\
&= (x+3)^2+1
\end{aligned}
$
\end{document}

enter image description here

A slightly better version where the space in front of the + is removed

\documentclass[border=12pt,12pt]{standalone}
\usepackage{amsmath,xcolor}

\let\latexunderbrace\underbrace
\def\underbrace#1_#2{%
  {\,\textcolor{red}{\latexunderbrace{\textcolor{black}{\mathstrut#1}}_{#2}}\,}%
}
\newcommand{\hplus}{{\mspace{-\medmuskip}}+}

\begin{document}
$\displaystyle
\begin{aligned}
x^2+6x+10 
&= \underbrace{x^2}_{a^2} \underbrace{\hplus 2x (3)}_{+2ab} + 10\\
&= \underbrace{x^2}_{a^2} \underbrace{\hplus2x (3)}_{+2ab} \underbrace{+(3)^2 -(3)^2}_{+b^2-b^2} +10\\
&= \underbrace{x^2+2x(3)+(3)^2}_{a^2+2ab+b^2}  -(3)^2 +10\\
&= \underbrace{(x+3)^2}_{(a+b)^2} -9 +10\\
&= (x+3)^2+1
\end{aligned}
$
\end{document}

enter image description here

4

enter image description here

\documentclass[preview,border=12pt,12pt]{standalone}
\usepackage{amsmath,xcolor}
\let\temp\underbrace
\def\underbrace#1_#2{{\color{red}\temp{{\color{black}{\strut}#1{}}}_{#2}}}

\begin{document}
$\displaystyle
\openup1\jot
\begin{aligned}
x^2+6x+10 
&= \underbrace{x^2}_{a^2} \underbrace{+2x (3)}_{+2ab} + 10\\
&= \underbrace{x^2}_{a^2} \underbrace{+2x (3)}_{+2ab} \underbrace{+(3)^2 -(3)^2}_{+b^2-b^2} +10\\
&= \underbrace{x^2+2x(3)+(3)^2}_{a^2+2ab+b^2}  -(3)^2 +10\\
&= \underbrace{(x+3)^2}_{(a+b)^2} -9 +10\\
&= (x+3)^2+1
\end{aligned}
$
\end{document}

{} so + gets infix spacing, added \strut so the braces are all at same depth, and added \openup to increase the line spacing a bit.

  • your example doesn't use align* ?? – David Carlisle Dec 14 '18 at 18:59
  • 1
    @ArtificialStupidity the same, before the environment – David Carlisle Dec 14 '18 at 19:55

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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