我想更改章节标题(即 blablabla)和章节标题(第 1 章)的大小,反之亦然。
\documentclass[10pt]{book}
\usepackage{titlesec}
\usepackage{fancyhdr}
\titleformat*{\section}{\large\bfseries}
\begin{document}
\chapter{blablabla}
\section{hello}
\end{document}
答案1
类book
使用\Huge
为第一行,Chapter xy
并\huge
使用 为章节标题。它用于宏\@makechapterhead
。以下示例更改大小宏。
\documentclass[10pt]{book}
\usepackage{etoolbox}
\makeatletter
% Size of chapter titles changed from \Huge to \huge
\patchcmd\@makechapterhead{\Huge}{\huge}{}{%
\errmessage{First patching \noexpand\@makechapterhead failed}%
}
\patchcmd\@makeschapterhead{\Huge}{\huge}{}{%
\errmessage{Patching \noexpand\@makeschapterhead failed}%
}
% Size of first chapter head line of numbered chapters
% changed from \huge to \Huge
\patchcmd\@makechapterhead{\huge}{\Huge}{}{%
\errmessage{Second patching \noexpand\@makechapterhead failed}%
}
\makeatother
\begin{document}
\chapter{blablabla}
\section{hello}
\end{document}
答案2
下面我定义\swapHugehuge
和,\revertHugehuge
交换重新定义的\Huge
和的定义:\huge
\chapter
\documentclass{book}
\usepackage{xparse}
% Store original \huge and \Huge definitions
\let\oldHuge\Huge\let\oldhuge\huge
\let\oldchapter\chapter% Store original \chapter
% Define swapping/reverting mechanism
\newcommand{\swapHugehuge}{\let\huge\oldHuge\let\Huge\oldhuge}
\newcommand{\revertHugehuge}{\let\huge\oldhuge\let\Huge\oldHuge}
\RenewDocumentCommand{\chapter}{s o m}{%
\swapHugehuge
\IfBooleanTF{#1}
{\oldchapter*{#3}}% \chapter*{..}
{\IfValueTF{#2}
{\oldchapter[#2]{#3}}% \chapter[.]{..}
{\oldchapter{#3}}% \chapter{..}
}%
\revertHugehuge
}
\begin{document}
\chapter{A chapter}
\section{A section}
\end{document}