Page LayoutUsing align and \left \right commands at same time.

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
tennisgremlin
Posts: 2
Joined: Thu Sep 08, 2011 4:29 pm

Using align and \left \right commands at same time.

Post by tennisgremlin »

Hello,

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!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Using align and \left \right commands at same time.

Post by localghost »

Every side of the equations represents a group. So scalable delimiters of this kind don't work across those boundaries. You have to insert some intermediate invisible delimiters.

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}
The same applies in a similar way to delimiters across several lines.


Best regards and welcome to the board
Thorsten
tennisgremlin
Posts: 2
Joined: Thu Sep 08, 2011 4:29 pm

Re: Using align and \left \right commands at same time.

Post by tennisgremlin »

Hello,

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.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Using align and \left \right commands at same time.

Post by localghost »

I see two possible approaches.
  1. Insert a vertical phantom on the left side to get the automatic scaling right.
  2. Adjust the delimiters manually and you only need one real pair of them.
Both methods are shown in the below example.

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}
For more stuff about math typesetting have a look at the excellent »Math mode« document.
Post Reply