我有章节标题的 titleformat 指定如下:
\documentclass{report}
\usepackage[sf,sl,outermarks,explicit]{titlesec}
\titleformat{\chapter}{\normalfont\sffamily\Large\bfseries}{\thechapter \quad \MakeUppercase{#1}}{.5em}{}
\begin{document}
\chapter{Too long chapter name needs to be split into multiple lines}
\end{document}
现在我的章节标题太长,无法在一行中很好地显示,需要分成多行。我尝试添加\\
或\newline
但没有成功。
\chapter{Too long chapter name needs to be split into multiple lines}
答案1
您把标题放错了地方:
\documentclass{report}
\usepackage[sf,sl,outermarks,explicit]{titlesec}
\titleformat{\chapter}
{\normalfont\sffamily\Large\bfseries}
{\thechapter}
{1em}
{\MakeUppercase{#1}}
\begin{document}
\chapter{Too long chapter name needs to be split into multiple lines}
\end{document}
如果没有explicit
它
\titleformat{\chapter}
{\normalfont\sffamily\Large\bfseries}
{\thechapter}
{1em}
{\MakeUppercase}
答案2
看起来可选参数[display]
可以起作用。titlesec 文档。
\documentclass{report}
\usepackage[sf,sl,outermarks,explicit]{titlesec}
\titleformat{\chapter}[display]%
{\normalfont\sffamily\Large\bfseries}%
{\thechapter \quad \MakeUppercase{#1}}{.5em}{} % Succeeds
%\titleformat{\chapter}%
% {\normalfont\sffamily\Large\bfseries}
% {\thechapter \quad \MakeUppercase{#1}}{.5em}{} % Fails
\begin{document}
\chapter{Too long chapter name needs to be split into multiple lines}
\end{document}