2

I'm using chemnum to keep track of my compounds in my thesis, and there are certain instances where I have a group of compounds that differ by a single substituent. Ideally, I would like to be able to define the suffixes used for subcompounds like so:

\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} 

Is there any way to edit the counter representation when declaring a subcompound? Or can it be edited after subcompound declaration?

Thanks!

1

I know nothing about chemnum and EVEN LESS about LaTeX3. But since the package is written in LaTeX3, I played with things a bit, and came up with...something. It doesn't answer your question fully, but may give you ideas on how to proceed.

I created a new label format called cmd that calls upon \blah:n and made cmd the default representation for sub-counters. The \blah:n macro takes an argument, converts it to Alph and wraps a \csname around it, so that the first substituent is defined with \CMDA, the second with \CMDB, etc. How to make this work across different primary groups etc. is well beyond the scope of my knowledge.

\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} 

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.