这个问题有很好的答案,如下:
再次感谢大家。
但是文本对变化非常敏感,所以当我尝试改变人们的建议时,我会收到错误消息。
因此我创建了最小的 MWE:
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usepackage{hyperref, longtable, tabu, booktabs}
\usetikzlibrary{arrows.meta,shapes.arrows}
\usepackage{tikz-cd}
\begin{document}
\begin{figure}[h]
\begin{equation*} \label{eqn-commutative}
\begin{tikzcd}[row sep=huge, column sep=width("bbbbbbbbbbbbbbbbbbbbbbb")]
A \arrow[r, "\qquad \qquad \qquad \quad \mathrm{some \; text \; here} \hspace{3cm}"]
\arrow[d, "\mathrm{some \, down \, text \, here}" swap] & \arrow[d, "\mathrm{some \, down \, text \, here}" ] B \\
C & D \arrow[l, "\qquad \qquad \qquad \quad \mathrm{some \; text \; here} \hspace{3cm}" ] \\
\end{tikzcd}
\end{equation*}
\vspace{-1.5cm}
\caption{Figure caption here}
\label{figure-commutative}
\end{figure}
In place of the "A" I would like the following:
\begin{equation} \label{eq:1}
\left\{\begin{array}{rl}
\sup & c^T x \\
s.t. & Ax \leq b.
\end{array} \right.
\end{equation}
with equation label adjusted to left.
In place of the "B" I would like the following:
\begin{equation} \label{eq:2}
\left\{\begin{array}{rl}
\sup & f^T x \\
s.t. & Dx \leq e.
\end{array} \right.
\end{equation}
with equation label adjusted to left.
Then I would like to reference \eqref{eq:1} and \eqref{eq:2} here.
\end{document}
答案1
我会为此定义一个合适的命令。请注意,您不必猜测单个大块的宽度。
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz-cd}
\makeatletter
\newcommand{\nodeequation}[1]{%
\let\label\ltx@label
\refstepcounter{equation}%
(\theequation)%
\quad#1%
}
\makeatother
\begin{document}
\begin{equation*}
\begin{tikzcd}[row sep=4em,column sep=10em,ampersand replacement=\&]
\nodeequation{
\label{eq:1}
\begin{cases}
\begin{alignedat}{2}
&\sup &\quad& c^T x \\
&\,\text{s.t.} &\quad& Ax \leq b.
\end{alignedat}
\end{cases}
}
\arrow[r,"\text{some text here}"] \arrow[d,swap,"\text{some text here}"] \&
\nodeequation{
\label{eq:2}
\begin{cases}
\begin{alignedat}{2}
&\sup &\quad& f^T x \\
&\,\text{s.t.} &\quad& Dx \leq c.
\end{alignedat}
\end{cases}
}
\arrow[d,"\text{some text here}"]
\\
C \& D \arrow[l,"\text{some text here}"]
\end{tikzcd}
\end{equation*}
The references are \eqref{eq:1} and \eqref{eq:2}. Another equation to see
that the number is right
\begin{equation}
0=0
\end{equation}
\end{document}
答案2
这是一个建议。左边和右边的方程数字回到大卫·卡莱尔的回答。因此,只需将这些方程式压缩到小页面中即可。并且,无需使用\quad
和\hspace
集合,只需使用pos=...
以移动文本即可,顺便说\text
一句,使用它们排版要简单得多。
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz-cd}
\usepackage{hyperref}
% https://tex.stackexchange.com/a/212099/121799
\makeatletter
\newcommand{\leqnomode}{\tagsleft@true\let\veqno\@@leqno}%
\newcommand{\reqnomode}{\tagsleft@false\let\veqno\@@eqno}%
\newcommand*{\compress}{\@minipagetrue}
\makeatother
\begin{document}
\begin{figure}[h]
\begin{equation*}
\begin{tikzcd}[row sep=huge, column sep=width("bbbbbbbbbbbbbbbbbbbbbbb"),
ampersand replacement=\&]
\begin{minipage}{4cm}
\leqnomode
\begin{equation} \label{eq:1}
\left\{\begin{array}{rl}
\sup & c^T x \\
s.t. & Ax \leq b.
\end{array} \right.
\end{equation}
\end{minipage}
\arrow[r, "\text{some text here}" pos=0.5]
\arrow[d, "\text{some down text here}" swap] \&
\arrow[d, "\text{some down text here}" ]
\begin{minipage}{4cm}
\begin{equation} \label{eq:2}
\left\{\begin{array}{rl}
\sup & f^T x \\
s.t. & Dx \leq e.
\end{array} \right.
\end{equation}
\end{minipage}\\
C \& D
\arrow[l, "\text{some text here}" pos=0.4 ] \\[-1cm]
\end{tikzcd}
\end{equation*}
\caption{Figure caption here.}
\label{figure-commutative}
\end{figure}
Then I would like to reference \eqref{eq:1} and \eqref{eq:2} here.
\end{document}