LaTeX forum ⇒ Page Layout ⇒ How to change "1 Introduction" into "Chapter 1: Introduction"? Topic is solved

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

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

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:

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

Stefan Kottwitz
Site Admin
Posts: 9388
Joined: Mon Mar 10, 2008 9:44 pm
Hi,

change article to report and \section to \chapter.

Stefan
Site admin

lukaszskowron96
Posts: 36
Joined: Tue Oct 09, 2018 1:01 pm
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.

Stefan Kottwitz
Site Admin
Posts: 9388
Joined: Mon Mar 10, 2008 9:44 pm
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
Site admin

lukaszskowron96
Posts: 36
Joined: Tue Oct 09, 2018 1:01 pm
Ok, I changed that but there are some more problems:

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

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.

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

Here's the code I am actually using:

lukaszskowron96
Posts: 36
Joined: Tue Oct 09, 2018 1:01 pm
I had a play around with different techniques to achieve what I want. The closest to what I want I achieved via using:

\usepackage{tocloft}\setlength{\cftsecnumwidth}{0em}

Here's the result:

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".

Anyone with any ideas how to resolve these problems?

lukaszskowron96
Posts: 36
Joined: Tue Oct 09, 2018 1:01 pm
Ok, I managed to get what I want by using:

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

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
Ok, I sorted it out.

Just have to change

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

into:

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

Therefore I achieved everything I wanted.

Stefan Kottwitz
Site Admin
Posts: 9388
Joined: Mon Mar 10, 2008 9:44 pm
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
Site admin

Return to “Page Layout”

Who is online

Users browsing this forum: No registered users and 2 guests