枚举环境中的大右括号

枚举环境中的大右括号

我正在尝试cases使用经典技巧来创建一个右边带有括号的环境\left. \begin{aligned} ... \end{aligned} \right\},但特殊之处在于我处于枚举环境中,这会给我以下结果,具体取决于我在环境[t]中放置的位置aligned

在此处输入图片描述

以下是产生该结果的代码:

\documentclass[fleqn, 12pt]{article}
\usepackage{amsmath}

\begin{document}

\begin{enumerate}
    \item 
    $\begin{aligned}
        \left.
        \begin{aligned}[t]
            &y=\frac{d}{x} \, \Rightarrow \, y^2=\frac{d^2}{x^2} \\[1ex]
            &y^2=db-dx
        \end{aligned} \right\}
    \end{aligned}$
    \item
    $\begin{aligned}[t]
        \left.
        \begin{aligned}
            &y=\frac{d}{x} \, \Rightarrow \, y^2=\frac{d^2}{x^2} \\[1ex]
            &y^2=db-dx
        \end{aligned} \right\}
    \end{aligned}$
\end{enumerate}

\end{document}

而且,rcases环境给出了与 2 相同的结果。

问题是我两者都不想要。我想要两者的混合,其中第一个方程与 1. 或 2. 对齐,并且括号不要太大。

提前感谢您的回答!

答案1

您可以测量顶部的高度aligned(不带支架)和aligned带支架的高度。然后降低后者,使参考点与前者一致。

\documentclass[fleqn, 12pt]{article}
\usepackage{amsmath}

\NewDocumentEnvironment{itemaligned}{b}{%
  \sbox0{$\begin{aligned}[t]#1\end{aligned}$}%
  \sbox2{$\left.\begin{aligned}#1\end{aligned}\right\}$}%
  \raisebox{\dimeval{\ht0-\ht2}}{\usebox{2}}%
}{}

\begin{document}

\begin{enumerate}
    \item
    \begin{itemaligned}
      &y=\frac{d}{x} \, \Rightarrow \, y^2=\frac{d^2}{x^2} \\[1ex]
      &y^2=db-dx
    \end{itemaligned}
\end{enumerate}

\end{document}

在此处输入图片描述

您可以稍加修改地添加一个以括号为中心的公式:这样的公式应该作为可选参数,itemaligned如下面的代码所示。

\documentclass[fleqn, 12pt]{article}
\usepackage{amsmath}

\NewDocumentEnvironment{itemaligned}{ob}{%
  \sbox0{$\begin{aligned}[t]#2\end{aligned}$}%
  \sbox2{%
    $\left.\begin{aligned}#2\end{aligned}\right\}%
    \IfValueT{#1}{\displaystyle{}#1}$%
  }%
  \raisebox{\dimeval{\ht0-\ht2}}{\usebox{2}}%
}{}

\begin{document}

\begin{enumerate}
    \item 
    \begin{itemaligned}[\Rightarrow \frac{d^2}{x^2}=db-dx]
      &y=\frac{d}{x} \, \Rightarrow \, y^2=\frac{d^2}{x^2} \\[1ex]
      &y^2=db-dx
    \end{itemaligned}
\end{enumerate}

\end{document}

在此处输入图片描述

答案2

带有包tikzmark库。为了使用美观的括号,还tikz使用了:decorations.pathreplacingcalligraphy

\documentclass[fleqn, 12pt]{article}
\usepackage{mathtools}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing,%
                calligraphy,% had to be after decorations.pathreplacing
                tikzmark}
\tikzset{BC/.style  = {decorate,
            decoration={calligraphic brace, amplitude=6pt,
                        pre =moveto, pre  length=1pt,
                        post=moveto, post length=1pt,
            raise = 6pt,
                    #1},% for mirroring of brace, if needed
            ultra thick,
            pen colour={black}},
        }

\begin{document}

\begin{enumerate}
    \item
    $\begin{aligned}[t]
          y & = \dfrac{d}{x} \, \Rightarrow \, y^2 = \tikzmarknode{A}{\dfrac{d^2}{x^2}} \\
        y^2 & = db - \tikzmarknode{B}{dx}          \\
        \end{aligned}$
    \item
    $\begin{aligned}[t]
          y & = \dfrac{d}{x} \, \Rightarrow \, y^2 = \tikzmarknode{C}{\dfrac{d^2}{x^2}} \\
        y^2 & = db-dx         &   \\
          E & = M\cdot\tikzmarknode{D}{C^2}    &   \\
        \end{aligned}$
\end{enumerate}
\begin{tikzpicture}[overlay, remember picture]
\draw[BC]   (A.north east) -- (A.east |- B.south);
\draw[BC]   (C.north east) -- (C.east |- D.south);
\end{tikzpicture}
\end{document}

经过至少两次编译后,上述 MWE 的结果是:

在此处输入图片描述

使用此解决方案,您可以更改括号的颜色。例如,通过设置将它们变为红色pen colour={red}

附录:
在某些情况下,当您希望花括号遵循某个等式时,只需将具有该等式的节点添加到花括号中:

\documentclass[fleqn, 12pt]{article}
\usepackage{mathtools}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing,%
                calligraphy,% had to be after decorations.pathreplacing
                tikzmark}
\tikzset{BC/.style  = {decorate,
            decoration={calligraphic brace, amplitude=6pt,
                        pre =moveto, pre  length=1pt,
                        post=moveto, post length=1pt,
            raise = 6pt,
                    #1},% for mirroring of brace, if needed
            ultra thick,
            pen colour={black}},
        }

\begin{document}
\begin{enumerate}
    \item
    $\begin{aligned}[t]
          y & = \dfrac{d}{x} \, \Rightarrow \, y^2 = \tikzmarknode{A}{\dfrac{d^2}{x^2}} \\
        y^2 & = db - \tikzmarknode{B}{dx}          \\
        \end{aligned}$
\end{enumerate}
    \begin{tikzpicture}[overlay, remember picture]
\draw[BC]   (A.north east) -- node[right=5mm] {$\dfrac{d^2}{x^2}=db-dx$} (A.east |- B.south);  % <---
    \end{tikzpicture}
\end{document}

在此处输入图片描述

答案3

提出这个想法作为解决方法。取决于您的实际用途,此方法可能不起作用。一定有更好的解决方案。

使用tabularenv 在不同的行中输入方程式,并使用multirowresizebox输入合适大小的右括号。

以下是代码:

\documentclass[fleqn, 12pt]{article}
\usepackage{amsmath}
\usepackage{multirow}
\usepackage{graphicx}

\begin{document}

\begin{enumerate}
    \item\renewcommand{\arraystretch}{1.8}
    \begin{tabular}[t]{l@{}l}
        $\displaystyle y=\frac{d}{x} \, \Rightarrow \, y^2=\frac{d^2}{x^2}$&\multirow{2}{*}{\resizebox{11pt}{28pt}{\}}}\\
        $y^2=db-dx$\\
        \end{tabular}
    \item         
    \begin{tabular}[t]{l@{}l}
        $\displaystyle y=\frac{d}{x} \, \Rightarrow \, y^2=\frac{d^2}{x^2}$&\multirow{3}{*}{\resizebox{11pt}{48pt}{\}}}\\
        $y^2=db-dx$\\
        $E=M\cdot C^2$\\
    \end{tabular}
\end{enumerate}
\end{document}

在此处输入图片描述

相关内容