6

I'm writing a document using the book class. The normal chapter headings are of the form (for the first chapter in the book):

Chapter 1

<Name of first chapter>

Instead I would like it to be:

First chapter

< Name of first chapter>

and of course with "Second chapter" instead of "Chapter 2" and so forth. I don't have a lot of chapters, so if there is a method that involves manually entering the "First chapter" part, that would be acceptable. I think it would be necessary in fact, since the book is in Icelandic and I don't think Babel would support this sort of translation. So, for the record, I really want it to say "Fyrsti kafli" instead of "Chapter 1".

Ideally, this solution would also take care of the chapter name in the headers, but if not I can solve it by using

\markboth{First chapter. Name of first chapter}{1.1 Name of first subchapter}
3
  • 1
    Welcome to TeX.SX! The titlesec and fmtcount packages should be able to do what you want. Unfortunately, the latter doesn't seem to support Icelandic at the moment.
    – egreg
    Commented Jul 4, 2015 at 23:14
  • Thanks, @egreg. You're correct, and the problem has been solved perfectly by Gonzalo Medina below, in the English case. If anyone has a solution that would work with Icelandic (or an arbitrary language), it would be much appreciated!
    – Peter
    Commented Jul 4, 2015 at 23:19
  • 1
    Related/duplicate: “Literal” numbering of chapters
    – Werner
    Commented Jul 5, 2015 at 0:14

1 Answer 1

6

One option using titlesec and fmtcount (to easily get the ordinal string for the chapter counter); using fancyhdr and a simple redefinition for \chaptermark gives the desired formatting for the header:

\documentclass{book}
\usepackage[a6paper]{geometry}% just for the example
\usepackage{titlesec}
\usepackage{fmtcount}
\usepackage{fancyhdr}
\usepackage{lipsum}% just for the example

\titleformat{\chapter}[display]
  {\normalfont\huge\bfseries}
  {\Ordinalstring{chapter}~\chaptertitlename}
  {20pt}
  {\Huge}

\pagestyle{fancy}
\fancyhf{}
\fancyhead[OL]{\leftmark}
\fancyhead[ER]{\nouppercase\rightmark}
\renewcommand{\chaptermark}[1]{%
  \markboth{\Ordinalstring{chapter}~\chaptername.\ #1}{}}

\begin{document}

\chapter{A test chapter}
\section{Test section}
\lipsum[1-6]

\end{document} 

The result:

enter image description here

Since, as egreg notices in his comment, fmtcount doesn't support Icelandic, one can use an \ifcase:

\documentclass{book}
\usepackage[icelandic]{babel}
\usepackage[a6paper]{geometry}% just for the example
\usepackage{titlesec}
\usepackage{fmtcount}
\usepackage{fancyhdr}
\usepackage{lipsum}% just for the example

\newcommand\icelandicordinal[1]{%
  \ifcase\value{#1}\or 
    Fyrsti\or 
    <second>\or...
    <third>%
  \fi
}

\titleformat{\chapter}[display]
  {\normalfont\huge\bfseries}
  {\icelandicordinal{chapter}~\MakeLowercase\chaptertitlename}
  {20pt}
  {\Huge}

\pagestyle{fancy}
\fancyhf{}
\fancyhead[OL]{\leftmark}
\fancyhead[ER]{\nouppercase\rightmark}
\renewcommand{\chaptermark}[1]{%
  \markboth{\icelandicordinal{chapter}~\MakeLowercase\chaptername.\ #1}{}}

\begin{document}

\chapter{A test chapter}
\section{Test section}
\lipsum[1-6]

\end{document} 

The result:

enter image description here

9
  • Since fmtcount doesn't support Icelandic, maybe a supplement showing how to define number-to-word translation for a few numbers could be useful: \ifcase\value{chapter}\or Fyrsti\or <second>\or...\fi
    – egreg
    Commented Jul 4, 2015 at 23:19
  • @egreg Of course. I missed the Icelandic part :-) Will add the addition shortly. Thanks. Commented Jul 4, 2015 at 23:20
  • @egreg Added a quick, yet provisional approach (I have to leave now). Later I'll polish the code (in particular, I'll read the fmtcount documentation to see if it provides an easier way to support languages). Commented Jul 4, 2015 at 23:31
  • That's more or less what I was thinking to, but i'd introduce a macro \icelandicordinal: \newcommand{\icelandicordinal}[1]{\ifcase\value{#1}\or Fyrsti\or <second>\or...\fi}
    – egreg
    Commented Jul 4, 2015 at 23:34
  • Thanks, @GonzaloMedina! Your addition is on the right track, but the word Kafli in "Fyrsti Kafli" should not be capitalised.
    – Peter
    Commented Jul 4, 2015 at 23:37

You must log in to answer this question.

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