
我想用來titlesec
對章節和章節標題進行一些修改,但titleformat
完全重新定義格式,而不僅僅是進行修改(例如,如果我只想更改顏色)。
我如何titlesec
修改而不是完全重新定義?這可能嗎?
如果不是,我如何找出什麼是目前的\chapter
、等的格式\section
以便我可以複製它並進行修改?
為了回應範例文件的請求,我想最基本的是:
\documentclass{article}
\begin{document}
\section{Hello World}
Hello world!
\end{document}
然而,我感興趣的是一種找出(例如列印出)當前格式的方法,\section
而不是簡單地「了解」特定配置的格式。
答案1
對於標題顏色等簡單修改,您可以使用 的精簡版本\titleformat
,但必須檢查article.cls
(或report
、或book
)參數值(字體大小、粗細、形狀)。
這是一個例子:
\documentclass[a4paper]{article}
\usepackage[svgnames]{xcolor}
\usepackage{titlesec}
\titleformat*{\section}{\color{IndianRed}\normalfont\bfseries\Large}
\begin{document}
\section{A short title}
This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph.
\end{document}
答案2
標準類別定義如下(複製自titlesec
參考,第 8.2 節)
\titleformat{\chapter}[display]
{\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\Huge}
\titleformat{\section}
{\normalfont\Large\bfseries}{\thesection}{1em}{}
\titleformat{\subsection}
{\normalfont\large\bfseries}{\thesubsection}{1em}{}
\titleformat{\subsubsection}
{\normalfont\normalsize\bfseries}{\thesubsubsection}{1em}{}
\titleformat{\paragraph}[runin]
{\normalfont\normalsize\bfseries}{\theparagraph}{1em}{}
\titleformat{\subparagraph}[runin]
{\normalfont\normalsize\bfseries}{\thesubparagraph}{1em}{}
\titlespacing*{\chapter} {0pt}{50pt}{40pt}
\titlespacing*{\section} {0pt}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
\titlespacing*{\subsection} {0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
\titlespacing*{\subsubsection}{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
\titlespacing*{\paragraph} {0pt}{3.25ex plus 1ex minus .2ex}{1em}
\titlespacing*{\subparagraph} {\parindent}{3.25ex plus 1ex minus .2ex}{1em}