我在文档的章节标题中放了一个列表。代码如下:
\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}
注意:我不对列表的文本负责......