%20(b)%20%E6%A8%99%E8%AA%8C%EF%BC%9F.png)
我想要兩個 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}
編譯結果和之前一樣。