2

I want to have my numbered compounds in bold throughout my text but I want them to have a different format when used in section headers. I tried using the command \cmpd+[format=\normalfont]{label} but the format option doesn't work with \cmpd+ (or \refcmpd).

MWE:

\documentclass{report}
\usepackage{chemnum}
\usepackage{titlesec}

\titleformat{\section}{\slshape}{\thesubsection}{1em}{}{}

\begin{document}

    \section{Preparation of \cmpd+{compoundA}}

    We made \cmpd{compoundA}.

    \section{Preparation of \cmpd+[format=\slshape]{compoundA}}

We made \cmpd{compoundA}.

\section{Preparation of \cmpd[format=\slshape]{compoundA}}

We made \cmpd{compoundA}.

\end{document}

Is there a way to get the format options to work with \cmpd+?

As mentioned in the comments the problem arises when one wants a Table of Contents. My format style prevents me from using bold in the table of contents, yet the compound numbers should be bolded in the text. Clearly I must use \cmpd+ to avoid numbering the compound at the beginning, but no matter what I do it does not take any format arguments.

ralk912
  • 478
  • Maybe a workaround could be to define the compounds before the section with \cmpd* and then use the formatted \cmpd in the section title (and subsequently the regular \cmpd in the section text)? – Marijn May 28 '19 at 14:00
  • Well that's a smart suggestion! I guess writing your thesis burns more brain cells than I thought. I'll leave this open just in case someone else wants to do something about it, but that's definitely a viable alternative. – ralk912 May 28 '19 at 14:02
  • @Marijn Maybe I replied to quickly. The point of using \cmpd+ was to avoid it defining the compound in the Table of Contents, which is what I'm having trouble with. – ralk912 Jun 15 '19 at 02:36

1 Answers1

1

Well I was just reading more on the chemnum manual and you can go around with the \cmpdplain command and just format the text however you want. So instead of \cmpd+[format=\itseries]{foo} you can use \textit{\cmpdplain{foo}}. Not exactly brilliant but it works for me at least.

ralk912
  • 478