0

I use the extbook-class and need to use \frontmatter and \mainmatter. However, the chapters numbers within \frontmatter does not display (as expected). But I would like them to be shown (and as letters, rather than numbers (A, B, ...)).

The chapters in \mainmatter are shown as normal numbers, so all is fine there.

As you can see, I use \renewcommand{\thechapter}{\Alph{chapter}} to set the chapters to letters within \frontmatter (and then set it to arabic again within \mainmatter). I suppose that part is correct. All I need now is to actually display the chapter letters in \frontmatter.

(I use a fancy tikz style-thingie for the chapters, but that works fine as long as there is a chapter number or chapter letter.)

EDIT: Ulrike Fischer suggested to use \pagenumbering{roman} instad of \frontmatter. This is a solution I've tried before. And while it does show the chapters (A and B) correctly within the book itself, bookmarks (as seen in pdf viewers) becomes strange. (Meaning printing the book would be fine, but not using it as a pdf file). Roman and arabic numbers are mixed as can be seen here: https://imgur.com/a/9HhQfPZ

In this example, chapter 1 and 2 get roman numbers, while 3 and 4 get arabic numbers. When writing longer documents, I also get roman numbers for subsections in chapter 1 and 2.

This is the code: \documentclass[14pt]{extbook} \usepackage[top=2cm,bottom=2cm,left=3cm,right=2.4cm,headsep=24pt,a4paper]{geometry} % Page margins

\usepackage{mathtools} % for math stuff

\usepackage{titletoc} % Required for manipulating the table of contents
\usepackage{hyperref}
\usepackage{bookmark}

% % Fancy chapter heading:
\usepackage{xcolor}
\definecolor{myBlue}{RGB}{0,77,153}
\usepackage[explicit]{titlesec}
\usepackage[activate={true,nocompatibility},final,tracking=true,kerning=true,spacing=true,factor=1100,stretch=10,shrink=10]{microtype}
\usepackage{tikz}

\titleformat{\chapter}[display]
  {\normalfont\bfseries\color{black}}
  {\filleft%
    \begin{tikzpicture}
    \node[ % the square
      outer sep=0pt,
      text width=2.5cm,
      minimum height=3cm,
      fill=myBlue,
      font=\color{white}\fontsize{80}{90}\selectfont,
      align=center
      ] (num) {\thechapter};
     \node[ % this is the title of the chapter (sent as argument #1)
      anchor=south east,
      font=\color{black}\Large\normalfont
      ] at ([yshift=-70pt, xshift=88pt]num.west) {\textls[180]{\textsc{#1}}}; 
\end{tikzpicture} 
  }
  {10pt}
  {\titlerule[2.5pt]\vskip3pt\titlerule\vskip4pt\LARGE\sffamily}

\begin{document}
% =========== TOC, Chapter A and B ==============
\pagenumbering{roman}
%\frontmatter
\tableofcontents % Print the table of contents itself
\renewcommand{\thechapter}{\Alph{chapter}}

\chapter{Init A}
This is supposed to be chapter A. Blablabla.
\chapter{Init B}
This is supposed to be chapter B. Blablabla.

\mainmatter
\renewcommand{\thechapter}{\arabic{chapter}}
\setcounter{chapter}{0}% Equivalent to "letter O"
\chapter{First chapter}
    asdf
    \newpage
    asdf
    \newpage
    \section{Section of first chapter}
    adsfdsf
    \section{Another section of first chapter}
    adsfadsf
\chapter{Second chapter}
    asdf
    \newpage
    asdf
    \newpage
    \section{Section of second chapter}
    asdf
    \newpage
    \section{Another section of second chapter}
    adsfadsf
\chapter{Third chapter}
    asdf
    \newpage
    asdf
    \newpage
\chapter{Fouth chapter}
    asdf
\end{document}
  • 1
    Don't use \frontmatter but only \pagenumbering{roman} (if you want roman page numbers ...). – Ulrike Fischer Apr 30 '18 at 11:56
  • Yes, I've tried that. However this makes the numbering very odd when displaying in a pdf viewer. In chapter 1, the first chapters are shown with roman numbers and also in chapter 2... :( – user5180880 Apr 30 '18 at 12:12
  • ...also the arabic numbers then starts earlier than expected. If I just exchange the \frontmatter and \mainmatter to \pagenumbering{roman} and \pagenumbering{arabic} in the example above, the first arabic number ends up in Init B, which is odd... – user5180880 Apr 30 '18 at 12:22
  • I only said to remove \frontmatter, not \mainmatter (which inserts a \cleardoublepage). You probably will want a \setcounter{chapter}{0} after \mainmatter too. – Ulrike Fischer Apr 30 '18 at 12:24
  • I see, I tried that as well. Everything looks ok within the document (so printing the book will be fine) but in the pdf references (I'm not sure what it is called) roman and arabic numbers are still mixed up. Here is an image of it: mixed up.... – user5180880 Apr 30 '18 at 12:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.