这是该答案的后续问题这里。当我将第一个方案与第二个方案结合时,文本中的编号出现了问题。如果我将文本放在位置一,编号是正确的。当我在第二个方案之后添加文本时,文本中的编号是错误的。
仅限位置 1:
仅限位置 2:
我以为第二个位置上得到的数字和第一个位置上得到的数字相同。哪里出了问题?
\documentclass{scrartcl}
\usepackage[utf8]{inputenc}
\DeclareNewTOC[
type=scheme,
types=schemes,
float,
name=Schema,
listname={Verzeichnis der Schemata}
]{los}
\usepackage[runs=2,crop=off]{auto-pst-pdf}
\usepackage{chemnum}
\setchemnum{format = \bfseries\sffamily}
\begin{document}
\begin{scheme}[htb]
\centering
\psfrag{TMP1}{\cmpd{mycompound.a}: M = Ti, n = 4}
\psfrag{TMP2}{\cmpd{mycompound.b}: M = Fe, n = 3}
\psfrag{TMP3}{\cmpd{mycompound.c}: M = Sn, n = 4}
\includegraphics{xyz}
\caption{My compounds. The replacement text is left aligned with respect to the placeholder text.}
\label{mycompounds}
\end{scheme}
%position1
%Compound \cmpd{mycompound.a, mycompound.b, mycompound.c} are my compounds.
\clearpage
\begin{scheme}[htb]
\centering
\replacecmpd{one}
\replacecmpd{two}
\replacecmpd{three}
\includegraphics{xyz}
\caption{second scheme}
\label{mycompounds2}
\end{scheme}
\cmpd{one, two, three}
%position2
Compound \cmpd{mycompound.a, mycompound.b, mycompound.c} are my compounds.
\end{document}
答案1
\cmpd
inside of 的使用psfrag
显然会弄乱相应化合物的启动/定义。您可以通过使用\cmpd*{<ID>}
inside ofscheme
环境自己定义新标签来防止这种情况,例如:
\begin{scheme}[htb]
\centering
\cmpd*{mycompound.a, mycompound.b, mycompound.c}
\psfrag{TMP1}{\cmpd{mycompound.a}: M = Ti, n = 4}
\psfrag{TMP2}{\cmpd{mycompound.b}: M = Fe, n = 3}
\psfrag{TMP3}{\cmpd{mycompound.c}: M = Sn, n = 4}
\includegraphics{xyz}
\caption{My compounds. The replacement text is left aligned with respect to the placeholder text.}
\label{mycompounds}
\end{scheme}
为了避免两次输入相同的ID,以及避免意外弄乱ID的顺序,您还可以定义自己的命令,如下所示:
\newcommand{\replacecmpdcomment}[3]{\cmpd*{#2}\psfrag{#1}{\cmpd{#2}: #3}}
然后您可以在文档中使用它,如下所示:
\replacecmpdcomment{<replacement tag>}{<compound's ID>}{<comment to be added>}
完整示例:
\documentclass{scrartcl}
\usepackage[utf8]{inputenc}
\DeclareNewTOC[
type=scheme,
types=schemes,
float,
name=Schema,
listname={Verzeichnis der Schemata}
]{los}
\usepackage[runs=2,crop=off]{auto-pst-pdf}
\usepackage{chemnum}
\setchemnum{format = \bfseries\sffamily}
\newcommand{\replacecmpdcomment}[3]{\cmpd*{#2}\psfrag{#1}{\cmpd{#2}: #3}}
\begin{document}
\begin{scheme}[htb]
\centering
\replacecmpdcomment{TMP1}{mycompound.a}{M = Ti, n = 4}
\replacecmpdcomment{TMP2}{mycompound.b}{M = Fe, n = 3}
\replacecmpdcomment{TMP3}{mycompound.c}{M = Sn, n = 4}
\includegraphics{xyz}
\caption{My compounds. The replacement text is left aligned with respect to the placeholder text.}
\label{mycompounds}
\end{scheme}
%position1
%Compound \cmpd{mycompound.a, mycompound.b, mycompound.c} are my compounds.
\clearpage
\begin{scheme}[htb]
\centering
\replacecmpd{one}
\replacecmpd{two}
\replacecmpd{three}
\includegraphics{xyz}
\caption{second scheme}
\label{mycompounds2}
\end{scheme}
\cmpd{one, two, three}
%position2
Compound \cmpd{mycompound.a, mycompound.b, mycompound.c} are my compounds.
\end{document}