I have a problem using \cmpd in a heading, that is too long. For some weird reason, the compound number gets put on a new line, even though there is no need. I already have a workaround using ~, but this is not what I want. A little explanation: within \iupac{} you can add a possible breakpoint using \|. As you will see, the linebreak will be placed after (hydroxy), but the (1) will be put on a new line. I inserted two headings. The first is the one, giving me a headache, the second one is working fine. The fourth is the workaround.

Here is my (almost) MWE:


\usepackage[english]{babel} % Silbentrennung, etc.
\usepackage{chemnum} % provides \cmpd{Name.Sub}
\usepackage{chemmacros} % provides iupac and loads siunitx


\subsection{\iupac{\tert\-Butyl 2\-((\S\-2,2\-dimethyl\-1,3\-dioxolan\-4\-yl)\|(hy\|droxy)\|methyl)\|acryl\|ate} (\cmpd{iPrtBuAcrylate})}
Problematic subsection heading.

\subsection{\iupac{Sodium \S\-2,2\-dimethyl\-1,3\-dioxolane\-4\-carboxylate} (\cmpd{iPrCarboxylate})}
Working subsection heading.

\subsection{\iupac{\tert\-Butyl 2\-((\S\-2,2\-dimethyl\-1,3\-dioxolan\-4\-yl)\|(hy\|droxy)\|methyl)\|acryl\|ate}~(\cmpd{iPrtBuAcrylate})}
Problematic subsection with a workaround.

  • Unrelated comment: in headings you should use \cmpd+{<id>} in order to avoid that the numbering starts in the table of contents. – clemens Sep 19 '13 at 12:46
  • 1
    It's curious that if you add at the end \|, the bad line break doesn't happen. However, this doesn't happen with article; the difference is that scrartcl uses raggedright section titles. – egreg Sep 19 '13 at 12:57
  • @cgnieder actually, I am already using \cmpd+ in my document. I don't know why I took it out again. ;) Thanks for the advice though! @egreg this actually seems to be a simple workaround as well. Thanks! – basseur Sep 19 '13 at 19:10
  • @cgnieder I remember: I took the + out, because it would have lead to empty parentheses in the MWE. :) – basseur Sep 19 '13 at 19:24
  • @basseur yes, the + plus variant doesn't declare a label, it only refers to one. You'd have to declare it elsewhere then, e.g. somewhere in the text... – clemens Sep 19 '13 at 19:28

This has nothing to do with the chem macros. The default headings in scrartcl are set \raggedright via the command \raggedsection. Ragged right environments demonstrate the problem you have. One way around this is to use the ragged2e package and set \raggedsection to \RaggedRight:

Sample output




\subsection{Averylongword\-averylongwordaverylong\-wordaverylongwordavery\-long\-word X}

  Averylongword\-averylongwordaverylong\-wordaverylongwordavery\-long\-word\-averylongwordaverylong\-wordaverylongwordavery\-long\-word X


\subsection{Averylongword\-averylongwordaverylong\-wordaverylongwordavery\-long\-word X}

  • 1
    Will this only affect the sectionheadings? What possibly bad repercussions are there to using this method? – basseur Sep 19 '13 at 20:03
  • 2
    scrartcl introduces \raggedsection explicitly for use in sectioning headings and uses this code nowhere else. So this is the right command to customize. – Andrew Swann Sep 20 '13 at 9:24

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.