【问题标题】:Error when using roman numerals in section heading LaTex在部分标题 LaTex 中使用罗马数字时出错
【发布时间】:2020-08-24 12:20:32
【问题描述】:

我想使用罗马数字来列举我的乳胶文档中的某些部分。

我使用这个:\MakeUppercase{\romannumeral 2} 来创建数字。这在普通文本中工作正常,但如果我尝试在 sectionsubsection 命令中使用它,我会收到“undefined control sequence”错误即使它似乎在部分标题中正确显示了数字。

显然问题出在\MakeUppercase 命令上,因为\romannumeral 2 命令不会出错。

我也尝试过定义\newcommand,效果相同。

有人知道为什么会这样吗?

编辑:在创建了一个最小的可重现示例后,我发现问题与 hyperref 包有关。

\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}

【问题讨论】:

  • 请创建一个minimal reproducible example,我们可以编译它以重现您的问题,而不仅仅是这样的代码片段
  • 感谢您指出它已经帮助缩小了问题范围

标签: latex roman-numerals


【解决方案1】:

您可以为 pdf 书签提供替代字符串:

\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}

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-05-16
  • 1970-01-01
  • 2017-11-27
  • 2020-05-28
  • 2012-02-24
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多