如何将候选人的声明章节和证书章节放在 latex 报告中的同一页并居中

如何将候选人的声明章节和证书章节放在 latex 报告中的同一页并居中

% 另外,我怎样才能减少目录中前言之间的间距。

\documentclass[a4paper, 12pt]{report}

\usepackage{fancyhdr}   
\usepackage{titlesec}

\titleformat{\chapter}[display]
 {\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\Huge}
\titlespacing*{\chapter}{0pt}{-20pt}{20pt}



\pagenumbering{roman}


\begin{document}

\chapter*{\underline{CANDIDATE'S DECLARATION}}%
\addcontentsline{toc}{chapter}{\numberline{}Candidate's Declaration}%
xxxxxxxxxxxxxxxxxxxxxxxxxx\\xxxxxxxxxxxxxxxxxxxxxxxxxxx\\xxxxxxxxxxxxxxxxxxxxxxxx\\

xxxxxxxxxxxxxxxx\\xxxxxxxxxxxxxxxxxxx\\xxxxxxxxxxxxxxxxxxx

xxxxxxxxxxxxxxxxxxxxxxxxxx\\xxxxxxxxxxxxxxxxxxxxxxxxxxx\\xxxxxxxxxxxxxxxxxxxxxxxx\\

xxxxxxxxxxxxxxxx\\xxxxxxxxxxxxxxxxxxx\\xxxxxxxxxxxxxxxxxxx

xxxxxxxxxxxxxxxxxxxxxxxxxx\\xxxxxxxxxxxxxxxxxxxxxxxxxxx\\xxxxxxxxxxxxxxxxxxxxxxxx\\

\par\noindent\rule{\textwidth}{0.4pt}

\chapter*{\underline{CERTIFICATE}}%
\addcontentsline{toc}{chapter}{\numberline{}Certificate}%
This is to certify that the above statement made by the candidate is correct to best of my knowledge and belief.
\\
\\
\\
\\
\\
\begin{flushright}
xxxxxxxxxxxxxxx\\
 Professor\\
xxxxxxxxxxxxxx\\
xxxxxxxxxxx
\end{flushright}

\tableofcontents

\pagenumbering{arabic}

\chapter{Introduction}

\end{document}

并在中心

答案1

好吧,您可以重新定义\cleardoublepage,并且\clearpage什么也不做,这样您的第二个就不会有新页面\chapter*{}。要使两个章节都居中,您必须添加\centering\titleformat在不再需要居中之后重新定义它...

请参阅以下代码(肮脏的黑客!):

\documentclass[a4paper, 12pt]{report}

\usepackage{fancyhdr}
\usepackage{titlesec}
\usepackage{showframe}% <============ to visualize typing area and margins

\titleformat{\chapter}[display]
 {\normalfont\huge\bfseries\centering}{\chaptertitlename\ \thechapter}{20pt}{\Huge}
%                          ^^^^^^^^^^  <================================
\titlespacing*{\chapter}{0pt}{-20pt}{20pt}



\pagenumbering{roman}


\begin{document}

\chapter*{\underline{CANDIDATE'S DECLARATION}}%
\addcontentsline{toc}{chapter}{\numberline{}Candidate's Declaration}%
xxxxxxxxxxxxxxxxxxxxxxxxxx\\xxxxxxxxxxxxxxxxxxxxxxxxxxx\\xxxxxxxxxxxxxxxxxxxxxxxx\\

xxxxxxxxxxxxxxxx\\xxxxxxxxxxxxxxxxxxx\\xxxxxxxxxxxxxxxxxxx

xxxxxxxxxxxxxxxxxxxxxxxxxx\\xxxxxxxxxxxxxxxxxxxxxxxxxxx\\xxxxxxxxxxxxxxxxxxxxxxxx\\

xxxxxxxxxxxxxxxx\\xxxxxxxxxxxxxxxxxxx\\xxxxxxxxxxxxxxxxxxx

xxxxxxxxxxxxxxxxxxxxxxxxxx\\xxxxxxxxxxxxxxxxxxxxxxxxxxx\\xxxxxxxxxxxxxxxxxxxxxxxx\\

\par\noindent\rule{\textwidth}{0.4pt}\vspace{\baselineskip} % <=====

{\let\cleardoublepage\relax % <=====================================
\let\clearpage\relax % <============================================
\chapter*{\underline{CERTIFICATE}}%
\addcontentsline{toc}{chapter}{\numberline{}Certificate}%
}

This is to certify that the above statement made by the candidate is correct to best of my knowledge and belief.
\vspace{2cm} % <========================================================
\begin{flushright}
xxxxxxxxxxxxxxx\\
 Professor\\
xxxxxxxxxxxxxx\\
xxxxxxxxxxx
\end{flushright}

\titleformat{\chapter}[display] % <=====================================
 {\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\Huge}
\tableofcontents

\pagenumbering{arabic}

\chapter{Introduction}

\end{document}

和结果(请注意,您不应该使用多个\\来获得垂直空间,\vspace{2cm}而是使用并根据需要更改值):

生成的 pdf

正如您所看到的(包showframe显示 pdf 中的打字区域,删除/注释它以便实际打印)您的第一章有点太长,Certificate居中,Contents不居中。

相关内容