0

I'm trying to recreate this layout for chapter headers for a book:

Chapter header

One side is the chapter name and the others is just numbers for the chapter count. I tried making this work with tables and multicols, but I can't get them to both top align and I can't reduce the width of the left-hand column enough to make the title fit properly.

How would you go about implementing this with LaTex? Possible?

3
  • 1
    Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}.
    – hesham
    Commented Jul 29, 2020 at 6:13
  • Do you mean recreating the chapter header or chapter title? Because it looks like the headers are not related to your question. And please show us which document class are you using (report, book, memoir, etc.)
    – hesham
    Commented Jul 29, 2020 at 6:19
  • I'm using books \documentclass{book}. I'm working on the header of the chapter. So, chapter title, numbering, spacing, text, etc. :-)
    – egarbugli
    Commented Jul 29, 2020 at 16:25

1 Answer 1

1

You may use totcount package along with \regtotcounter{chapter} command and then you can refer to the total chapters counts in your document by the command \total{chapter}.

To apply this into your chapter title, one way is using \usepackage{titlesec} to change the default title format to include the total number of chapters, and perhaps using \sffamily (from what appears in your picture) as the font of your chapter title.

Assuming you are using the book class (as you didn't specify), with total of 3 chapters, you get an output like this

enter image description here

Full code

\documentclass{book}
\usepackage{titlesec}
\usepackage{totcount}
\regtotcounter{chapter}
%
\usepackage{lipsum}
%
\titleformat{\chapter}[hang]{\sffamily\Huge\bfseries}{\thechapter/\total{chapter}}{1em}{}

\begin{document}
    \chapter{Introduction}
    \section{Structure}
    This book consists of \total{chapter} chapters.
%   
    \chapter{Finding The Leaks in Your Funnel}
    \section{Leaks}
    \lipsum
%
    \chapter{Finding Something Else}
    \section{Something}
        \lipsum
\end{document}

EDIT

If you want multi-line numbering (with a smaller font for chapter numbering), change \titleformat command to

\titleformat{\chapter}[hang]{\sffamily\bfseries}{\raisebox{2ex}{\normalsize \parbox[t][0cm]{0cm}{ \thechapter \\ / \\ \total{chapter} }}}{3em}{\Huge}

enter image description here

You may change the parameters of 2ex, \normalsize, or \Huge to your liking.

8
  • 1
    there is a new line between \thechapter and \total{chapter}
    – js bibra
    Commented Jul 29, 2020 at 7:30
  • @js bibra Yea thanks I noticed, but I wasn't sure he meant that or it was just the small width space of the numbering that forced it at a new line!
    – hesham
    Commented Jul 29, 2020 at 7:34
  • The \thechapter and \total{chapter} may even need to shrink their fontsize.
    – hesham
    Commented Jul 29, 2020 at 7:35
  • This is awesome. Thank you @hesham! Any way to force the numbering on 3 lines like the original?
    – egarbugli
    Commented Jul 29, 2020 at 16:26
  • @egarbugli Sorry for the late response. The answer has been edited based on your comment.
    – hesham
    Commented Aug 6, 2020 at 13:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .