# How to put compound names in braces globally with chemnum?

My supervisor would like my compounds refrences in the form (1), (2), (3).

Using numbers is easy: drop \setchemnum{counter-format=arabic} in the preamble. But I can't figure out brackets. The manual has an example on pg 18 that gives exactly the output I want:

\cmpd[pre-label-code=(,post-label-code=)]{x, y, z.one }

But, as per pg 12--13, these are "cmpd" options, and thus I'd have to specify them for each and every compound, the first time I reference it. Is there a way to specify this globally that I'm not seeing, so I don't have to worry about which reference is the first one, and worry about missing one, assigning it each time, and so on?

• Something like \newcommand*\cmpdformat[1]{(\textbf{#1})} and \setchemnum{format=\cmpdformat} should work. – clemens May 9 '16 at 23:42
• @clemens: OK, I'll remove my comment. – Bernard May 10 '16 at 0:00
• My idea works but only for labels without sublabels… – clemens May 10 '16 at 8:09
• @clemens That works. You should make it an answer so I can accept it. Thank you! – Canageek May 10 '16 at 18:41
• @Canageek I already added a (better) answer :) My suggestion in the comment will not work for labels with sublabels like \cmpd{main.sub} – clemens May 10 '16 at 18:43

Actually I don't know any more why I didn't make pre-label-code and post-label-code generally available. I'll change this in future versions. For the time being you can make the change yourself and then just set them via \setchemnum:

\documentclass{article}

\usepackage{chemnum}

% adding the pre- and post- options to the general' group makes
% them generally available; they should keep the compound' group,
% though, too:
\ExplSyntaxOn
\keys_define:nn {chemnum}
{
pre-label-code  .groups:n = {compound,general} ,
post-label-code .groups:n = {compound,general}
}
\ExplSyntaxOff

\setchemnum{
pre-label-code = ( ,
post-label-code = )
}

\begin{document}

\cmpd+{a,h}

\cmpd{a,b,c,d.1,e,f.{1,2},g}

\cmpd[pre-label-code=,post-label-code=]{h}

\cmpd{a,h}

\end{document}