我决定使用 \usepackage[center]{titlesec} 来将我的章节居中,但我不希望它们在章节标题中显示章节编号,因此我应用了 titleformat。但使用此新宏,它会删除 [center] 命令。
\documentclass[14pt]{memoir}
\usepackage[center]{titlesec}
\usepackage{lipsum}
\titleformat{\chapter}
{\Large\bfseries}
{}
{0pt}
{\huge}
\titleformat{\section}
{\Large\bfseries}
{}
{0pt}
{\large}
\begin{document}
\tableofcontents
\chapter{This shouldn't be centered}
\clearpage
\section{This should be centered}
\lipsum[1]
\subsection{This should be centered}
Nothing to see here.
\end{document}
结果:
答案1
像这样 ? :
\documentclass[14pt]{memoir}
\usepackage[center]{titlesec}
\usepackage{lipsum}
\titleformat{\chapter}
{\centering\Large\bfseries} % format
{}% label
{0pt} % sep
{\huge}
\setcounter{secnumdepth}{0}
\begin{document}
\tableofcontents
\chapter{This shouldn't be centered}
\clearpage
\section{This should be centered}
\lipsum[1]
\subsection{This should be centered}
Nothing to see here.
\end{document}
答案2
你不应该使用titlesec
,memoir
请参阅关于 memoir 和 titlesec 不兼容
\documentclass[14pt]{memoir}
\usepackage{lipsum}
\setsecheadstyle{\centering\Large\bfseries}
\setsubsecheadstyle{\centering\large\bfseries}
\setsechook{\setsecnumformat{\csname the##1\endcsname\ }}
\begin{document}
\tableofcontents
\chapter{This shouldn't be centered}
\section{This should be centered}
\lipsum[1]
\subsection{This should be centered}
Nothing to see here.
\end{document}