我在文件的章節標題中放置了一個清單。這是代碼:
\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 上執行程式碼時,都會收到以下錯誤訊息: Argument of @sect has an extra } , Runaway argument?和別的。我檢查了好幾遍文法,似乎沒有錯誤。另外,我添加了化學方程式,因為它對於實際文件很重要,而且當程式碼無法運行時。沒有化學程式碼會出現錯誤,但我仍然可以在背面運行它。
答案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}
注意:我不對清單的文字負責......