标题格式不适用于参考书目

标题格式不适用于参考书目

这是我用于将标题格式应用于章节的代码的 MWE。但它没有应用于我的参考书目章节。有什么想法吗?

\documentclass[a4paper,11pt]{report}

\usepackage{times}
\usepackage{makeidx}

\usepackage{tikz}
\usetikzlibrary{calc}
\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}

\usepackage{titlesec}

\titleformat{\chapter}[display]
{\bfseries\Large}
{\hfill \tikz[remember picture] \node[] (nr) {\huge\color{blue!50!black}\textbf{\thechapter}~~};
  \begin{tikzpicture}[remember picture,overlay]
    \coordinate (leftborder) at ($(nr)-(100,0)$);
    \coordinate (leftborderhigh) at ($(nr.north west)-(100,0)$);
    \coordinate (leftborderlow) at ($(nr.south west)-(100,0)$);
    \coordinate (left) at ($(nr.west)-(1.5,0)$);
    \path[shade, top color=blue!1,bottom color=blue!20] (leftborderhigh) -- ($(nr.north west)+(0,0.5)$) -- (left) -- (leftborder) -- cycle;
    \path[shade, top color=blue!20,bottom color=blue!1] (leftborderlow) -- ($(nr.south west)-(0,0.5)$) -- (left) -- (leftborder) -- cycle;
    \draw[blue!50!black,line width=0.1em,line join=round] (left) -- ($(nr.south west)-(0,0.5)$) -- ($(nr.south east)-(0,0.5)$) -- ($(nr.north east)+(0,0.5)$) -- ($(nr.north west)+(0,0.5)$) -- (left) -- (leftborder);
  \end{tikzpicture}}
{5ex}
{\filleft\LARGE\bf}
[\vspace{0ex}]

\makeindex

\begin{document}
\chapter{Introduction}
\chapter{Chapter about XXX}
\chapter{Chapter about YYY}
\chapter{Conclusion}
\bibliography{../references}
\end{document}

答案1

如果您不想要编号的参考书目,则需要使用 添加单独的自定义代码\titleformat{name=\chapter,numberless}。将以下内容添加到您的序言中(我曾经\phantom保留过 TikZ 装饰的大小):

\titleformat{name=\chapter,numberless}[display]
{\bfseries\Large}
{\hfill \tikz[remember picture] \node[] (nr) {\huge\color{blue!50!black}\phantom{\textbf{\thechapter}}~~};
  \begin{tikzpicture}[remember picture,overlay]
    \coordinate (leftborder) at ($(nr)-(100,0)$);
    \coordinate (leftborderhigh) at ($(nr.north west)-(100,0)$);
    \coordinate (leftborderlow) at ($(nr.south west)-(100,0)$);
    \coordinate (left) at ($(nr.west)-(1.5,0)$);
    \path[shade, top color=blue!1,bottom color=blue!20] (leftborderhigh) -- ($(nr.north west)+(0,0.5)$) -- (left) -- (leftborder) -- cycle;
    \path[shade, top color=blue!20,bottom color=blue!1] (leftborderlow) -- ($(nr.south west)-(0,0.5)$) -- (left) -- (leftborder) -- cycle;
    \draw[blue!50!black,line width=0.1em,line join=round] (left) -- ($(nr.south west)-(0,0.5)$) -- ($(nr.south east)-(0,0.5)$) -- ($(nr.north east)+(0,0.5)$) -- ($(nr.north west)+(0,0.5)$) -- (left) -- (leftborder);
  \end{tikzpicture}}
{5ex}
{\filleft\LARGE\bf}
[\vspace{0ex}]

相关内容