部分名称水平居中

部分名称水平居中

请考虑,作为起点,指出下面的代码。

我想让多行部分名称水平居中,但没有成功。

这种类型的定心仅适用于肯定部分名称,而不是所有部分名称。

\documentclass{article}

\begin{document}

\tableofcontents

\addcontentsline{toc}{section}{my section, my section, my section, my section, my section, my section, my section, my section, my section, my section, my section, my section}

\newpage
\thispagestyle{empty}
\topskip0pt
\vspace*{\fill}
\section*{my section, my section, my section, my section, \linebreak {\centering my section, my section, my section} \linebreak {\centering my section, my section, my section}}
\vspace*{\fill}
\newpage

This section...

\end{document}

答案1

您可以使用提供此类功能的类,例如,

\documentclass[emulatestandardclasses]{scrartcl}

\begin{document}

\let\raggedsection\centering
\section*{centered section, centered section, centered section, centered
  section, centered section, centered section, centered section, centered
  section, centered section, centered section}

\let\raggedsection\raggedright
\section*{left-aligned section, left-aligned section, left-aligned section,
  left-aligned section, left-aligned section, left-aligned section,
  left-aligned section, left-aligned section, left-aligned section,
  left-aligned section}

\let\raggedsection\raggedleft
\section*{right-aligned section, right-aligned section, right-aligned section,
  right-aligned section, right-aligned section, right-aligned section,
  right-aligned section, right-aligned section, right-aligned section,
  right-aligned section}

\let\raggedsection\relax
\section*{justified section, justified section, justified section, justified
  section, justified section, justified section, justified section, justified
  section, justified section, justified section}

\end{document}

在此处输入图片描述

或者添加一个支持改变对齐方式的包,例如:

\documentclass{article}
\usepackage{sectsty}

\begin{document}

\sectionfont{\bfseries\centering}
\section*{centered section, centered section, centered section, centered
  section, centered section, centered section, centered section, centered
  section, centered section, centered section}

\sectionfont{\bfseries\raggedright}
\section*{left-aligned section, left-aligned section, left-aligned section,
  left-aligned section, left-aligned section, left-aligned section,
  left-aligned section, left-aligned section, left-aligned section,
  left-aligned section}

\sectionfont{\bfseries\raggedleft}
\section*{right-aligned section, right-aligned section, right-aligned section,
  right-aligned section, right-aligned section, right-aligned section,
  right-aligned section, right-aligned section, right-aligned section,
  right-aligned section}

\sectionfont{\bfseries}
\section*{justified section, justified section, justified section, justified
  section, justified section, justified section, justified section, justified
  section, justified section, justified section}


\end{document}

在此处输入图片描述

相关内容