如何在 align* 环境中将几行放在侧括号内?

如何在 align* 环境中将几行放在侧括号内?

我想在环境中的几行周围放置一个侧括号align*,如以下代码中的注释所示:

\begin{align*}
    left side & = right side \\
    left side & = right side \\  %   }
    left side & = right side \\  %   }-  these three lines are important
    left side & = right side \\  %   }
    left side & = right side \\
\end{align*}

答案1

您不需要任何额外的软件包来执行此操作。以下是使用常规的方法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}

左边是常规align*环境(来自amsmath),而右边应该是。中间方程中添加了一个只有右分隔符的array零高度 3 行以对输出进行分组。array\}


另一个选择是,这次使用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}

与环境相比,您可能需要调整垂直位移align*

答案2

应该还有其他方法可以做到这一点。但我喜欢这个tikzmark方法。参考资料如下:

  1. 安德鲁·斯泰西 (Andrew Stacey)

  2. 在此站点搜索

部分代码摘自参考文献1,特此致谢。

我根据方程的长度使用了不同的放置方式(您可以选择合适的方式或找到自己的放置方式)。这是 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}

在此处输入图片描述

编辑

正如 Peter Grill 所建议的,可以定义一个宏,例如

\newcommand{\EmBrace}[3][]{%
    \begin{tikzpicture}[overlay,remember picture]%
        \draw [decoration={brace,amplitude=0.5em},decorate,ultra thick, #1] (#2) -- (#3);
    \end{tikzpicture}%
    }%

用于在文档中的任意位置重复标记,例如

\EmBrace[magenta]{seventh.north east}{eigthth.east}

若未指定颜色,black则使用默认颜色。

编辑-2:

ams cases接下来尝试对环境进行丑陋的破解。

\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} 

在此处输入图片描述

如果需要涵盖整个方程式,则empheq包一定是令人感兴趣的。

\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} 

在此处输入图片描述

相关内容