如何制作这样的部分

如何制作这样的部分

如何制作像这样的章节和小节

在此处输入图片描述

答案1

你可以调整杰克的代码. 调整颜色和字体以适合您的喜好。

\documentclass{book}
\usepackage[explicit]{titlesec}
\usepackage{tikz}
\usetikzlibrary{shapes.misc,arrows}
%defining subsection titles
\newcommand\titlebar{%
\tikz[baseline,trim left=0cm,trim right=3cm] {    
    \node [
        text = red!70!green,
        anchor= base east,        
        minimum height=3.5ex] (a) at (3cm,0) {
        \textbf{\arabic{chapter}.\thesection}
    };
   \path[fill=red!70!blue] (a.east) circle (.5ex);
   \draw[color=red!70!blue, thick,rounded corners=1ex] (a.east) |- (\textwidth+1cm,-0.75ex);  
}%
}
\titleformat{\section}{\large\sf}{\titlebar}{0.25cm}{\textcolor{blue!60!green}{#1}}
\titlespacing*{\section}{-2cm}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
\renewcommand*{\thesection}{\arabic{section}}

%defining subsection titles
\newcommand\subtitlebar{%
\tikz[baseline,trim left=0cm,trim right=3cm] {
    \node [
        text = red!70!green,
        anchor= base east,
        minimum height=3.5ex] (b) at (3cm,0) {
        \textbf{\arabic{chapter}.\arabic{section}.\thesubsection}
    };
   \path[fill=red!70!blue] (b.east) circle (.5ex);
   \draw[color=red!70!blue, thick,rounded corners=1ex] (b.east) |- (\textwidth+0.8cm,-0.75ex);
}%
}

\titleformat{\subsection}{\normalfont\sf}{\subtitlebar}{0.2cm}{\textcolor{blue!60!green}{#1}}
\titlespacing*{\subsection}{-1.8cm}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
\renewcommand*{\thesubsection}{\arabic{subsection}}


\begin{document}
\chapter{Some chapter}
Some text here
\section{Some section}
Some text here
\subsection{Some sub section}
Some text here
\end{document}

在此处输入图片描述

相关内容