0

I wanted to place the chapter heading in the center instead of flushleft. I used

\usepackage{sectsty}
\chapterfont{\centering} 

which placed the chapter heading in center but it started almost from midway of page which looks bad in my thesis. I want the heading centralized and starting from a reasonable distance from the page head, like the "Abstract" or other pages in my thesis.

here is my tex file:

\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}

my cls and results.tex files are here:

https://www.dropbox.com/s/jx2ajmby8s98zm7/formatting.zip?dl=0

3
  • off-topic: you loaded several packages more than once. e.g. amsmath, microtype, amssymb. Also, subfigure is deprecated, use subcaption instead. On a more related note, can you make your example code more minimal? It contains a lot of unnecessary packages (for this example), and is not even compilable in any case, since we do not have access to results.tex
    – Troy
    Commented Jul 5, 2017 at 2:03
  • Hi, sorry for the really messy tex file. I used \subcaption which returned me more error. As I don't understand what is going on here, can you please take a look at the cls file and the minimal results.tex file which I have shared in Dropbox
    – bhjghjh
    Commented Jul 5, 2017 at 2:12
  • 1
    Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See minimal working example (MWE). Commented Jul 5, 2017 at 2:26

1 Answer 1

1

change your cls file to:

\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@
    }}

It's about on 770 row of the cls.

(Edit:Check the comment about vertical space too)

Resault:

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .