2

I want to change fontsize of chapter headings to 18 pt, section headings to 16 pt, subsection headings to 14 pt with 1.5 linespacing in the report as per our univeristy guidelines. I use luatex. I have tried googling and tried below method, but it sets chapter heading font size to normal size

\documentclass[12pt,abstract = true,toc = flat,toc = bib,enabledeprecatedfontcommands]{scrreprt}
\usepackage{lipsum}
\addtokomafont{disposition}{\rmfamily}
\setkomafont{chapter}{\fontsize{18}{27}}
\begin{document}
\chapter{The first}
This a test chap
\section{The section}
We will see how to write report in below subsection
\subsection{little brother of section}
Write report according to your university guidelines
\lipsum[1-2]
\end{document}
4
  • 1
    Welcome to TeX.SX! You need to use \selectfont right after \fontsize{...}{...} for it to go into effect. See f.i. Sections titles font size. In your example, try using \setkomafont{chapter}{\fontsize{18}{27}\selectfont}.
    – marquinho
    Mar 4 at 9:46
  • 1
    Additionally you have to use a scalable font. Off topic: Why you are using option enabledepratedfontcommands?
    – esdd
    Mar 4 at 11:12
  • @marquinho Thank you very very much! I was strugglimg for days! Can you make your comment an answer?
    – Hemang
    Mar 4 at 12:02
  • @esdd our university has asked us to write references in aiche journal style, which uses AMA style, and a style file i used to meet that requirement, for bibtex used \it. So i had to use enabledepratedfontcommands to allow use of \it
    – Hemang
    Mar 4 at 12:06

1 Answer 1

1

The short answer

The direction \setkomafont{chapter}{\fontsize{18}{27}} is not working because you are missing the command \selectfont (immediately) after the specifications. It is this command that actually updates the font attributes. You can read about font selection commands in this guide, §2.2. In the given example, amend the line to this:

\setkomafont{chapter}{\fontsize{18}{27}\selectfont}

Advice you didn't ask for: which parameters to use for \fontsize?

The second argument of \fontsize sets, of course, the value of \baselineskip that is to be used along with the specified font size.

Since you are going for a document with one-and-a-half line spacing, you chose 27pt for a font size of 18pt (18ptx1.5). Instead, I would recommend to keep the default ratio between \baselineskip and the font size. The ratio corresponding to normal spacing in the standard document classes is 1.2. Thus, you get 21.6pt for \chapter, 19.2pt for \section, 16.8pt for \subsection.

Why? Because you will need to set a line spacing (of one and a half) for the body of your document, not just for the chapter and section headings. If you issue a global command to do so, this will scale all elements in the document proportionally, including the headings.

To do this, use \linespread{<factor>}. Be aware, though, that this factor does not map one-to-one onto the desired line spacing, because it needs to be compounded by the value of \baselineskip. And since \baselineskip is 1.2, for one-and-a-half spacing you will need \linespread{1.25}; for double spacing, you'd need something like \linespread{1.6667}.

So, to achieve the values given in your guidelines, you can use the following code (the command \thefontsize shows the font size in points):

\documentclass[12pt]{scrreprt}

\usepackage{lipsum}

\makeatletter
\newcommand\thefontsize{(Font size = \f@size pt)}
\makeatother

\addtokomafont{disposition}{\rmfamily}

\setkomafont{chapter}{\fontsize{18}{21.6}\selectfont}
\setkomafont{section}{\fontsize{16}{19.2}\selectfont}   
\setkomafont{subsection}{\fontsize{14}{16.8}\selectfont}

\linespread{1.25}

\begin{document}
\chapter{Chapter \thefontsize}
\lipsum[1]
\section{Section \thefontsize}
\lipsum[1]
\subsection{Subsection \thefontsize}
\lipsum[1]
\end{document}

On the left is the document in the specified format, on the right the same document with \linespread commented out. Note how all line spacing, including around the headings, is scaled proportionally.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.