0

I am quite new to Latex and trying to make the report based on the template provided by my professor. I want to centre my Chapter heading along with chapter number and add an underline below it. I tried many things but only chapter heading would centre not the chapter number. Can someone please help me with this?

Currently, I am seeing the chapter name as following: [1]: https://i.sstatic.net/VCsiO.png

What I would like to achieve: [2]: https://i.sstatic.net/8GrvS.png

I tried the centring as mentioned in many answers \chapter*{\centering Introduction} but that is centring only the heading Introduction not the title. Can someone please help me how to centre the title of the chapter with the number and add an underline below it so it can get bit of professional feel?

\documentclass[a4paper,12pt]{book}
\usepackage{fontspec}  
\usepackage{microtype}  
\usepackage{polyglossia}
\setdefaultlanguage{english}
\usepackage[english]{selnolig}
\usepackage{geometry}
\usepackage[usegeometry,
            margin=20mm,
            twoside=semi]
           {typearea} 

\usepackage{acronym}
    \renewcommand*{\acsfont}[1]{{\rmfamily #1}} 
\usepackage[export]{adjustbox}
\usepackage[font=small,labelfont=bf]{caption}
\usepackage{csquotes}
\usepackage{graphicx}  
\usepackage{icomma} 
\usepackage{ltablex}   
\usepackage{newfile}   
\usepackage{overpic}   
\usepackage[hyphens]{url}
\usepackage{url}
\usepackage[
  backend=biber,
  style=ieee,
  urldate=long, 
  dateabbrev=false
]{biblatex}
\addbibresource{literatur.bib} 


\usepackage{float}
\makeatletter
\def\ScaleIfNeeded{
    \ifdim\Gin@nat@width>\linewidth
        \linewidth
        \else
        \Gin@nat@width
        \fi
}
\makeatother
\setkeys{Gin}{width=\ScaleIfNeeded}

\parindent 2em         
\parskip 0.5em          

\pagestyle{headings}

\input{commons_en.tex}

\newoutputstream{xmpstream}
\openoutputfile{\jobname.xmpdata}{xmpstream}
    \newcommand{\dummyspace}{ }

    \addtostream{xmpstream}{\protect\Title{\dctitle}}
    \addtostream{xmpstream}{\protect\Author{\dcauthorfirstname  \dcauthorlastname}}
    \addtostream{xmpstream}{\protect\Keywords{Compiler\protect\sep\dummyspace
                                              Database\protect\sep\dummyspace
                                              Index}}
    \addtostream{xmpstream}{\protect\Publisher{My University}}
\closeoutputstream{xmpstream}

\usepackage{hyperref}
\usepackage[a-1b]{pdfx}

\hypersetup{unicode,
            pdftitle={\dctitle},
            pdfauthor={\dcauthorfirstname~\dcauthorlastname},
            pdfsubject={\dcsubject},
            hidelinks}

\pdfinfo{
    /Title(\dctitle)
    /Author(\dcauthorfirstname\ \dcauthorlastname)
    /Subject(\dcsubject)
}

\usepackage{makeidx}         
\makeindex                    

\setcounter{secnumdepth}{4}    
\setcounter{tocdepth}{4}       


\author{\dcauthorfirstname~\dcauthorlastname}
\title{\dctitle}
\date{\today}


\begin{document}
\frontmatter

\begin{titlepage}
    \sffamily
    \newgeometry{left=2cm,top=2cm,bottom=2cm,right=2cm}

    \centering{
        \begin{tabularx}{\linewidth}{lp{1.5em}|p{1.5em}X}
            \includegraphics[width=0.33\textwidth,valign=c]{\tulogo}
            & & &
            {\huge\bfseries Department of Human Psychology}
        \end{tabularx}

        \vfill\vfill

        {\Huge\bfseries \dctitle}
        \vfill\vfill

        {\huge \dcsubject\\[1ex]

        for obtaining the academic degree}
        \vfill

        \LARGE B.\,Com.
        \vfill

        \dcauthortitle~\dcauthorfirstname~\dcauthorlastname\\[1ex]
       Registration Number: \dcmatriculation
    }
    \vfill\vfill\vfill
    
    \large
    \begin{tabular}[t]{ll}
        \textbf{Internal supervisor:}  & ABCD\\
        \textbf{External supervisor:}  & WXYZ.
    \end{tabular}

\end{titlepage}

\pagestyle{empty}

\ \\[90ex]
\null\vfill
{
    \ \\
    \textbf{\dcauthorlastname, \dcauthorfirstname}\\
    \dctitle\\
    \dcsubject, Department of Social Science\\
    My University,~%
        \ifcase\month%
            \or January%
            \or February%
            \or March%
            \or April%
            \or May%
            \or June%
            \or July%
            \or August%
            \or September%
            \or October%
            \or November%
            \or December%
        \fi%
    ~\number\year
}
\par\vfill\null

%-----------------------------
% Acknowledgements
%-----------------------------
\section*{\centering Acknowledgements}
\input{tex/1.Acknowledgements.tex}

\vfill
\thispagestyle{empty}
%-----------------------------
% Abstract
%-----------------------------
\section*{\centering Abstract}
\input{tex/2.Abstract.tex}

\vfill
\thispagestyle{empty}

\section*{\centering About}
\input{tex/3.About}

\vfill
\clearpage{\pagestyle{empty}\cleardoublepage}

\pagestyle{headings}


%-----------------------------
% Lists
%-----------------------------
\tableofcontents            \clearpage{\pagestyle{empty}\cleardoublepage}
\listoffigures              \clearpage{\pagestyle{empty}\cleardoublepage}
\listoftables               \clearpage{\pagestyle{empty}\cleardoublepage}
%\lstlistoflistings
\input{tex/acronyms_en.tex}    \clearpage{\pagestyle{empty}\cleardoublepage}    
\mainmatter 
\acresetall

%---------------------------------------------------------------------------------------------------
\chapter{\centering Introduction}
\input{tex/4.Introduction.tex}

\chapter{Conclusion}
\input{tex/10.Conclusion.tex}

\chapter{Future Scope}
\input{tex/11.FutureScope.tex}

\begin{appendix}

\chapter{Appendix}
\label{chap:Appendix}
\input{tex/appendix0_en.tex}

\end{appendix}

\backmatter

\printindex


\addcontentsline{toc}{chapter}{Bibliography}
\printbibliography

\clearpage
\thispagestyle{empty}
\addcontentsline{toc}{chapter}{Statement of Authorship}

\newgeometry{left=2cm,right=3.5cm,top=2cm,bottom=2cm}

\newlength\us
\settowidth{\us}{-\dcauthorfirstname~\dcauthorlastname-}

\begin{overpic}[width=\linewidth]{pics/selbstaendigkeitserklaerung}
    \put (6.5,81.71) {\small\sffamily \dcauthorlastname}
    \put (6.5,78.15) {\small\sffamily \dcauthorfirstname}
    \put (6.5,74.60) {\small\sffamily \dcauthorbirthdate}
    \put (6.5,71.05) {\small\sffamily \dcmatriculation}
    \put (5,32.69)   {\small\sffamily \today}
    \put (45.8,57.46){\small\sffamily \dcsubject}
    \put (38,32.6)   {\rule[-0.1ex]{\us}{0.5pt}}
\end{overpic}
\restoregeometry

\end{document}
2
  • The problem is: how is defined the formatting of chapters in this template?
    – Bernard
    Oct 11, 2020 at 9:36
  • Thanks for the response. I am actually following the format specified in my university so that has the basic codes which I am unable to decode completely. I have posted the complete template specified in that template. If possible can you please let me know what's causing the centring issue? Oct 11, 2020 at 10:00

1 Answer 1

1

Simply use titlesec. Add these lines to your preamble:

\usepackage{titlesec}
\titleformat{\chapter}[display]{\bfseries\filcenter}{\huge\chaptername~\thechapter}{3.8ex}{\Huge}[\vskip 1ex{\titlerule[1pt]}]

enter image description here

1
  • Thanks a lot :) That worked. Oct 11, 2020 at 12:53

You must log in to answer this question.

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