Page LayoutHow to change "1 Introduction" into "Chapter 1: Introduction"?

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
lukaszskowron96
Posts: 36
Joined: Tue Oct 09, 2018 1:01 pm

How to change "1 Introduction" into "Chapter 1: Introduction"?

Post by lukaszskowron96 »

I tried using this: https://latex.org/forum/viewtopic.php?t=3754#

But unfortunatelly didn't get what I want, this is the example code you can edit to help me:

Code: Select all

\documentclass{article}
\begin{document}
\section{Introduction}
\subsection{Introductory Note}
Some text
\section{More stuff}
\subsection{Even more stuff}
Some text
\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

How to change "1 Introduction" into "Chapter 1: Introduction"?

Post by Stefan Kottwitz »

Hi,

change article to report and \section to \chapter.

Stefan
LaTeX.org admin
lukaszskowron96
Posts: 36
Joined: Tue Oct 09, 2018 1:01 pm

How to change "1 Introduction" into "Chapter 1: Introduction"?

Post by lukaszskowron96 »

The thing is I am not using article or report. I am using scrartcl and it seems like it doesn't recognize \chapter. I got an error(! Undefined control sequence.) while trying to do that.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

How to change "1 Introduction" into "Chapter 1: Introduction"?

Post by Stefan Kottwitz »

You wrote \documentclass{article} above. ;-)

So, change to scrreprt, that's the "chapter version" of scrartcl.

Specifically, activate the chapterprefix option:

\documentclass[chapterprefix=true]{scrreprt}

Stefan
LaTeX.org admin
lukaszskowron96
Posts: 36
Joined: Tue Oct 09, 2018 1:01 pm

How to change "1 Introduction" into "Chapter 1: Introduction"?

Post by lukaszskowron96 »

Ok, I changed that but there are some more problems:

FIrstly, I don't like how Chapter 1 is above word introduction:

Image

I would prefer it to be in one line: "Chapter 1: Introduction".

Also I want to change how it is presented in ToC. I want it so say "Chapter 1: Introduction" ............. 1.

Image

Also, changing the document class also changed the table of contents look. I prefer how it looks on this picture:

Image

Here's the code I am actually using:

Code: Select all

\documentclass[toc=sectionentrywithdots,a4paper,11pt]{scrartcl}
\usepackage{graphicx}

\usepackage{setspace}
\doublespacing

\usepackage[a4paper, left=20mm, right=20mm, top=20mm]{geometry}

\usepackage{pdfpages}

\usepackage{fancyhdr}
\pagestyle{fancy}
\rhead{ }
\lhead{ }
\thispagestyle{empty}

\usepackage{lipsum}

\setcounter{page}{1}

\renewcommand{\rmdefault}{phv}
\renewcommand{\sfdefault}{phv}

\usepackage[margin=0pt,font=normalsize]{subcaption}

\counterwithin{figure}{section}

\begin{document}
\pagenumbering{gobble}
\setcounter{page}{0}

\newpage
\pagenumbering{roman}
\thispagestyle{plain}
\begin{center}
\begin{LARGE}

\textbf{Abstract}

\end{LARGE}
\end{center}

\newpage
\thispagestyle{plain}
\tableofcontents
\clearpage

\newpage
\pagenumbering{arabic}
\lhead{Chapter 1: Introduction}
\section{Introduction}
\subsection{Introductory Note}
Test test bla bla bla bla bla bla blfwefmwefqermqfermfje n rnjnjfnj fnjnj nja fnejjna njnja nj anjnj nj nj vanjvnja njvnj venjvenj nj evnjnj eanjvnjnjve njvenjvnejjnevnjwerlnfwlefrefe
\subsection{Perforated Foundations}
\subsection{Perforation Ratio}
\subsection{Soil Behaviour}
\subsection{Aims of the Project}

\section{Obtaining Vertical Bearing Capacity for Benchmark Cases}

\newpage
\addcontentsline{toc}{section}{References}
references
\end{document}
lukaszskowron96
Posts: 36
Joined: Tue Oct 09, 2018 1:01 pm

How to change "1 Introduction" into "Chapter 1: Introduction"?

Post by lukaszskowron96 »

I had a play around with different techniques to achieve what I want. The closest to what I want I achieved via using:

Code: Select all

\usepackage{tocloft}
\setlength{\cftsecnumwidth}{0em}
Here's the result:

Image

There are two problems with this. Firstly, the number coincides with letters. Secondly, the dots between title and page number disappeared.

And there's one more thing. I still need to get rid of this circled "1".

Image

Anyone with any ideas how to resolve these problems?
lukaszskowron96
Posts: 36
Joined: Tue Oct 09, 2018 1:01 pm

How to change "1 Introduction" into "Chapter 1: Introduction"?

Post by lukaszskowron96 »

Ok, I managed to get what I want by using:

Code: Select all

\usepackage[nobottomtitles*]{titlesec}
\usepackage{titletoc}
\usepackage{ifthen}

\titlecontents{section}
   [0em]
   {}{}
   {\hspace*{-0em}}
   {\space\titlerule*[1pc]{.}\contentspage}

\titleformat{\section}[runin]
   {\normalfont\LARGE\bfseries}
   {}{0pt}{}
   [\ifthenelse{\equal{\thesection}{0}}{\\\vspace*{0pt}}]
Image

Image

NOW, the only last problem I have with this is to have "Chapter 1: Introduction ..... 1" and "Chapter 2: ..." and "References" in bold, does anyone know how to do that?

EDIT: I forgot to mention that of course the code above has to go into the preamble.
lukaszskowron96
Posts: 36
Joined: Tue Oct 09, 2018 1:01 pm

How to change "1 Introduction" into "Chapter 1: Introduction"?

Post by lukaszskowron96 »

Ok, I sorted it out.

Just have to change

Code: Select all

\titlecontents{section}
   [0em]
   {}{}
   {\hspace*{-0em}}
   {\space\titlerule*[1pc]{.}\contentspage}
into:

Code: Select all

\titlecontents{section}
   [0em]
   {\bfseries}{}
   {\hspace*{-0em}}
   {\space\titlerule*[1pc]{.}\contentspage}
Therefore I achieved everything I wanted.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

How to change "1 Introduction" into "Chapter 1: Introduction"?

Post by Stefan Kottwitz »

Good to hear that you solved it! I was just traveling and could not run TeX. So good to read that it's fine now.

Stefan
LaTeX.org admin
Post Reply