3

I am currently writing my chemistry thesis, which is significantly focused on photoisomerisation. I am using chemnum for compound number. For example, here is azobenzene photoisomerisation: E-Z azobenzene photomerisation

As far as I am concerned, TMP1 is a single chemical compound and should be assigned a single label (say \cmpd{azobenzene} = 1). Within text, I would then like to be able to refer to the E or Z photoisomers as E-1 or Z-1. I can kind-of fake this by defining the compound \cmpd{azobenzene} and then manually calling $E$-\cmpd{azobenzene} or $Z$-\cmpd{azobenzene}, but this breaks down when it comes to renaming tags in .eps chemical structures (like the one shown above): unless there's some way to manually specify or modify the text chemnum uses to replace a temporary tag in an EPS file, there's no way to preface the compound numbers with E- or Z- as required.

As far as I can tell, my options are to either give each isomer a different numerical label (unacceptable) or label them as subcompounds with something like

\replacecmpd[tag=E-TMP1]{azobenzene.E}
\replacecmpd[tag=Z-TMP1]{azobenzene.Z}

which would allow me to call Compounds \cmpd{azobenzene.E}, \cmpd{azobenzene.Z} as

Compounds 1a, 1b

which is still incorrect, unless there's a way to redefine chemnum's subcompound logic replace lowercase latin suffices with E/Z prefixes.

Can anyone suggest a solution?

Edit: on playing around a little bit, this seems to be an ok solution to my problem:

\replacecmpd[tag=ETMP,pre-label-code=\textit{E-}]{Eazobenzene}
\resetcmpd[\cmpdproperty{Eazobenzene}{number}]
\replacecmpd[tag=ZTMP,pre-label-code=\textit{Z-}]{Zazobenzene}
\includegraphics{azobenzenes.eps}

Compounds \cmpd{Eazobenzene} and \cmpd{Zazobenzene}.

Compounds E-1 and Z-1.

This is acceptable, if a little clunky. Is there a better option?

1 Answers1

1

It looks like you've already found a working solution. :)

I propose another solution using a command \setcmpdlabel that I first used in another answer (and which I should probably add to chemnum as it proves useful again and again…).

\documentclass{article}
\usepackage{chemnum}

\ExplSyntaxOn
\NewDocumentCommand \setcmpdlabel {mm}
  { \chemnum_compound_set_property:nnn {#1} {counter-representation} {#2} }
\ExplSyntaxOff

\newcommand*\defineEZcmpds[1]{%
  \cmpd*{#1}\cmpd*{E#1}\cmpd*{Z#1}%
  \setcmpdlabel{E#1}{\textit{E}-\cmpd{#1}}%
  \setcmpdlabel{Z#1}{\textit{Z}-\cmpd{#1}}%
}

\begin{document}

% defining
\defineEZcmpds{azobenzene}

% and using
Compounds \cmpd{Eazobenzene} and \cmpd{Zazobenzene} are the two photoisomers 
of \cmpd{azobenzene}.

\end{document}

enter image description here

cgnieder
  • 66,645
  • That seems a little neater, so thank you. It still faces a difficulty in referring to the parent compound generally. My workaround right now is to use \textbf{\cmpdproperty{Eazobenzene}{counter-representation}}, e.g.: \cmpd{Eazobenzene} and \cmpd{Zazobenzene} are the two photoisomers of \textbf{\cmpdproperty{Eazobenzene}{counter-representation}}. to receive "E-1 and Z-1 are the two photoisomers of 1." Which is quite awkward, I think you'd agree. Perhaps in future an extension of the chemnum subcompound logic could be considered? – Thomas MacDonald Feb 22 '20 at 04:30
  • @ThomasMacDonald It doesn't, see my updated answer. – cgnieder Feb 22 '20 at 09:25
  • Very nice! Thanks, and marked as answered. I still think that generalisable subcompound labelling for prefixes would be a good feature to add at some point: E/Z, R/S/rac, fac/mer, cis/trans, Δ/Λ, etc etc. – Thomas MacDonald Feb 22 '20 at 12:37
  • @ThomasMacDonald all these are prefixes and I agree that there should be a mechanism. I think something along the lines of my answer here could be implemented (in a somewhat more generic way) in chemnum. I opened an issue so I don't forget: https://github.com/cgnieder/chemnum/issues/14 – cgnieder Feb 22 '20 at 20:15
  • One more correction needed: your defined command doesn't reset compound numbering after it's done, so if two EZcompounds are defined sequentially they'll be numbered 1 and 4 (and the next compound will be 7). My solution is to add \resetcmpd[\cmpdproperty{#1}{number}+1]% to the end of the \defineEZcmpds{} command definition. – Thomas MacDonald Feb 23 '20 at 03:31
  • @ThomasMacDonald yes, of course. I was just outlining an idea... – cgnieder Feb 23 '20 at 07:41