4

I am trying to create an automatic numbering of remarks which will be highlighted. It does produce the expected result but it crashes and I don't understand what is wrong. Below is the minimum working example.

\documentclass[review,5p,sort&compress]{elsarticle}
\usepackage[english]{babel}
\usepackage{siunitx}
\usepackage[rgb]{xcolor}
\usepackage[normalem]{ulem}
\newcounter{HLcounter}
\show\ULon
\newcommand{\hl}[1]{\stepcounter{HLcounter}%
    \bgroup\markoverwith{\textcolor{yellow}{\rule[-.5ex]{2pt}{2.5ex}}}%
    \ULon{\,R\arabic{HLcounter}: {#1}\,}}
\begin{document}
efe \hl{testing} test \hl{\SI{60}{\minute}} bla bla
\end{document}

Thanks,

Rufus

1 Answer 1

3

The break-down-the-input approached used by ulem clashes with the hoops siunitx jumps through. The best fix is to add an \mbox, either to \hl:

\documentclass[review,5p,sort&compress]{elsarticle}
\usepackage[english]{babel}
\usepackage{siunitx}
\usepackage[rgb]{xcolor}
\usepackage[normalem]{ulem}
\newcounter{HLcounter}
\show\ULon
\newcommand{\hl}[1]{\stepcounter{HLcounter}%
    \bgroup\markoverwith{\textcolor{yellow}{\rule[-.5ex]{2pt}{2.5ex}}}%
    \ULon{\,R\arabic{HLcounter}: {\mbox{#1}}\,}}
\begin{document}
efe \hl{testing} test \hl{\SI{60}{\minute}} bla bla
\end{document}

or at each use of \SI inside \hl if you want to do it manually.

1
  • 1
    If I use the solution provided in the code (\mbox around #1) there are no line breaks any more. If I renew the \SI \si commands, it does work fine. \let\siold\si \let\SIold\SI \renewcommand{\si}[1]{\mbox{\siold{#1}}} \renewcommand{\SI}[2]{\mbox{\SIold{#1}{#2}}}
    – Rufus
    May 8, 2015 at 7:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .