如何改变章节样式?

如何改变章节样式?

我该如何更改章节样式才能得到类似这样的内容?字体类型并不重要,但我希望章节名称位于章节编号下方。在此处输入图片描述

此时我的代码如下所示。不知为何我的文本无法达到该数字。

\documentclass[a4paper,11pt,oneside,openany]{report}
\usepackage{titlesec}
\usepackage[dvipsnames]{xcolor}
\usepackage{xcolor}
\usepackage{fix-cm}
\usepackage{eso-pic}
\usepackage{sectsty}

\definecolor{col1}{RGB}{102, 102, 102}
\definecolor{col2}{RGB}{112, 154, 184}
\definecolor{col3}{RGB}{229, 208, 146}
\definecolor{col4}{RGB}{213, 151, 80}
\definecolor{col5}{RGB}{66, 51, 63}
\definecolor{col6}{RGB}{180, 104, 84}
\definecolor{col7}{RGB}{215, 208, 198}
\definecolor{shadecolor}{RGB}{215, 208, 198}

\newcommand{\hsp}{\hspace{20pt}}
\newcommand\CHAP{\fontsize{100}{60}\selectfont}
\newcommand\CHAPTER{\fontsize{48}{60}\selectfont}
\titleformat{\chapter}[hang]{\CHAP\bfseries}{\thechapter\hsp\textcolor{black}{.}\hsp}{0pt}{\newline\CHAPTER\bfseries}
\titlespacing{\chapter}{0mm}{-4mm}{4mm}
\titlespacing{\section}{0mm}{4mm}{4mm}
\titlespacing{\subsection}{0mm}{4mm}{4mm}
\titleformat*{\section}{\normalfont\Large\bfseries}
\titleformat*{\subsection}{\normalfont\large\bfseries}
\titleformat*{\subsubsection}{\normalfont\normalsize\bfseries}

\begin{document}

%%%%%%%%%%%% Chapter page %%%%%%%%%%%%
\chapter{Introduction}\label{Introduction}\noindent
\thispagestyle{empty}
\AddToShipoutPictureBG*{\AtTextLowerLeft{\textcolor{col2}{\rule{\textwidth}{\textheight}}}}

% Intro
\noindent
blablablabla

\newpage
\end{document}

答案1

尝试一下这个代码。

(1)使用display而不是hang作为章节标题格式。

(2)扩大背景图像,使其比文本区域更宽、更高。

(3) 点间距更小,以ex单位表示。

A

\documentclass[a4paper,11pt,oneside,openany]{report}
\usepackage{titlesec}
\usepackage[dvipsnames]{xcolor}

\usepackage{fix-cm}
\usepackage{eso-pic}
\usepackage{sectsty}

\definecolor{col1}{RGB}{102, 102, 102}
\definecolor{col2}{RGB}{112, 154, 184}
\definecolor{col3}{RGB}{229, 208, 146}
\definecolor{col4}{RGB}{213, 151, 80}
\definecolor{col5}{RGB}{66, 51, 63}
\definecolor{col6}{RGB}{180, 104, 84}
\definecolor{col7}{RGB}{215, 208, 198}
\definecolor{shadecolor}{RGB}{215, 208, 198}

\newcommand{\hsp}{\hspace{0.01ex}}% changed <<<<<<<<<<<
\newcommand\CHAP{\fontsize{100}{60}\selectfont}
\newcommand\CHAPTER{\fontsize{48}{60}\selectfont}
\titleformat{\chapter}[display]{\CHAP\bfseries}{\thechapter\hsp\textcolor{black}{.}\hsp}{0pt}{\CHAPTER\bfseries}% changed <<<<<<<<<<<
\titlespacing{\chapter}{0mm}{-4mm}{4mm}
\titlespacing{\section}{0mm}{4mm}{4mm}
\titlespacing{\subsection}{0mm}{4mm}{4mm}
\titleformat*{\section}{\normalfont\Large\bfseries}
\titleformat*{\subsection}{\normalfont\large\bfseries}
\titleformat*{\subsubsection}{\normalfont\normalsize\bfseries}

\usepackage{kantlipsum}% ONLy dummy text <<<<<<<<<<<<<<<
\begin{document}
    
    %%%%%%%%%%%% Chapter page %%%%%%%%%%%%
    \chapter{Introduction}\label{Introduction}\noindent
    \thispagestyle{empty}
    \AddToShipoutPictureBG*{\put (1in,1in){\textcolor{col2}{\rule{\dimexpr\paperwidth-2in}{\dimexpr\paperheight-2in}}}} % changed <<<<<<<<<<<
    
    % Intro
    \noindent\kant[1]   
    \newpage    

\end{document}

相关内容