# How to display chapter number in big numerical next to chapter title

I would like to display on the first page of every chapter, the chapter's name, followed by some spacing and then the chapter's number in big gray numerals. Also the number should be displayed in a slightly lighter gray font than the normal text.I have illustrated with a rectangle in the figure below (including relative font size) the region where the chapter's number should appear relative to the title.

Edit minimal working example shown next.

\documentclass[10pt,twoside]{book}

% todo modify this to display chapter name and number as shown in figure above.
\titleformat{\chapter}[display]
{\bfseries\Huge\sffamily}
{\vspace{-0.9in}\filright{\LARGE{\chaptername} \thechapter}}
{0pt}
{\rule{10pt}{10pt}\hspace{10pt}\rule{10pt}{10pt}\hspace{10pt}\rule{10pt}{10pt}\filright\\[20pt]}
[\vspace{2ex}\titlerule\vspace{16pt}]

\usepackage{currfile}
\usepackage{lipsum}

\usepackage{shorttoc}
\usepackage{tocbibind}
% http://ctan.org/pkg/bookmark
\usepackage{bookmark}
\usepackage{listings}
\usepackage{wrapfig}

% Page dimensions required by publisher
\usepackage[paperwidth=16.99cm,paperheight=24.4cm]{geometry}

\usepackage{float}

\begin{document}
\chapter{Random Number Generators}
blablabla
\end{document}


Edit 2 The solution given by Bernard below is exactly what I need. I still 2 issues: i omitted in the MWE to specify my exact page dimensions. So now the chapter number is out of the page at the moment (see screenshot below). I have updated the MWE to include the page dimensions. In a more general way, what are the parameters which govern the positioning of the chapter number?

The second issue is that now I have the work "Chapter" being displayed in my preface and TOC (frontmatter chapters).

Edit 3 Using the advice given in the following answer LaTeX - how do I force PDF page height/width?, I modified my page settings from \RequirePackage[paperwidth=16.99cm,paperheight=24.4cm]{geometry} to \RequirePackage[pass,paperwidth=16.99cm,paperheight=24.4cm]{geometry}. Bernard's solution now works. From the answer given in the previous link, "With the pass option, geometry won't change the class parameters for pagination, as it would do without it".

Output shown below:

• Sure thing! This depends though on your document class, and possibly other package restrictions (as a result of other package you might be using already which could conflict). Can you provide the community with a minimal working example (MWE) that lays the foundation for what you require? It should start with \documentclass and end with \end{document} so we can copy-and-paste-and-compile and see exactly what you're currently seeing. – Werner Mar 3 '17 at 23:17
• @Werner Added a MWE. However the \titleformat{\chapter} command needs to be modified in order to achieve the expected layout. Thanks! – BigONotation Mar 3 '17 at 23:40

Here is a solution, with two (not Fifty) Shades of Grey:

\documentclass[10pt,twoside]{book}
\usepackage[utf8]{inputenc}
\usepackage{lipsum, graphicx, tabularx}
\usepackage[svgnames]{xcolor}
\usepackage[explicit]{titlesec}
% todo modify this to display chapter name and number as shown in figure above.
\titleformat{\chapter}[block]
{\bfseries\Huge\sffamily}
{\rlap{\hspace*{\dimexpr\linewidth+\marginparsep}%
\parbox{\marginparwidth}{\centering\color{Gainsboro}\scalebox{4}{\thechapter}\\[-0.5ex]% \raisebox{-0.3\height}[0pt][0pt]
\rule{10pt}{10pt}\hspace{10pt}\rule{10pt}{10pt}\hspace{10pt}\rule{10pt}{10pt}}}}
{0pt}
{\color{gray!75}\begin{tabularx}{\linewidth}{@{}>{\raggedright\arraybackslash}X>{\raggedleft\arraybackslash}p{1cm}@{}}
& \makebox[0pt]{\LARGE\chaptername}\\[2.5ex] #1
\end{tabularx}}
[\vspace{1ex}\titlerule\vspace{16pt}]

\titlespacing{\chapter}{0pt}{-5ex}{10ex}

\usepackage{currfile}
\usepackage{lipsum}

\usepackage{shorttoc}
\usepackage{tocbibind}
% http://ctan.org/pkg/bookmark
\usepackage{bookmark}
\usepackage{listings}
\usepackage{wrapfig}

\usepackage{float}

\begin{document}

\chapter{Random Number Generators}

\lipsum[1-5]

\end{document}


For problems with the margin, I propose this variant:

\documentclass[10pt,twoside]{book}
\usepackage[utf8]{inputenc}% Page dimensions required by publisher
\usepackage[paperwidth=16.99cm,paperheight=24.4cm,]{geometry} % showframe
\usepackage{lipsum, graphicx, tabularx}
\usepackage[svgnames]{xcolor}
\usepackage[explicit]{titlesec}
% todo modify this to display chapter name and number as shown in figure above.
\titleformat{\chapter}[block]
{\bfseries\Huge\sffamily}
{\rlap{\hspace*{\dimexpr\linewidth+2 \marginparsep}%
\begin{tabular}{@{}>{\color{Gainsboro}}c@{}}\scalebox{4}{\thechapter}\\[-0.5ex]%
\rule{10pt}{10pt}\hspace{10pt}\rule{10pt}{10pt}\hspace{10pt}\rule{10pt}{10pt}\end{tabular}}}
{0pt}
{\color{gray!75}\begin{tabularx}{\dimexpr\linewidth+4\marginparsep}%
{@{}>{\raggedright\arraybackslash}X>{\raggedleft\arraybackslash}r@{}}
& \rule{0pt}{3ex}\LARGE\chaptername\\[0ex] #1
\end{tabularx}}
[\vspace{1ex}\titlerule\vspace{16pt}]

\titlespacing{\chapter}{0pt}{-5ex}{10ex}

\usepackage{currfile}
\usepackage{lipsum}

\usepackage{shorttoc}
\usepackage{tocbibind}
% http://ctan.org/pkg/bookmark
\usepackage{bookmark}
\usepackage{listings}
\usepackage{wrapfig}

\usepackage{float}

\begin{document}

\chapter{Random Number Generators}

\lipsum[1-5]
\end{document}


• Many thanks this is exactly what I wanted! I am having 2 issues still. I am sorry I did not mention it in my MWE example, but I have set the page dimensions set explicitly. The chapter number is slightly out of the page area now. The second problem is that the word "Chapter" now appears in my preface and toc (I have attached screenshots of both issues). Otherwise your solution is the one I will accept as soon as the previous points have been solved. And yes who needs 50 shades of Gray when you have two! :) – BigONotation Mar 4 '17 at 13:52
• In a more general way, which parameters to your solution govern the positioning of the chapter number on the page? – BigONotation Mar 4 '17 at 14:04
• The chapter number is centred in the outer margin par, and the word ‘Chapter’ is centred at the right margin. The problem is that, as it's a non-standard paper size (at least for the usual LaTeX classes), there's no \marginparwidth not text dimensions fitting it by default. I guess paper size comes from a publisher specifications. Aren't text width, height and margin sizes also specified? – Bernard Mar 4 '17 at 19:17
• Well I am supposed to provide PDF print-ready output for the chapters. The contents has to fit inside 6.69''x9.61''. I have a tool which enables me to see if PDF output overflows the page or is not within the margins etc...but not more. Using LaTeX was my choice so I am a bit on my own here...I could tweak font sizes and margins but not sure where to start – BigONotation Mar 4 '17 at 20:05
• I think I managed to make it work. I modified the page dimensions setting from \usepackage[paperwidth=16.99cm,paperheight=24.4cm]{geometry} to \usepackage[pass,paperwidth=16.99cm,paperheight=24.4cm]{geometry}. By adding the pass, your solutions works now – BigONotation Mar 4 '17 at 20:27

An example using the memoir class, lightly modified from Various chapter styles for the memoir class:

\documentclass{memoir}
\usepackage{lipsum}
\usepackage{xcolor}
\newif\ifchapternonum
\makechapterstyle{jenor}{
\renewcommand\printchaptername{}
\renewcommand\printchapternum{}
\renewcommand\printchapternonum{\chapternonumtrue}
\renewcommand\chaptitlefont{\sffamily\bfseries%
\fontsize{25}{35}\selectfont\raggedright}
\renewcommand\chapnumfont{\fontfamily{pbk}\fontseries{m}\fontshape{n}%
\fontsize{2in}{0in}\selectfont\color{gray!50}}
\renewcommand\printchaptertitle[1]{%
\ifchapternonum%
\begin{tabularx}{\textwidth}{X}%
{\parbox[b]{\linewidth}{\chaptitlefont ##1}%
\vphantom{\raisebox{-15pt}{\chapnumfont 1}}}
\end{tabularx}%
\else
\begin{tabularx}{\textwidth}{Xl}
{\parbox[b]{\linewidth}{\chaptitlefont ##1}}
& \raisebox{-15pt}{\chapnumfont \thechapter}%
\end{tabularx}%
\fi
\par\vskip2mm\hrule
}}

\chapterstyle{jenor}

\begin{document}
\chapter{Random Number Generators}
\section*{Introductiom}
\lipsum[1]
\end{document}