Text FormattingChapter font size

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
QwareeqMathematics
Posts: 68
Joined: Mon Jul 06, 2009 7:44 pm

Chapter font size

Post by QwareeqMathematics »

I like to control the chapters font size like (12pt,14pt,....etc) . For sure, I don't need any change on TOC chapter fonts. Because , some of the solutions I found (on google) make a change on TOC chapters fonts

Also, how to control section/subsection font size. ...

Here is my preamble :

Code: Select all

\documentclass[12pt,a4paper,dvipdfm]{report}
\usepackage[left=3.5cm,right=2.5cm,top=2.5cm]{geometry}
\usepackage{enumerate}
\setlength{\textheight}{780pt}
\usepackage[dvipdfm]{hyperref}
\usepackage{amssymb,latexsym,amsmath,mathrsfs,array,epsfig,tikz}
\usepackage{color,amstext,amsbsy,amsopn,amsthm,amscd,amsxtra,amsfonts,setspace}
\renewcommand{\thechapter}{\Roman{chapter}}
\renewcommand{\contentsname}{List of Contents}
\renewcommand{\bibname}{References}
%------------------
\usepackage{titlesec}
\titleformat{\chapter}[display]
  {\normalfont\sffamily\huge\bfseries\color{blue}}
  {\chaptertitlename\ \thechapter}{20pt}{\Huge}
\titleformat{\section}
  {\normalfont\sffamily\Large\bfseries\color{cyan}}
  {\thesection}{1em}{}
  
  %-----------------------

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\chead{\thepage}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\numberwithin{figure}{section}
\newcommand*\mycirc[1]{%
  \begin{tikzpicture}[baseline=(C.base)]
    \node[draw,circle,inner sep=1pt](C) {#1};
  \end{tikzpicture}}

\setcounter{secnumdepth}{3}
%----------------------------------------------------------------------------------------------
%Change the place of chapter and decreasing lines

\makeatletter
\let\ps@plain\ps@fancy % This line for page number
\def\@makechapterhead#1{%
  \vspace*{-50\p@}% default: 50pt
  {\parindent \z@ \centering \normalfont% default: \raggedright
    \ifnum \c@secnumdepth >\m@ne
        \huge\bfseries\sc \@chapapp\space \thechapter
        \par\nobreak
        \vskip 0\p@% default: 20\p@
    \fi
    \interlinepenalty\@M
    \Huge \bfseries #1\par\nobreak
    \vskip 15\p@
  }}
\def\@makeschapterhead#1{%
  \vspace*{-50\p@}% default: 50pt
  {\parindent \z@ \centering% default: \raggedright
    \normalfont
    \interlinepenalty\@M
    \Huge \bfseries  #1\par\nobreak
    \vskip 15\p@
  }}
\makeatother
%----------------------------------------------------------------------------------------------
\setlength{\headheight}{14pt} %To avoid error for page numbers

\begin{document}

\chapter{chapter title test}

\section{section title test}



\end{document}


I found a post in this forum and I tried the code :

Code: Select all

\usepackage{titlesec}
\titleformat{\chapter}[block]{\centering\fontsize{10pt}{16pt}\selectfont}{\chaptertitlename~\thechapter.}{12pt}{}
But there is nothing happened .

I think the problem in this code in my preamble :

Code: Select all

\makeatletter
\let\ps@plain\ps@fancy % This line for page number
\def\@makechapterhead#1{%
  \vspace*{-50\p@}% default: 50pt
  {\parindent \z@ \centering \normalfont% default: \raggedright
    \ifnum \c@secnumdepth >\m@ne
        \huge\bfseries\sc \@chapapp\space \thechapter
        \par\nobreak
        \vskip 0\p@% default: 20\p@
    \fi
    \interlinepenalty\@M
    \Huge \bfseries #1\par\nobreak
    \vskip 15\p@
  }}
\def\@makeschapterhead#1{%
  \vspace*{-50\p@}% default: 50pt
  {\parindent \z@ \centering% default: \raggedright
    \normalfont
    \interlinepenalty\@M
    \Huge \bfseries  #1\par\nobreak
    \vskip 15\p@
  }}
\makeatother
I have no idea how to fix it


Thanks

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Chapter font size

Post by Johannes_B »

Welcome,

the solution with package titlesec gives you an easy interface to change spacing and appearance of not only the chapter, but also section, subsections etc.

That second block you posted uses the very low level stuff that defines a chapter heading, which is quite hard for new users. Try to put a percent sign (%) at the beginning of every line of that block and try again.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
QwareeqMathematics
Posts: 68
Joined: Mon Jul 06, 2009 7:44 pm

Re: Chapter font size

Post by QwareeqMathematics »

I can't remove that codes , since it is a settings for the thesis. Of course, when I remove the codes. everything get works with titlesec... But I could not get the same settings using titlesec with controlling the size..

and to be honest I could not understand everything in titlesec...


So, may you help by that. Thanks
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Chapter font size

Post by Johannes_B »

If your thesis class/package sets this stuff, it seems like you are supposed to typeset your thesis that way. Some universities, especially in the USA, have very strict requirement with respect to the layout. I wouldn't change that.

I cannot help any further without a minimal working example.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
QwareeqMathematics
Posts: 68
Joined: Mon Jul 06, 2009 7:44 pm

Re: Chapter font size

Post by QwareeqMathematics »

These settings done by me and the guys here in this forum as the university needs before couples of years. Now it needs a new settings by resizing the chapter (section..) font .

Anyway, I will try again with titlesec package and if I couldn't fix it as I like. I will put a minimal example.

Thanks ;)
Post Reply