![使用 quotchap 包在章节号前添加单词“Chapter”](https://linux22.com/image/452325/%E4%BD%BF%E7%94%A8%20quotchap%20%E5%8C%85%E5%9C%A8%E7%AB%A0%E8%8A%82%E5%8F%B7%E5%89%8D%E6%B7%BB%E5%8A%A0%E5%8D%95%E8%AF%8D%E2%80%9CChapter%E2%80%9D.png)
我正在使用 quotchap 包,我希望在章节号前加上“章节”这个词,而不是仅仅有1,我希望第1章其余章节也采用这种格式,附录 A而不是仅仅拥有A。这是@Simon Dispa 很好地回答的问题的延续(https://tex.stackexchange.com/users/161015/simon-dispa) 在使用 quotchap 包为所有附录章节添加“附录”一词。
以下是我的 MWE:
\documentclass[11pt,openany,twoside]{book}
\raggedbottom
\let\cleardoublepage=\clearpage
\usepackage[left=2.5cm, right=2.5cm, top=3cm, bottom=3cm,a4paper]{geometry}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[table]{xcolor}
\usepackage{graphicx}
\newcommand\HRule{\noindent\rule{\linewidth}{1.5pt}}
\usepackage[dotinlabels]{titletoc}
\usepackage{background}
\backgroundsetup{contents={}}
\usepackage{fancyhdr}
\usepackage{hhline}
\pagestyle{fancy}
\usepackage[noindentafter,calcwidth]{titlesec}
\usepackage[courier]{quotchap}
\usepackage{helvet}
\renewcommand\sectfont{\bfseries}
\usepackage{calc,pifont}
\usepackage{multirow}
\newcommand*\myheaderfooterfont{\normalfont\bfseries}
\usepackage[nottoc]{tocbibind}
\usepackage[ragged]{sidecap}
\usepackage[marginal]{footmisc}
\renewcommand\footnoterule{\vspace*{-3pt}%
\hrule width 2in height 1.4pt \vspace*{2.6pt}}
\setlength\footnotemargin{10pt}
\usepackage{etoolbox}
\usepackage{regexpatch}
\usepackage{listings}
\usepackage{hyperref}
\hypersetup{
colorlinks=true,
linkcolor=blue,
}
\usepackage{apptools}
\begin{document}
\chapter{Backrre}
\end{document}
答案1
试试这个代码。它适用于章节和附录。
您可以通过修改定义来更改字体,颜色和位置\chapname
(并\appname
相应地)
% !TeX TS-program = pdflatex
\documentclass[11pt,openany,twoside]{book}
\usepackage[T1]{fontenc}% added <<<<<<
\raggedbottom
\let\cleardoublepage=\clearpage
\usepackage[left=2.5cm, right=2.5cm, top=3cm, bottom=3cm,a4paper]{geometry}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[table]{xcolor}
\usepackage{graphicx}
\newcommand\HRule{\noindent\rule{\linewidth}{1.5pt}}
\usepackage[dotinlabels]{titletoc}
\usepackage{background}
\backgroundsetup{contents={}}
\usepackage{fancyhdr}
\usepackage{hhline}
\pagestyle{fancy}
\usepackage[noindentafter,calcwidth]{titlesec}
\usepackage[courier]{quotchap}
\usepackage{helvet}
\renewcommand\sectfont{\bfseries}
\usepackage{calc,pifont}
\usepackage{multirow}
\newcommand*\myheaderfooterfont{\normalfont\bfseries}
\usepackage[nottoc]{tocbibind}
\usepackage[ragged]{sidecap}
\usepackage[marginal]{footmisc}
\renewcommand\footnoterule{\vspace*{-3pt}%
\hrule width 2in height 1.4pt \vspace*{2.6pt}}
\setlength\footnotemargin{10pt}
\usepackage{etoolbox}
\usepackage{regexpatch}
\usepackage{listings}
\usepackage{hyperref}
\hypersetup{
colorlinks=true,
linkcolor=blue,
}
\usepackage[toc,header]{appendix}
\usepackage{apptools}
\usepackage{showframe}
%************************************************** added
\usepackage{xstring}
\makeatletter
\patchcmd{\@makechapterhead}{\thechapter}{%
\IfSubStr{ABCDEFGHIJKLMNOPQRSTUVWXYZ}{\thechapter}{\appname\,\thechapter}{\chapname\,\thechapter}
}
\makeatother
\newcommand{\appname}{{\fontfamily{phv}\fontsize{22pt}{26pt}\selectfont\raisebox{1em}{\textcolor{red}{Appendix}}}} % set the appendix name <<<<<<<<<<<
\newcommand{\chapname}{{\fontfamily{phv}\fontsize{22pt}{26pt}\selectfont\raisebox{1em}{\textcolor{red}{\chaptername}}}} % set the chapter name <<<<<<<<<<<
%**************************************************
\begin{document}
\frontmatter
\chapter*{Ac}
\addcontentsline{toc}{chapter}{Ac}
\mainmatter
\setcounter{tocdepth}{1}
\chapter{Backrre}
\setcounter{chapter}{14}
\chapter{Another chapter with \#15}
\begin{appendices}
\chapter{Derivation of X}
The contents...
\chapter{Derivation of Y}
Another content...
\setcounter{chapter}{15}
\chapter{Derivation of P}
\setcounter{chapter}{25}
\chapter{Derivation of Z}
Another content...
\end{appendices}
\backmatter
% \bibliography{}
\end{document}
答案2
这并不难实现,只需修补命令即可\@makechapterhead
。我认为您可以完全自己重新定义它而不使用quotchap
。因为如果您知道如何重新定义,它会做完全相同的事情\@makechapterhead
。无论如何,我认为输出不是那么漂亮。所以我还在标题和标题名称之间添加了一些空格。
编辑:您可以这样做来更改字体大小。
\documentclass[11pt,openany,twoside]{book}
\raggedbottom
\let\cleardoublepage=\clearpage
\usepackage[left=2.5cm, right=2.5cm, top=3cm, bottom=3cm,a4paper]{geometry}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[table]{xcolor}
\usepackage{graphicx}
\newcommand\HRule{\noindent\rule{\linewidth}{1.5pt}}
\usepackage[dotinlabels]{titletoc}
\usepackage{background}
\backgroundsetup{contents={}}
\usepackage{fancyhdr}
\usepackage{hhline}
\pagestyle{fancy}
\usepackage[noindentafter,calcwidth]{titlesec}
\usepackage[courier]{quotchap}
\usepackage{helvet}
\renewcommand\sectfont{\bfseries}
\usepackage{calc,pifont}
\usepackage{multirow}
\newcommand*\myheaderfooterfont{\normalfont\bfseries}
\usepackage[nottoc]{tocbibind}
\usepackage[ragged]{sidecap}
\usepackage[marginal]{footmisc}
\renewcommand\footnoterule{\vspace*{-3pt}%
\hrule width 2in height 1.4pt \vspace*{2.6pt}}
\setlength\footnotemargin{10pt}
\usepackage{etoolbox}
\usepackage{regexpatch}
\usepackage{listings}
\usepackage{hyperref}
\hypersetup{
colorlinks=true,
linkcolor=blue,
}
\usepackage{apptools}
\usepackage{lipsum}
\makeatletter
\patchcmd{\@makechapterhead}{\thechapter}{{\fontsize{60}{80}\selectfont\chaptername}\hskip20pt\thechapter}{}{}
\patchcmd{\@makechapterhead}{\par}{\par\vspace{15pt}}{}{}
\makeatother
\begin{document}
\chapter{Backrre}
\lipsum[1]
\end{document}