使用 quotchap 包在章节号前添加单词“Chapter”

使用 quotchap 包在章节号前添加单词“Chapter”

我正在使用 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相应地)

C

d

A

F

% !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}

在此处输入图片描述

相关内容