1
votes

I want to use roman numerals to enumerate some sections in my latex document.

I use this: \MakeUppercase{\romannumeral 2} to create the numeral. This works fine in the normal text but if I try to use it in a section or subsection command I get an "undefined control sequence" error even though it seems to display the numeral correctly in the section heading.

Apparently the problem is with the \MakeUppercase command, as just the \romannumeral 2 command does not give an error.

I have also tried to define a \newcommand with the same effect.

Does anybody have an idea why that is the case?

Edit: after creating a minimal reproducible example I figured out that the problem has something to do with the hyperref package.

\documentclass[12pt,a4paper]{report}
\usepackage[utf8]{inputenc}

\usepackage{hyperref}

\newcommand{\RomanNumeralCaps}[1]{\MakeUppercase{\romannumeral #1}}

\begin{document}

\chapter{Some chapter}
\section{Some section}
\subsection{Experiment \MakeUppercase{\romannumeral 1}}
\MakeUppercase{\romannumeral 1}
\RomanNumeralCaps{2}

\end{document}
1
Please make a minimal reproducible example which we can compile to reproduce your problem and not just such code fragmentssamcarter_is_at_topanswers.xyz
Thanks for pointing that out it already helped narrow down the problemFiber22

1 Answers

3
votes

You can provide an alternative string for the pdf bookmark:

\documentclass[12pt,a4paper]{report}
\usepackage[utf8]{inputenc}

\usepackage{romannum}% for approach #1 and #2
\usepackage{biblatex}% for approach #3
\usepackage{hyperref}


\begin{document}

\chapter{Some chapter}
\section{Some section}
\subsection{Experiment \texorpdfstring{\Romannum{1}}{I}}

or

\subsection[Experiment II]{Experiment \Romannum{2}}

or

\subsection{Experiment \RN{3}}

However with this approach the III will be replaced by 3 in the pdf bookmarks

\end{document}