如何仅使 \subsection{} 居中,而其他所有部分类型保持左对齐?

如何仅使 \subsection{} 居中,而其他所有部分类型保持左对齐?

问题基本上如上所述。如何才能仅将特定部分类型居中,而其他所有部分都保留标准格式?

\documentclass{report}
\begin{document}

\section{Blabla} %this one should NOT be centered
\subsection{xyz} %this one should be centered
\subsubsection{abc} %this one should NOT be centered
\end{document}

谢谢!

答案1

带包裹titlesec

A

\documentclass{report}

\usepackage{titlesec}% <<<<<<<<<<<<<<<<<<<<<<

\titleformat{\subsection}% sectioning command
{\large\bfseries\filcenter}% format
{\thesubsection}% label
{1ex}% label separation
{} %code before

\begin{document}
    
    \section{Blabla} %this one should NOT be centered
    \subsection{xyz} %this one should be centered
    \subsubsection{abc} %this one should NOT be centered    

\end{document}

相关内容