
Я хотел бы добавить символ «|» или вертикальную линию в заголовок главы, чтобы он выглядел так:
Вот исходный код:
\documentclass[svgnames]{book}
\usepackage{tikz}
\usepackage{kpfonts}
\usepackage[explicit]{titlesec}
\newcommand*\chapterlabel{}
\titleformat{\chapter}
{\gdef\chapterlabel{}
\normalfont\sffamily\Huge\bfseries\scshape}
{\gdef\chapterlabel{\thechapter\ }}{0pt}
{\begin{tikzpicture}[remember picture,overlay]
\node[yshift=-3cm] at (current page.north west)
{\begin{tikzpicture}[remember picture, overlay]
\draw[fill=LightSkyBlue] (0,0) rectangle
(\paperwidth,3cm);
\node[anchor=east,xshift=.9\paperwidth,rectangle,
rounded corners=20pt,inner sep=11pt,
fill=MidnightBlue]
{\color{white}\chapterlabel#1};
\end{tikzpicture}
};
\end{tikzpicture}
}
\titlespacing*{\chapter}{0pt}{50pt}{-60pt}
\begin{document}
\tableofcontents
\chapter{Decision Trees}
Text
\chapter{Main}
\section{Section}
Text
\begin{thebibliography}{99}
\bibitem{Test} test reference
\end{thebibliography}
\end{document}
решение1
\chapterlabel #1
место для вставки вертикальной линии. \chapterlabel
либо пусто для ненумерованных глав, либо содержит номер главы, включая конечный пробел.
Вертикальную линию можно добавить с помощью \vrule
. Ширину можно настроить с помощью ключевого слова width
: \vrule width 1pt
. Высота и глубина зависят от высоты и глубины линии и могут различаться в разных главах. Постоянное правило доступно как $|$
. Последнее в жирной версии используется в следующем примере:
\documentclass[svgnames]{book}
\usepackage{tikz}
\usepackage{kpfonts}
\usepackage[explicit]{titlesec}
\newcommand*\chapterlabel{}
\titleformat{\chapter}
{\gdef\chapterlabel{}
\normalfont\sffamily\Huge\bfseries\scshape}
{\gdef\chapterlabel{\thechapter\ }}{0pt}
{\begin{tikzpicture}[remember picture,overlay]
\node[yshift=-3cm] at (current page.north west)
{\begin{tikzpicture}[remember picture, overlay]
\draw[fill=LightSkyBlue] (0,0) rectangle
(\paperwidth,3cm);
\node[anchor=east,xshift=.9\paperwidth,rectangle,
rounded corners=20pt,inner sep=11pt,
fill=MidnightBlue]
{\color{white}%
\ifx\chapterlabel\empty
\else
\chapterlabel $\boldsymbol{|}$ %
\fi
#1};
\end{tikzpicture}
};
\end{tikzpicture}
}
\titlespacing*{\chapter}{0pt}{50pt}{-60pt}
\begin{document}
\tableofcontents
\chapter{Decision Trees}
Text
\chapter{Main}
\section{Section}
Text
\begin{thebibliography}{99}
\bibitem{Test} test reference
\end{thebibliography}
\end{document}
Страница 3:
Страница 7: