如何使用 chemnum 定義一個帶有單獨計數器的新臨時標籤?

如何使用 chemnum 定義一個帶有單獨計數器的新臨時標籤?

有沒有辦法使用 chemnum 在.eps文件中建立不同類型的 TMP 標籤,然後可以在文字中用單獨的標籤/編號替換該標籤?

例如,我有許多 chemdraw 在文本中編號(1、2、3...),但我想為配體有一個單獨的標籤,並有自己的計數器(L1、L2、L3...)。

謝謝

\documentclass{article}

\usepackage{graphicx}
\usepackage[crop=off]{auto-pst-pdf}
\usepackage{chemnum}
\setchemnum{init,log=verbose}

% regular labels
\initcmpd{1,2,3.a}

% ligands
\resetcmpd
\initcmpd[pre-label-code=\textbf{L}]{L1.a,L2,L3.a}

\begin{document}

\begin{center}
\cmpdref{compound1} %replaces TMP1
\cmpdref{compound2} %replaces TMP2
\includegraphics{scheme.eps}
\end{center}

Here are two compounds: \refcmpd{compound1} and \refcmpd{compound2}.

\begin{center}
\setchemnum{replace-tag=L}
\cmpdref[tag=L1]{ligand1} 
\includegraphics{ligand.eps}
\end{center}

Here is a ligand: \refcmpd{ligand1}

\end{document}

答案1

編輯:

再讀問題我相信你的問題不是關於標籤被替換但有一組不同的標籤?你可能應該發布一個完整的 MWE 來說明你想要什麼...

pre-label-code但是,您可以透過在定義第二組標籤之前重設計數器並設定 a 來取得兩組標籤。 (這與 EPS 檔案的標籤替換完全無關!)如果您在文件中執行此操作,則必須注意將變更保留在本機或在定義新標籤後再次撤銷設定。在序言中定義它們會更容易:

\documentclass{article}

\usepackage{chemnum}
\setchemnum{init,log=verbose}

% regular labels
\initcmpd{1,2,3.a}

% ligands
\resetcmpd
\initcmpd[pre-label-code=\textbf{L}]{L1.a,L2,L3.a}

\begin{document}
Here are two compounds: \cmpd{1} and \cmpd{2}.

Here are two ligands: \cmpd{L1.a} and \cmpd{L2}.

Here we have \cmpd{1} and \cmpd{2} again.

And now \cmpd{3.a}. Again \cmpd{2} but then \cmpd{L3.a}.
\end{document}

在此輸入影像描述

原答案:

chemnum為此提供了手段。標準行為是替換標籤等TMP1TMP2編號是本地的。這意味著如果\replacecmpd在一個群組中使用(我猜通常是一個環境),它會TMP1再次從下一個數字開始。 (以下範例使用chemnumv1.0 語法。)

\documentclass{article}
\usepackage{graphicx,auto-pst-pdf,chemnum}
\begin{document}

\begin{center}
  \replacecmpd{compound1}% replaces TMP1
  \replacecmpd{compound2}% replaces TMP2
  \includegraphics{myscheme.eps}
\end{center}

\end{document}

改變這種情況的一種方法是根據具體情況進行:

\documentclass{article}
\usepackage{graphicx,auto-pst-pdf,chemnum}
\begin{document}

\begin{center}
  \replacecmpd[tag=L1]{compound1}% replaces L1
  \replacecmpd[tag=L2]{compound2}% replaces L2
  \includegraphics{myscheme.eps}
\end{center}

\end{document}

但您也可以TMP使用選項來變更標籤的部分:

\documentclass{article}
\usepackage{graphicx,auto-pst-pdf,chemnum}
\begin{document}

\begin{center}
  \setchemnum{replace-tag=L}
  \replacecmpd{compound1}% replaces L1
  \replacecmpd{compound2}% replaces L2
  \includegraphics{myscheme.eps}
\end{center}

\end{document}

相關內容