我想要两个 tikz 图形具有以下示例格式,其中(a)
和(b)
位于它们最左侧。
示例参考:Cormen/Introduction to Algorithms 2022 页码:341
请注意,我只对放置(a)
、、、... 标签感兴趣。(b)
(c)
我想到的解决方案是使用 如何标记/标记 TikZ 图表?。但在这里我无法将方程编号改为(2)
和(a)
改为(3)
,(b)
也无法将它们的位置改为最左边。
我的 tex 代码:
\documentclass{article}
\usepackage{tikz-cd}
\usepackage{blindtext}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\setcounter{page}{15}
\noindent
\begin{equation}
\begin{tikzcd}
x = 5 * 5; \\
\end{tikzcd}
\end{equation}
into a commutative diagramm
\begin{equation}
\begin{tikzcd}
B\times_A C \arrow{r}{\pi_2}\arrow{d}[swap]{\pi_1} & C\arrow{d}{g} \\
B \arrow{r}[swap]{f} & A;
\end{tikzcd}
\end{equation}
\begin{equation}
\begin{tikzpicture}[compute/.style={draw,thick,font=\sffamily,
append after command={
(\tikzlastnode.south west) edge[double=gray!50,double distance=3pt,
line cap=rect,
shorten >=-2pt,shorten <=-2pt]
(\tikzlastnode.south east)}}]
\node[compute] (n1) {Node};
\node[compute,right=2cm of n1] (n2) {More text};
\draw[thick,-stealth] (n1) -- (n2);
\end{tikzpicture}
\end{equation}
\end{document}
输出:
想要的输出:
答案1
我猜您想获得以下内容:
使用@Andrew Swann回答你可以写:
\documentclass{article}
\usepackage{lipsum}
\usepackage{amsmath}
\makeatletter
\newcommand{\leqnos}{\tagsleft@true\let\veqno\@@leqno}
\newcommand{\reqnos}{\tagsleft@false\let\veqno\@@eqno}
\reqnos
\makeatother
\newcounter{eqtn}
\usepackage{tikz-cd}
\usetikzlibrary{positioning}
\begin{document}
\setcounter{page}{15}
\begin{equation}
a^2 + b^2 = c^2
\end{equation}
\lipsum[3][1-3]
\begingroup\leqnos
\setcounter{eqtn}{\theequation}
\setcounter{equation}{0}
\renewcommand\theequation{\alph{equation}}
\begin{equation}
\begin{tikzcd}
x = 5 * 5; \\
\end{tikzcd}
\end{equation}
into a commutative diagramm
\begin{equation}
\begin{tikzcd}
B\times_A C \arrow{r}{\pi_2}\arrow{d}[swap]{\pi_1} & C\arrow{d}{g} \\
B \arrow{r}[swap]{f} & A;
\end{tikzcd}
\end{equation}
\begin{equation}
\begin{tikzpicture}[compute/.style={draw,thick,font=\sffamily,
append after command={
(\tikzlastnode.south west) edge[double=gray!50,double distance=3pt,
line cap=rect,
shorten >=-2pt,shorten <=-2pt]
(\tikzlastnode.south east)}}]
\node[compute] (n1) {Node};
\node[compute,right=2cm of n1] (n2) {More text};
\draw[thick,-stealth] (n1) -- (n2);
\end{tikzpicture}
\end{equation}
\setcounter{equation}{\theeqtn}
\endgroup
\lipsum[66]
\begin{equation}
a^2 + b^2 = c^2
\end{equation}
\end{document}
我想知道为什么你不使用该sidcap
包并使用例如
\begin{SCfigure}
\includegraphics{image}
\caption{A figure and its caption framed}
\label{fig:test}
\end{SCfigure}
并按照与上述类似的方式更改标题编号。
编辑: 通过手动标记方程来简化代码:
\documentclass{article}
\usepackage{lipsum}
\usepackage{amsmath}
\makeatletter
\newcommand{\leqnos}{\tagsleft@true\let\veqno\@@leqno}
\newcommand{\reqnos}{\tagsleft@false\let\veqno\@@eqno}
\reqnos
\makeatother
\usepackage{tikz-cd}
\usetikzlibrary{positioning}
\begin{document}
\setcounter{page}{15}
\begin{equation}
a^2 + b^2 = c^2
\end{equation}
\lipsum[1][1-3]
\begingroup\leqnos
\begin{equation}
\begin{tikzcd}
x = 5 * 5; \tag{a}\\
\end{tikzcd}
\end{equation}
into a commutative diagramm
\begin{equation}
\begin{tikzcd}
B\times_A C \arrow{r}{\pi_2}\arrow{d}[swap]{\pi_1} & C\arrow{d}{g} \\
B \arrow{r}[swap]{f} & A;
\end{tikzcd} \tag{b}
\end{equation}
\begin{equation}
\begin{tikzpicture}[compute/.style={draw,thick,font=\sffamily,
append after command={
(\tikzlastnode.south west) edge[double=gray!50,double distance=3pt,
line cap=rect,
shorten >=-2pt,shorten <=-2pt]
(\tikzlastnode.south east)}}]
\node[compute] (n1) {Node};
\node[compute,right=2cm of n1] (n2) {More text};
\draw[thick,-stealth] (n1) -- (n2);
\end{tikzpicture} \tag{a}
\end{equation}
\endgroup
\lipsum[66]
\begin{equation}
a^2 + b^2 = c^2
\end{equation}
\end{document}
编译结果和以前相同。