Problem Description
I am having a problem with the right alignment of chapters and appendices labels and numbers to the right margin. In the picture below (just an example and a representation of the problem I am facing), it can be seen that the chapter name (Backrre) is properly aligned to the right margin (indicated by the black vertical line). However, the chapter label and number (Chapter 1) is not aligned to the right margin as can be seen by the space/gap between the blue line (the blue vertical line I added to illustrate my problem) and the right margin (shown by the black vertical line) in the picture below.

I need assistance on how to align the chapters labels and numbers to the right margin as are the chapter names. Below is my MWE which was a solution to my previous problem that @Simon Dispa (https://tex.stackexchange.com/users/161015/simon-dispa) assisted me with at Adding the word "Chapter" before Chapter number using the quotchap package:
\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}
\end{document}




\usepackage[courier]{quotchap}enough? Is it possible that we do not renew the chapter number font such that we can set the font type through the quotchap package? Please help. – itc Jul 11 '22 at 18:45quotchapneeds pdflatex to change fonts, so to do this is not useful. Remember, one question at a time (font family). – Simon Dispa Jul 11 '22 at 21:46\newenvironment{myfont1}{\fontencoding{T1}\fontfamily{pzc}\selectfont}{\par} \newenvironment{myfont2}{\fontencoding{T1}\fontfamily{phv}\selectfont}{\par}(and compile with xelatex!) – Simon Dispa Jul 12 '22 at 15:20\sfdefaultis set by\usepackage{helvet}tophv– Simon Dispa Jul 12 '22 at 16:41\normalfont\bfseries\sffamilyis fine. I do not understand your question. In your last example section titles are bold + helvetica. – Simon Dispa Jul 12 '22 at 17:10