Chapters and Customized Chapters

Chapters and Customized Chapters #

Author: Er Hua

Keywords: chapters, customized chapters

In this section, we discuss the chapters of a document.

Chapters provided by LaTeX #

The chapter divisions in LaTeX are as follows:

These chapter divisions are automatically numbered, but if you use ※, they can be unnumbered and not included in the table of contents.

\chapter*{Name of the Chapter}
\section*{Name of the Section}
Both will not be numbered and displayed in the table of contents.
\secnumdepth % Controls the depth of section numbering.
\tocdepth % Controls the depth of section inclusion in the table of contents.
Can be modified in the preamble.

Customizing Chapters #

For Chinese, the ctex package provides the \ctexset or \CTEXsetup commands to set the format of chapter titles. #
------
\usepackage[heading = true]{ctex}
\ctexset{section = {optional = value, optional = value ...}, subsection = {}, ...}
------
\CTEXsetup[optional = value, optional = value, ...]{chapter, section, subsection, ...}
This is the form of setting. Some optional values and their corresponding values are as follows (for more, please refer to Chapter 8 of the ctex.pdf documentation).
\documentclass[]{article}
\usepackage[heading=true]{ctex}% Be sure to set heading to true
\usepackage[left = 30mm,right = 30mm]{geometry}
\newCJKfontfamily\qingsong{FZQKBYSJW--GB1-0}
\ctexset{section={name={第,节}, titleformat = {\qingsong}}}
\begin{document}
\section{锦瑟无端五十弦}
\section{一弦一柱思华年}
\section{庄生晓梦迷蝴蝶}
\section{望帝春深托杜鹃}
\end{document}

In addition to the ctex package, you can also use the titlesec package to customize. #

Additional Customizations for Chapters #

For specific usage, please refer to page 18 of the ctex package.
\ctexset{section = {name = {第,回}, titleformat = {\mysection}}}% Customize your own mysection type
\newcommand{\mysection}[1]{Specific appearance of mysection}

% Be sure to avoid manual line breaks in settings!!!!! % Keep each setting separate as much as possible.

\documentclass[]{article}
\usepackage[heading = true]{ctex}
% Be sure to avoid manual line breaks in settings!!!!!
\ctexset{section = {name = {第,回}, titleformat = {\mysection}, nameformat = {\qingsong\Huge}, numberformat = {\Huge}},}% Customize your own mysection type
\newcommand{\mysection}[1]{\Huge\qingsong #1}
% Keep each setting separate as much as possible.
\ctexset{subsection = {name = {第,项}, titleformat = {\mysubsection}, nameformat = {\large}}}
\newcommand{\mysubsection}[1]{\large\qingsong #1}

\usepackage{anyfontsize}
\usepackage{fontspec}
\newCJKfontfamily\qingsong{FZQKBYSJW--GB1-0}
\begin{document}
\section{我试试}
\subsection{试试就试试}
试试就试试
\end{document}

Note the following: