0

I am using the quotchap package and I wish to have the word "Chapter" before the Chapter number for example, instead of just having 1, I wish to have Chapter 1 and the remaining chapters to have this format and also Appendix A instead of just having A. This is a continuation of the question answered nicely by @Simon Dispa (https://tex.stackexchange.com/users/161015/simon-dispa) at Adding the word "Appendix" for all the Appendices chapters using the quotchap package .

Below is the my 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}

itc
  • 657
  • All chapters have to be numbered 1? – Bernard Jul 08 '22 at 22:22
  • I want 1 to be Chapter 1, 2 to be Chapter 2, 3 to be Chapter 3 and so on. Also A to be Appendix A, B to be Appendix B, C to be Appendix C and so on. – itc Jul 08 '22 at 22:36
  • this is very easy to do with the \titleformat command from titlesec. – Bernard Jul 09 '22 at 08:05
  • Can you please assist @Bernard. – itc Jul 09 '22 at 12:55
  • When I try to use titleformat, everything from the quotchap package end up being overridden. @Bernard – itc Jul 09 '22 at 13:03
  • :: I've never used quotchap, so I don't know if some macros can be written with another package. For me, the simplest way to obtain the word chapter before the chapter number is to use \titleformat*{\chapter}{\chaptername~\thechapter}. If that doesn't work as you want, could please post a compilable short code that illustrates the problems you have? – Bernard Jul 09 '22 at 13:15
  • I have tried the command \titleformat*{\chapter}{\chaptername~\thechapter} and it is not working. Thank you very much Bernard. I can work with the 2 solutions provided by Simon Dispa and Tom. – itc Jul 09 '22 at 13:28

2 Answers2

1

This is not hard to achieve, just patch the \@makechapterhead command. I think you may completely redefine it by yourself without using quotchap. Because it did exact same thing if you know how to redefine the \@makechapterhead. Anyway, I don't think the output is that pretty. So I also add some space between the heading and title name.

Edit: You could do this to change the font size.

\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}

enter image description here

Tom
  • 7,318
  • 4
  • 21
  • How can I set the font type and size of the word Chapter? – itc Jul 09 '22 at 02:36
  • @itc You can use \fontsize{<size>}{<baselineskip>}\selectfont in front of \chaptername\space\thechapter, the number size will also changed. – Tom Jul 09 '22 at 04:08
  • @itc add an example in the answer. – Tom Jul 09 '22 at 04:17
  • Can you please look into the comment I tagged you below @Simon Dispa answer? It's an issue concerning the chapter label and chapter name right alignment to the margin. For example, the chapter name in our MWE, Backre is perfectly right aligned. However, as you can see, the chapter label Chapter 1 is not perfectly aligned to the right as is the chapter name. Can you please assist in adjusting the answer? Thanks in advance. – itc Jul 09 '22 at 13:34
1

Try this code. It works with chapters and appendices.

You can change the font, color and position by modifying the definition of \chapname (and \appname accordingly)

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}

Simon Dispa
  • 39,141
  • If you look at Appendix A it is properly positioned at [right=2.5cm] as can be seen from the right margin line touching the letter A. However, if you look at the label Chapter 1 for example, you can see that the heading is far away from the right margin and is not in line with the chapter name Backre.The chapter name Backre is properly aligned to the right at [right=2.5cm]. Can you please assist in making the adjustments so that the chapter label and name all have a proper right alignment to the margin? I can also say the same about the solution provided by @Tom. – itc Jul 09 '22 at 13:19
  • @itc This is not related with the patch nor the question. (comment it out to see) It also happens in all appendices (A to Z). See the figures. Maybe another question? also see https://tex.stackexchange.com/questions/427068/sidebearings-and-precision-left-right-alignment – Simon Dispa Jul 09 '22 at 13:46
  • You are right. Perhaps I should ask a question concerning this. Thank you very much! – itc Jul 09 '22 at 16:39