章节样式与表格内容样式不同

章节样式与表格内容样式不同

我尝试使用titlesectikz包来设计章节页面的样式,如下所示: http://www.texample.net/tikz/examples/fancy-chapter-headings/ 但我看到目录和参考书目页的样式与章节相同。如何在这 3 个页面中使用不同的样式?

答案1

您可以将定义与列表后面的文档主体中的\titleformat和一起移动\titlespacing,然后恢复原始样式,或者您可以定义两个命令:一个用于花式标题,另一个用于常规标题,这样您就可以随意在样式之间切换:

\documentclass[svgnames]{report}
\usepackage{tikz}
\usepackage{kpfonts}
\usepackage[explicit]{titlesec}
\newcommand*\chapterlabel{}

\newcommand\fancychapter{%
\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}
}
\newcommand\regularchapter{%
\titleformat{\chapter}[display]
  {\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\Huge##1}
\titlespacing*{\chapter}
  {0pt}{50pt}{40pt}
}
\begin{document}

\regularchapter
\tableofcontents
\listoffigures
\listoftables

\fancychapter
\chapter{Test Chapter One}
\chapter{Test Chapter Two}

\regularchapter
%Some additional chapter with the "regular" formatting

\end{document}

如果您正在使用book类,甚至可以挂接到\mainmatter和,以自动将更改应用于主要章节而不是部分\backmatter中的章节;类似这样的操作:\frontamatter\backmatter

\documentclass[svgnames]{book}
\usepackage{etoolbox}
\usepackage{tikz}
\usepackage{kpfonts}
\usepackage[explicit]{titlesec}
\newcommand*\chapterlabel{}

\newcommand\fancychapter{%
\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}
}
\newcommand\regularchapter{%
\titleformat{\chapter}[display]
  {\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\Huge##1}
\titlespacing*{\chapter}
  {0pt}{50pt}{40pt}
}

\apptocmd{\mainmatter}{\fancychapter}{}{}
\apptocmd{\backmatter}{\regularchapter}{}{}

\begin{document}

\frontmatter
\tableofcontents
\listoffigures
\listoftables

\mainmatter
\chapter{Test Chapter One}
\chapter{Test Chapter Two}

\backmatter
\appendix
\chapter{Test Chapter}
%The bibliography could be here

\end{document}

另一种选择(由埃格尔)是使用numberless和 的选项\titleformat有两个定义,允许对编号章节使用一种样式,对未编号章节使用另一种样式(初始列表、ToC、LoF、LoT 和参考书目通常使用 构建\chapter*)。在这种情况下,可以说

\documentclass[svgnames]{report}
\usepackage{tikz}
\usepackage{kpfonts}
\usepackage[explicit]{titlesec}
\newcommand*\chapterlabel{}

\titleformat{name=\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}

\titleformat{name=\chapter,numberless}[display]
  {\normalfont\huge\bfseries}{}{20pt}{\Huge#1}
\titlespacing*{\chapter}
  {0pt}{50pt}{40pt}

\begin{document}

\tableofcontents
\listoffigures
\listoftables

\chapter{Test Chapter One}
\chapter{Test Chapter Two}

%The bibliography could be here

\end{document}

相关内容