
我有以下 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}
我想為預設假設字型字元寬度為 12pt,然後節寬為 18pt,章節寬度為 24pt。或者也許是 12pt 24pt 48pt。但無論哪種情況,我都想知道該怎麼做。
我看了這些地方:
但他們的回答還不夠深入,我陷入了困境。例如,他們解釋了\chaptertitlefont{\Huge}
,但沒有解釋如何使用48pt
,就像\chaptertitlefont{48pt}
只是顯示為48ptFoo
。我在答案中遇到了很多問題,所以想知道是否可以提供幫助。
答案1
當您載入 sectsty 時,您可以使用它的命令:
\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}