如何仅将对齐方程组的一部分放在框内

如何仅将对齐方程组的一部分放在框内

我有以下对齐方程组

\begin{subequations}\label{1}
\begin{align}
&A=B=C\label{a}\\
&D=E=F\label{b}
\end{align}}
\end{subequations}

我想把部分

A=B

德=埃

在一个盒子里,留下

=C

=F

盒子外面。

例如,可以使用 empheq 来完成此操作吗?

答案1

带有 的简短代码pstricks。我将每行中的第一个=符号定义为节点,并使用\ncbox节点连接将它们连接起来,并使用相关参数:

\documentclass[svgnames]{article}
\usepackage{amsmath}

\usepackage{pst-node}
\usepackage{auto-pst-pdf} %% for pdflatex compilation

\begin{document}

\begin{subequations}\label{1}
\begin{postscript}
\begin{align}
A& \mathrel{\Rnode{beg}{=}}B=C\label{a}\\
D & \mathrel{\Rnode{end}{=}}E=F\label{b}
\end{align}
\ncbox[boxsize=0.57, nodesepA=1.5ex, nodesepB=0.8ex, linecolor=IndianRed]{beg}{end}
\end{postscript}
\end{subequations}

\end{document} 

在此处输入图片描述

答案2

这是代码:

\documentclass{article}
\usepackage{amsmath}

\usepackage{tikz}
\usetikzlibrary{calc,shapes}

\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node (#1) {};}
\newcommand{\DrawRect}[3]{%
  \begin{tikzpicture}[overlay,remember picture]
    \draw[#3] ([yshift=8pt,xshift=4pt]#1.north west) rectangle ([yshift=0pt,xshift=-4pt]#2.south east);
  \end{tikzpicture}
}

\begin{document}

\begin{subequations}\label{1}
\begin{align}
&\tikzmark{Begin}A=B=C\label{a}\\
&D=E\tikzmark{End}=F\label{b}
\end{align}
\end{subequations}
\DrawRect{Begin}{End}{green}
\end{document}

输出结果如下:

在此处输入图片描述

针对更复杂的情况进行编辑:

\documentclass{article}
\usepackage{amsmath}

\usepackage{tikz}
\usetikzlibrary{calc,shapes}
\makeatletter
\newcommand{\tikzmark}[2]{\tikz[overlay,remember picture] \node[xshift={\f@size/1.5},yshift={\f@size/3}] (#1) {\phantom{$#2$}};}
\makeatother

% #1 is the draw option (can contain decorate etc) #2 can be any shift option to be used for all points. #3 are the points in comma separated list. 
\def\DrawComplic#1#2#3{
\begin{tikzpicture}[overlay,remember picture]
   \draw[#1]\foreach \point[count=\i from 0] in {#3}{%
   \ifnum\i=0 ([#2]\point) \else --([#2]\point)\fi%
   }--cycle;
\end{tikzpicture}

}
\begin{document}

\begin{subequations}\label{1}
\begin{align}
f(x,y,z)&=\tikzmark{First}{A x}A x=B y=C z\label{a}\\
&=\tikzmark{Fourth}{D x}D x=\tikzmark{Third}{E y}E y=F z\label{b}\\
&=\tikzmark{Last}{F x}F x=G y\label{c}
\end{align}
\end{subequations}
\DrawComplic{red}{}{First.north west,First.north east,First.south east,Third.north east,Third.south east,Last.north east, Last.south east, Last.south west}
 \end{document}

输出:

在此处输入图片描述

相关内容