0

I have the following MVP:

\documentclass[a4paper]{book}

\renewcommand{\contentsname}{Contents}

\usepackage{fontspec}
\usepackage{fullpage}
\usepackage{geometry}
\usepackage{sectsty}
\usepackage[hidelinks]{hyperref}
\hypersetup{
  colorlinks,
  citecolor=black,
  filecolor=black,
  linkcolor=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.

Lance
  • 1,799

1 Answers1

1

As you are loading sectsty you can use its commands:

\documentclass[a4paper,12pt]{book}

\renewcommand{\contentsname}{Contents}

\usepackage{fontspec}
\usepackage{fullpage}
\usepackage{geometry}
\usepackage{sectsty}
\usepackage[hidelinks]{hyperref}
\hypersetup{
  colorlinks,
  citecolor=black,
  filecolor=black,
  linkcolor=black,
  urlcolor=black
}
\setmainfont{TeX Gyre Heros} %adapt
\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}
Ulrike Fischer
  • 327,261