答案1
补充 2014/03/14:
两天前,v1.0chemnum
发布了。其中有各种变化。其中之一是内置了以下情况的可能性:
\documentclass{book}
\usepackage{chemnum}
\makeatletter
% new counter format for chemnum:
\newcmpdcounterformat{chapter}{\thechapter.\@arabic}
\makeatother
\setchemnum{
counter-within = chapter ,
counter-format = chapter % use new counter format
}
\begin{document}
\chapter{First}
\cmpd{a} and \cmpd{b}
\chapter{Second}
\cmpd{a} and \cmpd{c}
\end{document}
原始答案:
基于的临时解决方案Heiko 的回答:
\documentclass{book}
\usepackage{chemnum}
\ExplSyntaxOn
\cs_new:Npn \int_to_chapter:n
{ \thechapter . \int_to_arabic:n }
% add the new choice to the options:
\keys_define:nn { chemnum }
{
cmpd-counter .generate_choices:n =
{ arabic , alph , Alph , greek, Greek , roman , Roman , Symbol , chapter }
}
\ExplSyntaxOff
% choose the new option:
\cmpdsetup{cmpd-counter=chapter}
% reset counter every new chapter:
\usepackage{etoolbox}
\preto\chapter{\cmpdreset}
\begin{document}
\chapter{First}
\cmpd{a} and \cmpd{b}
\chapter{Second}
\cmpd{a} and \cmpd{c}
\end{document}
答案2
添加章节编号的技巧:
\documentclass{book}
\usepackage{chemnum}
\begingroup
\makeatletter
\catcode`\_=11 %
\catcode`\:=11 %
\global\let\org@cmpd\cmpd
\gdef\cmpd#1{%
\begingroup
\cmpdsetup{cmpd-counter=Symbol}%
\def\int_to_Symbol:n{%
\thechapter.\int_to_arabic:n
}%
\org@cmpd{#1}%
\endgroup
}%
% reset numbers at chapters
\@firstofone{\endgroup
\let\c@chemnum@counter\g__chemnum_cmpd_int
\@addtoreset{chemnum@counter}{chapter}%
}
\endgroup
\begin{document}
\chapter{First}
\cmpd{a} and \cmpd{b}
\chapter{Second}
\cmpd{a} and \cmpd{c}
\end{document}
结果:
第1章:1.1和1.2
第2章:1.1和2.1