我想将章节标题放在中间,而不是左对齐。我使用了
\usepackage{sectsty}
\chapterfont{\centering}
它将章节标题放在中间,但它几乎从页面中间开始,这在我的论文中看起来很糟糕。我希望标题居中,并从与页眉合理的距离开始,就像“摘要”或我的论文中的其他页面一样。
这是我的 tex 文件:
\documentclass[12pt]{behrooz-thesis}
% Packages
\usepackage[left=1.5in,right=1in,bottom=1.5in,top=1in,marginparwidth=0.0in,marginparsep=0.0in,headheight=0.0in,headsep=0.0in,footskip=0.5in]{geometry}
%\usepackage{layout}
\usepackage{graphicx}
\usepackage{deluxetable}
%\usepackage{mymacros}
%\setlength{\textfloatsep}{0.5in plus 1.0pt minus 1.0pt}
%\setlength{\floatsep}{0.25in plus 1.0pt minus 1.0pt}
%\setlength{\intextsep}{0.5in plus 1.0pt minus 1.0pt}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{color}
\usepackage{calc}
\usepackage[font={small}, skip=12pt, format=hang]{caption}
\usepackage{float}
\floatstyle{plaintop}
\restylefloat{table}
%\DeclareCaptionListFormat{mycaplist}{#2}
%\captionsetup{listformat=mycaplist}
\usepackage{gnuplottex}
%\usepackage{gnuplot-lua-tikz}
\usepackage{empheq}
\usepackage{subfigure}
\usepackage{microtype}
%\usepackage{siunitx}
\usepackage{booktabs}
\usepackage{enumerate}
\usepackage[percent]{overpic}
\usepackage{microtype}
\usepackage{amsfonts,amsmath,amssymb}
%
\usepackage[subfigure]{tocloft}
%setlength{\cftchapnumwidth}{3em}
\renewcommand{\cftchappresnum}{Chapter\space}
\AtBeginDocument{\addtolength\cftchapnumwidth{\widthof{\bfseries Chapter }}}
\setlength{\cftbeforechapskip}{3pt}
\renewcommand{\cftchapfont}{}
\renewcommand{\cftchappagefont}{}
\renewcommand{\cftbeforefigskip}{0.15in}
%\renewcommand{\cfttoctitlefont}{\hfill\Large\bfseries} %thaque
%\renewcommand{\cftaftertoctitle}{\hfill} %thaque
%\usepackage{titletoc}% http://ctan.org/pkg/titletoc
%\titlecontents*{chapter}% <section-type
%[0pt]% <left>
% {}% <above-code>
% {\bfseries\chaptername\ \thecontentslabel\quad}% <numbered-entry-format>
% {}% <numberless-entry-format>
% {\bfseries\hfill\contentspage}% <filler-page-format>
%\renewcommand\cftpartnumwidth{-2cm}
%\usepackage{titlesec}
%\titlespacing{\chapter}{0pt}{0pt}{0.5in}
%\usepackage{float}
\usepackage{lipsum}
%\usepackage[subrefformat=parens,labelformat=parens]{subfig}
\usepackage{nomencl}
%\usepackage[backend=bibtex,natbib=true,style=authoryear-comp,firstinits=true,uniquename=init]{biblatex}
%\addbibresource{ref.bib}
%\DeclareNameAlias{sortname}{last-first}
\usepackage[round]{natbib}
%\bibliographystyle{plainnat}
\bibliographystyle{apj}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[dvipsnames]{xcolor}
%\usepackage{cite}
\usepackage[none]{hyphenat}
\usepackage{setspace}
\usepackage[left]{lineno}
\usepackage{placeins}
\usepackage{ifthen}
\usepackage[titletoc]{appendix}
\usepackage{listings,minted}
\usepackage{algorithm}
\usepackage{algpseudocode}
\captionsetup[algorithm]{font=scriptsize} %change the caption size
\algrenewcommand\alglinenumber[1]{\scriptsize #1:} %change line number size in pseudocode
\algnewcommand{\LineComment}[1]{\Statex \(\triangleright\) #1 \hfill~} %freely positions comments in pseudocode
\algrenewcommand\textproc{}% Used to be \textsc %small alphabets as function name
%\algtext*{EndFor}
%\algtext*{EndIf}
%New definitions
\algnewcommand\algorithmicswitch{\textbf{switch}}
\algnewcommand\algorithmiccase{\textbf{case}}
\algnewcommand\algorithmicassert{\texttt{assert}}
\algnewcommand\Assert[1]{\State \algorithmicassert(#1)}%
%New "environments"
\algdef{SE}[SWITCH]{Switch}{EndSwitch}[1]{\algorithmicswitch\ #1\ \algorithmicdo}{\algorithmicend\ \algorithmicswitch}%
\algdef{SE}[CASE]{Case}{EndCase}[1]{\algorithmiccase\ #1}{\algorithmicend\ \algorithmiccase}%
%\algtext*{EndSwitch}%
\algtext*{EndCase}%
%
%\usepackage[backend=bibtex8,citestyle=numeric-comp,sorting=none,bibstyle=numeric]{biblatex}
%\addbibresource{refs.bib}
%\DefineBibliographyStrings{english}{urlseen = {accessed},}
%%
%\usepackage{floatrow}
%\floatsetup[table]{capposition=top}
\usepackage{tikz}
%\usepackage{pgfplots}
%\pgfplotsset{compat=1.9}
%\tikzset{>=latex}
%\usetikzlibrary{shapes.geometric,arrows,decorations.pathreplacing,positioning}
%\usepackage{titlesec}
%\usepgfplotslibrary{external,groupplots}
%\pgfplotsset{compat=1.9,width=0.9\textwidth,height=0.5\textwidth}
%\usepackage[colorlinks=false, pdfborder={0 0 0}]{hyperref}
%\RequirePackage[l2tabu, orthodox]{nag}
%
\usepackage{etoolbox}
\makeatletter
%\patchcmd{\l@chapter}{\bfseries}{}{}{}
%
\patchcmd{\@chapter}{\addtocontents{lof}{\protect\addvspace{10\p@}}}{}{}{}% LoF
\patchcmd{\@chapter}{\addtocontents{lot}{\protect\addvspace{10\p@}}}{}{}{}% LoT
\makeatother
%
%\usepackage{fancyhdr}
%\pagestyle{fancy}
%\fancyhf{}
%\titlespacing{\chapter}{}{0pt}{}
\linespacing{1.66}
% turning figures on and off.
%\tikzexternalize
%\newcommand{\activefig}{0}
%
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
%
%\setlength{\nomitemsep}{1cm}
\setlength{\nomlabelwidth}{4cm}
\makenomenclature
%}
% My custom commands
\newcommand{\reg}[1]{#1\textsuperscript{\textregistered}}
\newcommand{\datadir}{plot_data}
% % % % % % % % % % % % % % flowchart style
\tikzstyle{startstop} = [rectangle, rounded corners, minimum width=1cm, minimum height=1cm,text centered, draw=black,text width=1.5cm]
\tikzstyle{io} = [trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=1cm, minimum height=1cm, text centered, draw=black,text width=1.5cm]
\tikzstyle{process} = [rectangle, minimum width=1cm, minimum height=1cm, text centered, draw=black,text width=1.5cm]
\tikzstyle{decision} = [diamond, minimum width=1cm, minimum height=1cm, text centered, draw=black,text width=1.5cm]
\tikzstyle{arrow} = [thick,->,>=latex]
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
%###########################################################################
\degree{Master of Science}
\department{Department of Physics} \gradyear{2017}
\title{\uppercase{Double-Degenerate }}
%
\author{Me}
\date{}
%
\newlength{\titlemarg}
\setlength{\titlemarg}{1.5in+0.5em}
\usepackage{hyperref}
\hypersetup{
colorlinks,
citecolor=black,
filecolor=black,
linkcolor=black,
urlcolor=black
}
\usepackage[capitalise]{cleveref}% load last
\crefrangelabelformat{equation}{(#3#1#4--#5#2#6)}
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \layout
\begin{preliminary}
\newgeometry{left=1.5in,right=1.5in,bottom=1.32in,top=\titlemarg,marginparwidth=0.0in,marginparsep=0.0in,headheight=0.0in,headsep=0.0in,footskip=0in}
%% This generates the title page from the information given above.
\maketitle
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
\restoregeometry
\begin{flushleft}
%\begin{doublespacing}
%\end{doublespacing}
\end{flushleft}
\singlespacing
\vspace{0.5in}
\begin{flushright}
\makebox[2.98in]{\hrulefill}\\
\end{flushright}
\vskip -0.17in
\hspace{2.95in} \makeatletter{\@author}\makeatletter
\vspace{0.5in}
\begin{flushright}
Date \makebox[2.61in]{\hrulefill}
\end{flushright}
\thispagestyle{empty}
\newpage
\thispagestyle{empty}
\begin{flushleft} We approve the thesis of \makeatletter{\@author}\makeatletter \end{flushleft}
\hspace{3.8in} Date of Signature
\vspace{0.40in}
\begin{flushleft}
\makebox[2.5in]{\hrulefill} \hspace{1.5in} \makebox[1.5in]{\hrulefill} \\
%Robert Fisher\\
Associate Professor, Department of Physics \\
Thesis Advisor\\
\vspace{0.49in}
\makebox[2.5in]{\hrulefill} \hspace{1.5in} \makebox[1.5in]{\hrulefill} \\
%Gaurav Khanna \\
Professor and Graduate Program Director\\
Department of Physics\\
Thesis Committee\\
\vspace{0.49in}
\makebox[2.5in]{\hrulefill} \hspace{1.5in} \makebox[1.5in]{\hrulefill} \\
%Jianyi Jay Wang\\
Associate Professor, Department of Physics\\
Thesis Committee\\
\vspace{0.49in}
\makebox[2.5in]{\hrulefill} \hspace{1.5in} \makebox[1.5in]{\hrulefill} \\
%Grant V. O'Rielly\\
Chairperson, Department of Physics\\
\vspace{0.49in}
\makebox[2.5in]{\hrulefill} \hspace{1.5in} \makebox[1.5in]{\hrulefill} \\
%Robert E. Peck\\
Dean, College of Engineering\\
\vspace{0.49in}
\makebox[2.5in]{\hrulefill} \hspace{1.5in} \makebox[1.5in]{\hrulefill} \\
%Tesfay Meressi\\
Associate Provost for Graduate Studies\\
\end{flushleft}
\linespacing{1.66}
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
%% There should be NOTHING between the title page and abstract.
%% This generates the abstract page, with the line spacing adjusted
%% according to SGS guidelines.
\begin{abstract}
%% *** Put your Abstract here. ***
%% (At most 150 words for M.Sc. or 350 words for Ph.D.)
Type Ia supernovae are theorized to originate from thermonuclear explosion of Carbon-Oxygen white dwarfs (CO WDs)
\end{abstract}
\newpage
%% This generates an "acknowledgements" section, if needed.
%% (uncomment to have it appear in the document)
\begin{acknowledgements}
%\begin{flushleft}
% %% *** Put your Acknowledgements here. ***
This thesis is based on a peer-reviewed paper
% \end{flushleft}
\end{acknowledgements}
\newpage
%% This generates the Table of Contents (on a separate page).
\renewcommand\contentsname{\vskip -1.12in Contents\vskip -0.27in}
% \sectionfont{\centering} %thaque
\begin{center} %thaque
\tableofcontents
\end{center} %thaque
% \sectionfont{}
\clearpage
%% This generates the List of Figures (on a separate page), if needed.
%% (uncomment to have it appear in the document)
%\begin{center}
\renewcommand\listfigurename{\vskip -1.12in List of Figures\vskip -0.25in}
%\end{center}
\linespacing{1}
\begin{center}
\nohyphens{\addcontentsline{toc}{chapter}{\textnormal{List of Figures}} \listoffigures}
\end{center}
\clearpage
\linespacing{1.66}
%% This generates the List of Tables (on a separate page), if needed.
%% (uncomment to have it appear in the document)
\renewcommand\listtablename{\vskip -1.12in List of Tables\vskip -0.25in}
\begin{center}
\nohyphens{\addcontentsline{toc}{chapter}{\textnormal{List of Tables}} \listoftables}
\end{center}
\clearpage
\printnomenclature
%% End of the preliminary sections: reset page style and numbering.
\end{preliminary}
\input{results.tex}
%
\newpage
\addcontentsline{toc}{chapter}{Bibliography}
\renewcommand\bibname{\vskip -1in Bibliography\vskip -0.24in}
\bibliography{Bibliography}{}
%\printbibliography
% % % % %
\end{document}
我的 cls 和 results.tex 文件在这里:
https://www.dropbox.com/s/jx2ajmby8s98zm7/formatting.zip?dl=0
答案1
将您的 cls 文件更改为:
\def\@makechapterhead#1{%
\vspace*{-27\p@}%FOR LESS VERTICAL SPACE YOU CAN MAKE IT UNTIL -127
{\parindent \z@ \raggedright \normalfont
\ifnum \c@secnumdepth >\m@ne
\centering
\huge\bfseries \@chapapp\space \thechapter
\par\nobreak
\vskip 20\p@
\fi
\interlinepenalty\@M
\centering
\Huge \bfseries #1\par\nobreak
\vskip 21\p@
}}
它位于 cls 的第 770 排。
(编辑:也检查关于垂直空间的评论)
结果: