[Tex/LaTex] Right align chapter number to the chapter name when using memoir with veelo style

chaptershorizontal alignmentmemoirsectioning

I am using the memoir document class and the veelo chapter style.
I'm having trouble aligning the chapter number to the right so it has the same right margin as the section name.
Because of the page margins the black rectangle on the right of the chapter number does not appear.
Part of the code I am using:

\documentclass[a4paper,12pt,twoside]{memoir}
\chapterstyle{veelo}
\settypeblocksize{252mm}{165mm}{*} 
\setlrmarginsandblock{25mm}{20mm}{*} 
\setulmarginsandblock{20mm}{25mm}{*} 
...
\chapter{Introduction}

When I compile I get what is on the left of the image below and I want to obtain what is on the right side.

Chapter style image

Thank you.

Best Answer

Unfortunately you didn't provide information about the horizontal position of the title with respect to the text; here's a possible definition of a new style achieving what you want:

\documentclass[a4paper,12pt,twoside]{memoir}
\usepackage{graphicx}
\usepackage{lipsum}

\settypeblocksize{252mm}{165mm}{*} 
\setlrmarginsandblock{25mm}{20mm}{*} 
\setulmarginsandblock{20mm}{25mm}{*} 

\makeatletter
\newlength{\numberheight}
\setlength{\numberheight}{\beforechapskip}

\newlength{\barlength}
\makechapterstyle{myveelo}{%
\setlength{\afterchapskip}{40pt}
\renewcommand*{\chapterheadstart}{\vspace*{40pt}}
\renewcommand*{\afterchapternum}{\par\nobreak\vskip 25pt}
\renewcommand*{\chapnamefont}{\normalfont\LARGE\flushright}
\renewcommand*{\chapnumfont}{\normalfont\HUGE}
\renewcommand*{\chaptitlefont}{\normalfont\HUGE\bfseries\flushright}
\renewcommand*{\printchaptername}{%
\chapnamefont\MakeUppercase{\@chapapp}\hspace*{\midchapskip}}
\renewcommand*{\chapternamenum}{}
\setlength{\beforechapskip}{18mm}
\setlength{\midchapskip}{\paperwidth}
\addtolength{\midchapskip}{-\textwidth}
\addtolength{\midchapskip}{-\spinemargin}
\addtolength{\midchapskip}{-2.5em}
\renewcommand*{\printchapternum}{%
\makebox[0pt][l]{\hspace{-\midchapskip}%
\resizebox{!}{\numberheight}{\chapnumfont \thechapter}%
\hspace{.8em}%
\rule{\midchapskip}{\beforechapskip}%
}}%
\makeoddfoot{plain}{}{}{\thepage}}
\makeatother
\chapterstyle{myveelo}

\begin{document}
\chapter{Introduction}
\lipsum[2]
\end{document}

enter image description here

Related Question