Page Layout ⇒ Using align and \left \right commands at same time.
-
- Posts: 2
- Joined: Thu Sep 08, 2011 4:29 pm
Using align and \left \right commands at same time.
The following code will not execute in latex:
\begin{align*}
\left[a + b &= c + d\right] \\
\left[e + f &= g + h\right]
\end{align*}
The problem has to do with the "\left" and "\right" commands for the brackets. If I remove the "&" in front of both equal signs the code compiles, but the equations are not aligned properly. Is there a way to align the equations and use the "\left" and "\right" commands simultaneously?
Thanks for the help!
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Using align and \left \right commands at same time.
Code: Select all
\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage{mathtools} % loads »amsmath«
\begin{document}
\begin{align*}
\left[a + b\right. &=\left. c + d\right] \\
\left[e + f\right. &=\left. g + h\right]
\end{align*}
\end{document}
Best regards and welcome to the board
Thorsten
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
-
- Posts: 2
- Joined: Thu Sep 08, 2011 4:29 pm
Re: Using align and \left \right commands at same time.
The code posted works well, except for one minor problem. If the right side of the equation (d in this case) is taller than the left side (a in this case), then the right bracket is larger than the left. Is there a way to match the heights of both brackets?
Thank you.
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Using align and \left \right commands at same time.
- Insert a vertical phantom on the left side to get the automatic scaling right.
- Adjust the delimiters manually and you only need one real pair of them.
Code: Select all
\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage{mathtools} % loads »amsmath«
\begin{document}
\begin{align*}
\left[a + b\vphantom{\frac{0}{0}}\right. &=\left. c + \frac{x-d}{x+d}\right] \\
\bigg[e + f &= g + \frac{x-h}{x+h}\bigg]
\end{align*}
\end{document}
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10