![在章节标题中指定换行符](https://linux22.com/image/429373/%E5%9C%A8%E7%AB%A0%E8%8A%82%E6%A0%87%E9%A2%98%E4%B8%AD%E6%8C%87%E5%AE%9A%E6%8D%A2%E8%A1%8C%E7%AC%A6%20.png)
我为我的论文创建了自己的 .cls 文件,当我在章节标题中指定换行符时,我收到一条错误消息
以下是文件中定义章节标题的部分:
%----------------------------------------------------------------------%
% Chapter heading font size
%----------------------------------------------------------------------%
\RequirePackage{sectsty}
\chapternumberfont{\normalsize}
\chaptertitlefont{\normalsize}
%----------------------------------------------------------------------%
% Title spacing
%----------------------------------------------------------------------%
\RequirePackage{titlesec} % Adjust title headers
% Reduce spacing after section/subsection/subsubsections
\titlespacing\section{0pt}{12pt plus 4pt minus 2pt}{0pt plus 2pt minus 2pt}
\titlespacing\subsection{0pt}{12pt plus 4pt minus 2pt}{0pt plus 2pt minus 2pt}
\titlespacing\subsubsection{0pt}{12pt plus 4pt minus 2pt}{0pt plus 2pt minus 2pt}
% Single spaced headers
\titleformat{\chapter} % command
[display] % shape
{\color{UOFURED}\centering\normalfont\Large\bfseries\doublespacing}
{\MakeUppercase{\chaptertitlename} \Large\thechapter}
{0pt} % separations
{\MakeUppercase} % before
[] % After (leave blank)
%\titleformat{\chapter}[display]{\centering\normalfont\huge\bfseries\singlespacing}{\chaptertitlename\ \thechapter}{40pt}{\huge}
\titleformat{\section}{\centering\singlespacing\normalfont\Large\bfseries}{\thesection}{1em}{}
\titleformat{\subsection}{\centering\singlespacing\normalfont\large\bfseries}{\thesubsection}{1em}{}
\titleformat{\subsubsection}{\centering\singlespacing\normalfont\normalsize\bfseries}{\thesubsubsection}{1em}{}
以下是我定义章节的方式,以便文本全部大写
\chapter{\uppercase{Chapter title goes here}}
但是,我的大学要求长章节标题必须为倒金字塔。我读到过,您可以通过指定换行符来实现这一点,如下所示:
\chapter[This is a really long title that needs to be wrapped as an inverted pyramid]{This is a really long title that \\ needs to be wrapped as an \\ inverted pyramid}
在 ubuntu 中编译后我收到一条错误消息,内容是:
! TeX capacity exceeded, sorry [main memory size=5000000].
\reserved@a #1#2->\let #1#2\reserved@a
l.8 ...ds to be wrapped as an \\ inverted pyramid}
! ==> Fatal error occurred, no output PDF file produced!
有人知道如何解决这个问题吗?
答案1
这个问题在评论中得到了回答。只需\protect\\
在\chapter
调用中添加即可。