How do I put a side brace around several lines in the align* environment?
You don't need any additional packages to do this. Here's a way using a regular array
:
\documentclass{article}
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\begin{document}
\noindent
\begin{minipage}{.5\textwidth}
\begin{align*}
f(x) & = a \\
g(x) & = ax + b \\
h(x) & = ax^2 + bx + c \\
i(x) & = ax^3 + bx^2 + cx + d \\
j(x) & = ax^4 + bx^3 + cx^2 + dx + e
\end{align*}
\end{minipage}%
\begin{minipage}{.5\textwidth}
\[
\setlength{\jot}{4.5pt}
\begin{array}{r@{\;}l}
f(x) & = a \\[\jot]
g(x) & = ax + b \\[\jot]
h(x) & = ax^2 + bx + c \hspace*{3em}
\smash{\left.\begin{array}{@{}c@{}}\\[\jot]\\[\jot]\\[\jot]\end{array}\right\}} \\[\jot]
i(x) & = ax^3 + bx^2 + cx + d \\[\jot]
j(x) & = ax^4 + bx^3 + cx^2 + dx + e
\end{array}
\]
\end{minipage}%
\end{document}
On the left is the regular align*
environment (from amsmath
), while the right should an array
. A zero-height 3-row array
with only a right \}
delimiter is added to the middle equation to group the output.
Another option, this time using blkarray
:
\documentclass{article}
\usepackage{blkarray}% http://ctan.org/pkg/blkarray
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\begin{document}
\noindent
\begin{minipage}{.5\textwidth}
\begin{align*}
f(x) & = a \\
g(x) & = ax + b \\
h(x) & = ax^2 + bx + c \\
i(x) & = ax^3 + bx^2 + cx + d \\
j(x) & = ax^4 + bx^3 + cx^2 + dx + e
\end{align*}
\end{minipage}%
\begin{minipage}{.5\textwidth}
\[
\def\arraystretch{1.1}
\begin{blockarray}{r@{\;}l}
f(x) & = a \\[\jot]
\begin{block}{r@{\;}l\}}
g(x) & = ax + b \\[\jot]
h(x) & = ax^2 + bx + c \\[\jot]
i(x) & = ax^3 + bx^2 + cx + d \\[\jot]
\end{block}
j(x) & = ax^4 + bx^3 + cx^2 + dx + e
\end{blockarray}
\]
\end{minipage}%
\end{document}
You may have to play around with the vertical displacement, compared to the align*
environment.
There should be other ways of doing this. But I like the tikzmark
way. The references are
By Andrew Stacey and
search in this site
Some part of the code is adopted with thanks from reference 1.
I have used different placements depending upon the length of your equations (you choose suitable one or find your own placement hopefully). Here is the MWE.
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing,calc}
\usepackage[showframe]{geometry} % to show the frame
%
\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node (#1) {};}
%
\begin{document}
\hfill\tikzmark{right}
\begin{align*}
left side & = right side \\
left side & = right side \tikzmark{first}\\
left side & = right side long and very long long and very long long and very long \\
left side & = right side \tikzmark{second}\\
left side & = right side
\end{align*}
%
\begin{tikzpicture}[overlay, remember picture]
\draw [decoration={brace,amplitude=0.5em},decorate,ultra thick,red]
($(right)!(first.north)!($(right)-(0,1)$)$) -- ($(right)!(second.south)!($(right)-(0,1)$)$);
\end{tikzpicture}
%
\begin{align*}
left side & = right side &\\
left side & = right sideE and very long long long long long long & \tikzmark{third}\\
left side & = right side & \\
left side & = right sidee & \tikzmark{fourth}\\
left side & = right side &
\end{align*}
%
\begin{tikzpicture}[overlay, remember picture]
\draw [decoration={brace,amplitude=0.4em},decorate,ultra thick,gray]
(third.north east) -- (fourth.east);
\end{tikzpicture}
%
\begin{align*}
&& left side & = right side & \\
&& left side & = right sideE and very long long long long long long && \tikzmark{fifth}\\
&& left side & = right side & \\
&& left side & = right sidee & \tikzmark{sixth}\\
&& left side & = right side &
\end{align*}
%
\begin{tikzpicture}[overlay, remember picture]
\draw [decoration={brace,amplitude=0.7em},decorate,ultra thick,blue]
(fifth.north east) -- (sixth.east);
\end{tikzpicture}
% The simple and using \phantom{}
\begin{align*}
left side & = right side \\
left side & = right side bigger equation \tikzmark{seventh}\\
left side & = right side \\
left side & = right side \phantom{bigger equation} \tikzmark{eigthth}\\
left side & = right side
\end{align*}
%
\begin{tikzpicture}[overlay, remember picture]
\draw [decoration={brace,amplitude=0.5em},decorate,ultra thick,magenta]
(seventh.north east) -- (eigthth.east);
\end{tikzpicture}
%
\end{document}
EDIT
As suggested by Peter Grill, one can define a macro like
\newcommand{\EmBrace}[3][]{%
\begin{tikzpicture}[overlay,remember picture]%
\draw [decoration={brace,amplitude=0.5em},decorate,ultra thick, #1] (#2) -- (#3);
\end{tikzpicture}%
}%
for marking anywhere in the document repeatedly like
\EmBrace[magenta]{seventh.north east}{eigthth.east}
If the color is not specified, black
will be used by default.
EDIT-2:
Next try with an ugly hack of ams cases
environment.
\documentclass{article}
\usepackage{amsmath}
%%-----------------------------------
\makeatletter
\newenvironment{rightcase}{%
\matrix@check\cases\env@cases
}{%
\endarray\right\}%
}%
\def\env@cases{%
\let\@ifnextchar\new@ifnextchar
\left.
\def\arraystretch{1.2}%
\array{@{}l@{\,\,}l@{}}%
}%
\makeatother
%%-----------------------------------
\begin{document}
%%-----------------------------------
\begin{align*}
f(x) & = x^{2} + x +10 \\
g(x) & = \\[-17pt] % Little eyeballing should help to decide this value.
f(x) + g(y) & = \begin{rightcase}
x^{2} + x +10 - y^{2} + y\\
x^{2} + x\\
y^{2} + 2y + 10
\end{rightcase} \\[-17pt]
g'(y) & = \\
f(x,y) & = x^{2} + x +10 + y^{3}
\end{align*}
%%-----------------------------------
\end{document}
If the entire bunch of equations need to be covered, then empheq
package must be of interest.
\documentclass{article}
\usepackage{empheq}
%-----------------------------------
\begin{document}
%-----------------------------------
\begin{subequations}
\begin{empheq}[right=\empheqrbrace]{align*}
a_1(x) &= b_1\\
a_2(x) &= b_2\\
a_3(x) &= b_3
\end{empheq}
\end{subequations}
%-----------------------------------
\end{document}