0

When compiling the code

\documentclass{article}
\usepackage{chemnum}
\begin{document}

\cmpd*[label-format=\bfseries\textsuperscript,pre-label-code=\textbf{Me\textsubscript{2}L}]{Me2bdc}
\resetcmpd[1]
\cmpd*[label-format=\bfseries\textsuperscript,pre-label-code=\textbf{H\textsubscript{2}L}]{H2bdc}

\cmpd{Me2bdc} and \cmpd{H2bdc}

\cmpd[format=\bfseries\textsuperscript]{Me2bdc} and \cmpd[format=\bfseries\textsuperscript]{H2bdc}

\end{document}

using pdflatex, the following will be rendered:

global definition vs. local definition of '1' formatting

where the second line represents what was intended here.

According to the chemnum manual, label-format should be used to alter a label's property, while format is used where the display of individual instances of \cmpd is to be altered locally. However, the definition of label-format=\bfseries\textsuperscript seems to have no effect on the diplay of 1 (see first line). Only when format=\bfseries\textsuperscript is used during calling the respective compound, the formatting will take place (second line). What am I getting wrong here? Using chemnum 1.2c from an up-to-date TeX Live 2019.

1
1

This is a misinterpretation or misunderstanding of the manual.

label-format is a property of a compound but not an option which can be set. Compound properties cannot be set directly by a user.

The option is called format and acts globally when used with \setchemnum and locally when used as option to \cmpd.

So the answer is: use \setchemnum{format=\bfseries\textsuperscript}.

If you want to restrict this to only a few compounds you either need to set the format again after declaring the compounds or use a group: this works because option setting is local to grouping but compounds are always defined globally.

\documentclass{article}
\usepackage{chemnum}

\begin{document}

\begingroup
\setchemnum{format=\bfseries\textsuperscript}
\cmpd*[pre-label-code=\textbf{Me\textsubscript{2}L}]{Me2bdc}
\resetcmpd
\cmpd*[pre-label-code=\textbf{H\textsubscript{2}L}]{H2bdc}
\endgroup

\cmpd{Me2bdc} and \cmpd{H2bdc}

\end{document}

enter image description here


It might be reasonable to be able to set the property label-format compoundwise when the the label is declared. For this an option would probably be useful (and it could be called label-format). If this sounds like a useful feature to you please feel free to open a feature request on github.

1
  • Thanks for clarifying. I've added a feature request here. While the rendering of labels within text works as intended now using the grouping approach suggested by you, I'm still having trouble to realize differently styled labels generated by replacing tags in eps files. – tstone-1 Feb 7 '20 at 21:31

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.