![自定义单个部分](https://linux22.com/image/399457/%E8%87%AA%E5%AE%9A%E4%B9%89%E5%8D%95%E4%B8%AA%E9%83%A8%E5%88%86%20.png)
答案1
我已经意识到类似顶部的图片的东西并定制一个单个部分,但我有三个问题。第一个是自定义部分的标题太小。第二个在主题表中自定义部分的标题被切成两半。第三所有遵循自定义部分的非自定义部分都与自定义部分相同。看看下面的图片。
\documentclass{report}
\usepackage{trace}
\usepackage{xcolor}
\usepackage[explicit]{titlesec}
\definecolor{sec}{RGB}{0,163,243}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%% OK! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\makeatletter
\newcommand\mysec[2][\DefaultOpt]{%
\titleformat{\section}[hang]{\sffamily\Huge\bfseries}{}{0.5ex}%
{\begin{minipage}{1\textwidth}%
\noindent
\color{sec}%
\llap{\vrule width\textwidth height2ex depth0ex\hskip0.75ex}%
\textcolor{sec}{\unskip#1}%
\hskip0.75ex%
\rlap{\vrule width\textwidth height2ex depth0ex}%
\end{minipage}}[\smallskip]%
\def\DefaultOpt{#2}%
\section[#1]{#2}%
}
\makeatother
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\tableofcontents
\chapter{The first chapter}
\section{Normal section}
Some text
\mysec{The first \\ section}
Some text
\section{The second section}
Some text
\section{The third section}
\end{document}