![chemnum 中子化合物的自定义后缀](https://linux22.com/image/379349/chemnum%20%E4%B8%AD%E5%AD%90%E5%8C%96%E5%90%88%E7%89%A9%E7%9A%84%E8%87%AA%E5%AE%9A%E4%B9%89%E5%90%8E%E7%BC%80.png)
我使用 chemnum 来跟踪论文中的化合物,在某些情况下,我有一组化合物,它们之间的区别在于一个取代基。理想情况下,我希望能够定义用于子化合物的后缀,如下所示:
\documentclass{article}
\usepackage{chemnum}
\setchemnum{replace-style=\bfseries}
\begin{document}
A class of compounds \cmpd{substituted} can have several R groups as substituents.
I would like \cmpd{substituted.methyl} and \cmpd{substituted.phenyl} to appear as
\cmpd{substituted}$\cdot$Me and \cmpd{substituted}$\cdot$Ph both here in the text
and when using \replacecmpd{} with my .ps files.
\end{document}
声明子化合物时,是否有办法编辑计数器表示?或者是否可以在声明子化合物后进行编辑?
谢谢!
答案1
我知道没有什么关于chemnum
和甚至更少关于 LaTeX3。但由于该软件包是用 LaTeX3 编写的,我尝试了一下,并想出了...一些东西。它不能完全回答你的问题,但可能会给你一些关于如何继续的想法。
我创建了一个新的标签格式,称为cmd
,它调用\blah:n
并cmd
作为子计数器的默认表示。该\blah:n
宏接受一个参数,将其转换为 ,Alph
并用 包裹\csname
它,这样第一个取代基就定义为\CMDA
,第二个取代基定义为\CMDB
,等等。如何让它在不同的主要群体等中发挥作用,远远超出了我的知识范围。
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{xparse}
\usepackage{chemnum}
\setchemnum{replace-style=\bfseries}
\def\CMDA{$\cdot$Me}
\def\CMDB{$\cdot$Ph}
\ExplSyntaxOn
\cs_new:Npn \blah:n #1 {\cs:w CMD\int_to_Alph:n #1\cs_end:}
\newcmpdcounterformat {cmd} { \blah:n }
\tl_set:Nn
\l__chemnum_default_subcounter_representation_tl
{cmd}
\ExplSyntaxOff
\begin{document}
\section{First}
A class of compounds \cmpd{substituted} can have several R groups as substituents.
I would like \cmpd{substituted.methyl} and \cmpd{substituted.phenyl} to appear as
\cmpd{substituted}$\cdot$Me and \cmpd{substituted}$\cdot$Ph both here in the text
and when using \replacecmpd{} with my .ps files.
\end{document}