# How to set the chapter, section, and default text to specific proportion widths?

I have the following MVP:

\documentclass[a4paper]{book}

\renewcommand{\contentsname}{Contents}

\usepackage{fontspec}
\usepackage{fullpage}
\usepackage{geometry}
\usepackage{sectsty}
\hypersetup{
citecolor=black,
filecolor=black,
urlcolor=black
}
\setmainfont{MyMonospaceFont}
\newlength{\characterwidth}
\settowidth{\characterwidth}{\normalfont x}
\geometry{margin=0.7in,textwidth=96\characterwidth,lines=48}
\AtBeginDocument{\raggedright\setlength{\parindent}{3\characterwidth}}
\frenchspacing
\begin{document}
\title{xyz}
\maketitle
\tableofcontents

\chapter{Foo}
\section*{A}
hello world
\section*{B}
\section*{C}
\chapter{Bar}
\end{document}


I would like for the default font character width to be let's say 12pt, and then have the section width be 18pt, and the chapter be 24pt. Or perhaps 12pt 24pt 48pt. But in either case, I'm wondering how to do it.

I looked at these places:

But they don't go far enough into answer it and I'm stuck. For example, they explain \chaptertitlefont{\Huge}, but not how to use 48pt there, like \chaptertitlefont{48pt} just shows up as 48ptFoo. I've run into many issues with the answers, so wondering if one could help.

• I think this should steer you in the right direction: Specify font point size – malvoisen Aug 21 at 11:41
• \\fontsize{48pt}{60pt}\selectfont in \titleformat (from titlesec) should to the trick. – Bernard Aug 21 at 13:03
• @Bernard, even for a monospaced font? – Lance Pollard Aug 21 at 13:38
• @Bernard \titleformat*{\chapter}{\fontsize{48pt}{60pt}\selectfont} or \titleformat*{\section}{\fontsize{48pt}{60pt}\selectfont} don't have any effect on the corresponding text. – Lance Pollard Aug 21 at 13:44
• Try with \titleformat (without *) which requires 5 arguments. – Bernard Aug 21 at 14:05

\documentclass[a4paper,12pt]{book}

\renewcommand{\contentsname}{Contents}

\usepackage{fontspec}
\usepackage{fullpage}
\usepackage{geometry}
\usepackage{sectsty}
\hypersetup{
citecolor=black,
filecolor=black,
urlcolor=black
}
\newlength{\characterwidth}
\settowidth{\characterwidth}{\normalfont x}
\geometry{margin=0.7in,textwidth=96\characterwidth,lines=48}
\AtBeginDocument{\raggedright\setlength{\parindent}{3\characterwidth}}
\frenchspacing

\chapterfont{\fontsize{24pt}{30pt}\selectfont} %<---
\sectionfont{\fontsize{18pt}{24pt}\selectfont} %<---
\begin{document}
\chapter{Foo}
\section*{A}
hello world
\section*{B}
\section*{C}
\end{document}