![为什么当我运行包含列表的此部分时会出现此错误?](https://linux22.com/image/475914/%E4%B8%BA%E4%BB%80%E4%B9%88%E5%BD%93%E6%88%91%E8%BF%90%E8%A1%8C%E5%8C%85%E5%90%AB%E5%88%97%E8%A1%A8%E7%9A%84%E6%AD%A4%E9%83%A8%E5%88%86%E6%97%B6%E4%BC%9A%E5%87%BA%E7%8E%B0%E6%AD%A4%E9%94%99%E8%AF%AF%EF%BC%9F.png)
我在文档的章节标题中放了一个列表。代码如下:
\documentclass{article}
\usepackage{enumerate}
\usepackage{chemfig}
\begin{document}
\section{My Controversial Opinions:
\begin{enumerate}[(a)]
\item Taylor Swift is overrated
\item Wiping your posterior with toilet paper is gross
\item Legend of Korra is not that bad.
\end{enumerate}
}
\subsection{\schemestart
\chemfig{Na_2SO_4}
\arrow{->[\footnotesize\chemfig{H_2O}]}
\chemfig{Na^+}\+\chemfig{SO_2^{-}}
\schemestop
}
\end{document}
我知道列表似乎不应该出现在章节标题中,但我希望它是这样。每次我在 Overleaf 上运行代码时,我都会收到以下错误消息:@sect 的参数有一个多余的 }、参数失控?等等。我检查了语法几次,似乎没有错。此外,我添加了化学方程式,因为它对实际文档很重要,而这时代码就无法运行了。没有化学代码会出现错误,但我仍然可以在 overleaf 上运行它。
答案1
无论如何,这是一个非常糟糕的想法,在章节标题中列出……
\documentclass{article}
\usepackage{enumerate}
\usepackage{chemfig}
\newsavebox{\sectionbox}
\newlength{\sectionwd}
\begin{document}
\begin{lrbox}{\sectionbox}
\addtocounter{section}{1}%
\Large\bfseries\settowidth{\sectionwd}{\thesection\quad}%
\addtocounter{section}{-1}%
\begin{minipage}[t]{\dimeval{\textwidth-\sectionwd}}
My Controversial Opinions:
\begin{enumerate}[(a)]
\item Taylor Swift is overrated
\item Wiping your posterior with toilet paper is gross
\item Legend of Korra is not that bad.
\end{enumerate}
\end{minipage}
\end{lrbox}
\section{\usebox{\sectionbox}}
\begin{lrbox}{\sectionbox}
\large\bfseries
\renewcommand*\printatom[1]{\ensuremath{\mathbf{#1}}}%
\schemestart
\chemfig{Na_2SO_4}
\arrow{->[\footnotesize\chemfig{H_2O}]}
\chemfig{Na^+}\+\chemfig{SO_2^{-}}
\schemestop
\end{lrbox}
\subsection{\usebox{\sectionbox}}
\end{document}
我推荐enumitem
。enumerate
答案2
您误用了section
。请在代码中坚持对对象进行简单的分配。
也许就这么简单?
\documentclass{article}
\usepackage{enumerate}
\usepackage{chemfig}
\begin{document}
\section{My Controversial Opinions}
\begin{enumerate}[(a)]
\item Taylor Swift is overrated
\item Wiping your posterior with toilet paper is gross
\item Legend of Korra is not that bad.
\end{enumerate}
\subsection{Chemical Equation Example}
\schemestart
\chemfig{Na_2SO_4}
\arrow{->[\footnotesize\chemfig{H_2O}]}
\chemfig{Na^+}\+\chemfig{SO_2^{-}}
\schemestop
\end{document}
注意:我不对列表的文本负责......