我想用 tikzducks 包中的 tikz 鸭子来标记和等式,稍后再参考它,如下所示:
显而易见的解决方案:
\usepackage{tikz}
\usepackage{tikzducks}
\usepackage{amsmath}
\section*{Question 1}
\begin{enumerate}[(a)]
\item
\[a^{2} + b^{2} = c^{2} \tag{$\begin{tikzpicture}[scale=0.2]
\duck
\end{tikzpicture}$} \label{C}\]
From equation \(\eqref{C}\), $b^{2} = c^{2} - a^{2}$.
\end{enumerate}
给出错误:TeX 容量超出,抱歉 [输入堆栈大小=5000]。但是,当我将鸭子放在图像的其他位置时,没有出现此错误,文档编译成功,我可以看到我的鸭子(嘎嘎叫)!
(我想补充一点,tikzpicture 环境是否放置在数学模式内并不重要。)
我似乎找不到办法来阻止此错误发生。
感谢您看我的问题。
答案1
\documentclass{article}
\usepackage{tikz}
\usepackage{tikzducks}
\usepackage{amsmath}
\usepackage{xparse}
\usepackage{enumerate}
\NewDocumentCommand\ducktag{}
{%
\begin{tikzpicture}[scale=0.2]
\duck
\end{tikzpicture}%
}
\begin{document}
\section*{Question 1}
\begin{enumerate}[(a)]
\item
\[a^{2} + b^{2} = c^{2} \tag{\ducktag} \label{C} \]
From equation \eqref{C}, $b^{2} = c^{2} - a^{2}$.
\end{enumerate}
\end{document}
您还可以为选项添加参数:
\documentclass{article}
\usepackage{tikz}
\usepackage{tikzducks}
\usepackage{amsmath}
\usepackage{xparse}
\usepackage{enumerate}
\NewDocumentCommand\ducktag{m}
{%
\begin{tikzpicture}[scale=0.2]
\duck[#1]
\end{tikzpicture}%
}
\begin{document}
\section*{Question 1}
\begin{enumerate}[(a)]
\item
\[a^{2} + b^{2} = c^{2} \tag{\ducktag{}} \label{B} \]
From equation \eqref{C}, $b^{2} = c^{2} - a^{2}$.
\item
\[a^{2} + b^{2} = c^{2} \tag{\ducktag{body=blue}} \label{C} \]
From equation \eqref{C}, $b^{2} = c^{2} - a^{2}$.
\item
\[a^{2} + b^{2} = c^{2} \tag{\ducktag{body=red}} \label{D} \]
From equation \eqref{B}, \eqref{C} and \eqref{D} $b^{2} = c^{2} - a^{2}$.
\end{enumerate}
\end{document}