复制特定章节样式

复制特定章节样式

我想在 LaTeX 中复制以下章节样式,以便标题页看起来像下面的模拟图像。我该如何实现这一点?

在此处输入图片描述

这是一个很好的起点。我不希望在目录页上有包含“第…章”的上框,所以只需将下行的“关于 LaTeX 的更多信息”文本替换为“目录”,就像下面的参考文档一样,

\documentclass[11pt]{book}
\usepackage[pass,paperwidth=6.85in,paperheight=9.3in]{geometry}
\usepackage[nottoc]{tocbibind}
\usepackage{titlesec}
\usepackage[titles]{tocloft}


\renewcommand\cftchapfont{\normalfont}
\renewcommand\cftchappagefont{\normalfont}

\AtBeginDocument{\renewcommand\contentsname{Table of Contents}}

\titleformat{\chapter}[display]
{}{\hfill\rule{.7\textwidth}{3pt}}{0pt}
{\hspace*{.3\textwidth}\huge\bfseries}[\addvspace{-1pt}]
\titleformat{name=\chapter,numberless}[display]
{}{\hfill\rule{.7\textwidth}{3pt}}{0pt}
{\hspace*{.3\textwidth}\huge\bfseries}[\addvspace{-1pt}]

\begin{document}

\frontmatter
\tableofcontents
\listoftables
\listoffigures

\mainmatter
\chapter{Test Chapter}
\section{Test Subsection}

\end{document}

得到:

在此处输入图片描述

我在下面添加了我想要实现的目标的模型。

在此处输入图片描述

答案1

以下是基于以下的简单建议:这个答案, 也这个答案这个答案

\documentclass[11pt]{book}
\usepackage[pass,paperwidth=6.85in,paperheight=9.3in]{geometry}
\usepackage[nottoc]{tocbibind}
\usepackage[explicit]{titlesec}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usepackage[titles]{tocloft}
\usepackage{lipsum}

\AtBeginDocument{\renewcommand\contentsname{Table of Contents}}
\renewcommand\cftchapfont{\normalfont}
\renewcommand\cftchappagefont{\normalfont}

% based on https://tex.stackexchange.com/a/335945/121799
\newcommand\CustomChapterTitle[2][]{%
\begin{tikzpicture}
    \path(0,0) coordinate (O);
    \node (A) [right=0.3\textwidth of O,
    rectangle,minimum width=0.7\textwidth, minimum height=1cm,
    text=green!40!black, text width=0.7\textwidth-3mm,align=left,
    path picture={\draw[line width=1mm,orange] (path picture bounding box.south west) |- 
     (path picture bounding box.north east);},
    #1] 
    {#2};
\end{tikzpicture}
}
\newcommand\CustomSectionTitle[2][]{%
\begin{tikzpicture}
    \path(0,0) coordinate (O);
    \node (A) [right=0.45\textwidth of O,
    rectangle,minimum width=0.55\textwidth, minimum height=1cm,
    text=green!40!black, text width=0.55\textwidth-3mm,align=left,
    path picture={\draw[line width=1mm,orange] (path picture bounding box.north west) -- 
     (path picture bounding box.north east);},
    #1] 
    {#2};
\end{tikzpicture}
}
\titleformat{\chapter}[display]
{}{}{0em}
{\CustomChapterTitle[font=\huge\bfseries]{#1}}
\titleformat{name=\chapter,numberless}[display]
{}{}{0em}
{\CustomChapterTitle[font=\huge\bfseries]{#1}}
\titleformat{\section}[display]
{}{}{0em}
{\CustomSectionTitle[font=\large\bfseries]{#1}}
\titleformat{name=\section,numberless}[display]
{}{}{0em}
{\CustomSectionTitle[font=\large\bfseries]{#1}}


% Redefinition of ToC command to get centered heading
\makeatletter% from https://tex.stackexchange.com/a/157411/121799
\renewcommand\tableofcontents{%
  \section*{\contentsname
  \@mkboth{\MakeUppercase\contentsname}{\MakeUppercase\contentsname}}%
  \@starttoc{toc}%
}% from https://tex.stackexchange.com/a/173180/121799
\renewcommand\listoffigures{%
    \section*{\listfigurename
        \@mkboth{%
           \MakeUppercase\listfigurename}{\MakeUppercase\listfigurename}}
    \@starttoc{lof}%
}%
\renewcommand\listoftables{%
    \section*{\listtablename
        \@mkboth{%
           \MakeUppercase\listtablename}{\MakeUppercase\listtablename}}
    \@starttoc{lot}%
}%
\makeatother

\begin{document}

\frontmatter
\tableofcontents
\listoftables
\listoffigures

\mainmatter
\chapter{Test Chapter}
\section{Test Section}

\end{document}

在此处输入图片描述

在此处输入图片描述

相关内容