使用 \tableofcontents 时出错

使用 \tableofcontents 时出错
\documentclass[12pt,reqno,a4paper]{amsart}
\usepackage{extsizes}
\usepackage{blindtext}
\textheight 9.3in \textwidth 6.5in
\calclayout
\usepackage{mathtools}
\usepackage{amsmath,amsthm,amsfonts,amssymb}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{corollary}{Corollary}[section]
\usepackage{hyperref}
\usepackage{mathrsfs}
\usepackage[all]{xy}
\usepackage[normalem]{ulem}
\newtheorem{lemma}{Lemma}[subsection]
\newtheorem*{question}{Question}
\theoremstyle{definition}
\newcommand{\mc}{\mathcal}
\newcommand{\mf}{\mathfrak}
\newtheorem*{solution}{Solution}
\newtheorem{definition}{Definition}[section]
\newtheorem{remark}{Remark}[section]
\newtheorem{proposition}{Proposition}[section]
\newtheorem{exercise}{Exercise} 
\newtheorem{example}{Example}[section]
\usepackage{tikz-cd}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{datetime}
% \renewcommand{\baselinestretch}{2} 
\usepackage{color}
\pagestyle{myheadings}
\newcommand{\xra}{\xrightarrow}
\newcommand{\ra}{\rightarrow}
\title{A}
\author{B} 

\begin{document}
    \today
\begin{abstract}

\end{abstract} 

\maketitle 
\tableofcontents 
\section{asdsd}
\subsection{A $p\colon \underline{X}\ra \mc{D}$B} 

\end{document}

当我不运行 \tableofcontents 时,我没有看到任何问题。如果我运行 \tableofcontents,我会看到

line 3: Missing $ inserted. ...htarrow \mathcal {D}$B}}{2}{subsection.1.1}
line 3: Missing $ inserted. ...htarrow \mathcal {D}$B}}{2}{subsection.1.1}
: It is better to use one of the extsizes classes, if you can.
line 48: Token not allowed in a PDF string (PDFDocEncoding):(hyperref) removing `math shift'
line 48: Token not allowed in a PDF string (PDFDocEncoding):(hyperref) removing `\mskip'
line 48: Token not allowed in a PDF string (PDFDocEncoding):(hyperref) removing `\mathpunct'
line 48: Token not allowed in a PDF string (PDFDocEncoding):(hyperref) removing `\nonscript'
line 48: Token not allowed in a PDF string (PDFDocEncoding):(hyperref) removing `\mkern'
line 48: Token not allowed in a PDF string (PDFDocEncoding):(hyperref) removing `\thinmuskip'
line 48: Token not allowed in a PDF string (PDFDocEncoding):(hyperref) removing `\mskip'
line 48: Token not allowed in a PDF string (PDFDocEncoding):(hyperref) removing `math shift'
line 48: Token not allowed in a PDF string (PDFDocEncoding):(hyperref) removing `\@@underline'
line 48: Token not allowed in a PDF string (PDFDocEncoding):(hyperref) removing `\hbox'
line 48: Token not allowed in a PDF string (PDFDocEncoding):(hyperref) removing `\mathsurround'
line 48: Token not allowed in a PDF string (PDFDocEncoding):(hyperref) removing `\z@'
line 48: Token not allowed in a PDF string (PDFDocEncoding):(hyperref) removing `math shift'
line 48: Token not allowed in a PDF string (PDFDocEncoding):(hyperref) removing `\rightarrow'
line 48: Token not allowed in a PDF string (PDFDocEncoding):(hyperref) removing `math shift'
: Label(s) may have changed. Rerun to get cross-references right.

上图中,前两个错误以红色字体显示。文件为 document.toc。第三个是警告。文件为 extsizes.sty。

其余所有内容都以警告形式出现在 document.tex 文件中

答案1

错误是由于\underline在小节标题中使用而导致的,可以通过\protect在其前面添加来解决。此外,Token not allowed in a PDF string可以通过为书签提供替代文本来避免有关的所有警告:

\documentclass[12pt,reqno,a4paper]{amsart}
\usepackage{extsizes}
\usepackage{blindtext}
\textheight 9.3in \textwidth 6.5in
\calclayout
\usepackage{mathtools}
\usepackage{amsmath,amsthm,amsfonts,amssymb}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{corollary}{Corollary}[section]
\usepackage{hyperref}
\usepackage{mathrsfs}
\usepackage[all]{xy}
\usepackage[normalem]{ulem}
\newtheorem{lemma}{Lemma}[subsection]
\newtheorem*{question}{Question}
\theoremstyle{definition}
\newcommand{\mc}{\mathcal}
\newcommand{\mf}{\mathfrak}
\newtheorem*{solution}{Solution}
\newtheorem{definition}{Definition}[section]
\newtheorem{remark}{Remark}[section]
\newtheorem{proposition}{Proposition}[section]
\newtheorem{exercise}{Exercise} 
\newtheorem{example}{Example}[section]
\usepackage{tikz-cd}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{datetime}
% \renewcommand{\baselinestretch}{2} 
\usepackage{color}
\pagestyle{myheadings}
\newcommand{\xra}{\xrightarrow}
\newcommand{\ra}{\rightarrow}
\title{A}
\author{B} 

\begin{document}
    \today
\begin{abstract}

\end{abstract} 

\maketitle 
\tableofcontents 
\section{asdsd}
\subsection{A \texorpdfstring{$p\colon \protect\underline{X} \ra \mc{D} $}{alternative text for bookmarks}B} 

\end{document}

相关内容