LaTeX forum ⇒ Page LayoutHow 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"?

Postby lukaszskowron96 » Fri Oct 26, 2018 10:24 pm

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:

  1. \documentclass{article}
  2. \begin{document}
  3. \section{Introduction}
  4. \subsection{Introductory Note}
  5. Some text
  6. \section{More stuff}
  7. \subsection{Even more stuff}
  8. Some text
  9. \end{document}

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

Postby Stefan Kottwitz » Sat Oct 27, 2018 1:14 am

Hi,

change article to report and \section to \chapter.

Stefan
Site admin

lukaszskowron96
Posts: 36
Joined: Tue Oct 09, 2018 1:01 pm

Postby lukaszskowron96 » Sat Oct 27, 2018 1:32 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.

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

Postby Stefan Kottwitz » Sat Oct 27, 2018 1:37 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

Postby lukaszskowron96 » Sat Oct 27, 2018 5:29 pm

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:
  1. \documentclass[toc=sectionentrywithdots,a4paper,11pt]{scrartcl}
  2. \usepackage{graphicx}
  3.  
  4. \usepackage{setspace}
  5. \doublespacing
  6.  
  7. \usepackage[a4paper, left=20mm, right=20mm, top=20mm]{geometry}
  8.  
  9. \usepackage{pdfpages}
  10.  
  11. \usepackage{fancyhdr}
  12. \pagestyle{fancy}
  13. \rhead{ }
  14. \lhead{ }
  15. \thispagestyle{empty}
  16.  
  17. \usepackage{lipsum}
  18.  
  19. \setcounter{page}{1}
  20.  
  21. \renewcommand{\rmdefault}{phv}
  22. \renewcommand{\sfdefault}{phv}
  23.  
  24. \usepackage[margin=0pt,font=normalsize]{subcaption}
  25.  
  26. \counterwithin{figure}{section}
  27.  
  28. \begin{document}
  29. \pagenumbering{gobble}
  30. \setcounter{page}{0}
  31.  
  32. \newpage
  33. \pagenumbering{roman}
  34. \thispagestyle{plain}
  35. \begin{center}
  36. \begin{LARGE}
  37.  
  38. \textbf{Abstract}
  39.  
  40. \end{LARGE}
  41. \end{center}
  42.  
  43. \newpage
  44. \thispagestyle{plain}
  45. \tableofcontents
  46. \clearpage
  47.  
  48. \newpage
  49. \pagenumbering{arabic}
  50. \lhead{Chapter 1: Introduction}
  51. \section{Introduction}
  52. \subsection{Introductory Note}
  53. 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
  54. \subsection{Perforated Foundations}
  55. \subsection{Perforation Ratio}
  56. \subsection{Soil Behaviour}
  57. \subsection{Aims of the Project}
  58.  
  59. \section{Obtaining Vertical Bearing Capacity for Benchmark Cases}
  60.  
  61. \newpage
  62. \addcontentsline{toc}{section}{References}
  63. references
  64. \end{document}

lukaszskowron96
Posts: 36
Joined: Tue Oct 09, 2018 1:01 pm

Postby lukaszskowron96 » Sun Oct 28, 2018 8:30 pm

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

  1. \usepackage{tocloft}
  2. \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

Postby lukaszskowron96 » Sun Oct 28, 2018 9:06 pm

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

  1. \usepackage[nobottomtitles*]{titlesec}
  2. \usepackage{titletoc}
  3. \usepackage{ifthen}
  4.  
  5. \titlecontents{section}
  6. [0em]
  7. {}{}
  8. {\hspace*{-0em}}
  9. {\space\titlerule*[1pc]{.}\contentspage}
  10.  
  11. \titleformat{\section}[runin]
  12. {\normalfont\LARGE\bfseries}
  13. {}{0pt}{}
  14. [\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

Postby lukaszskowron96 » Mon Oct 29, 2018 6:25 pm

Ok, I sorted it out.

Just have to change

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


into:

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


Therefore I achieved everything I wanted.

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

Postby Stefan Kottwitz » Mon Oct 29, 2018 8:27 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