9

I'm working on a daily journal and I want every \chapter number to contain an ordinal indicator (st, nd, rd etc.). See attached picture as an example (I marked in red what I'm looking for). Is there a way for this to work in LaTeX? So for every chapter, LaTeX should output the ordinal indicator based on the number. So for chapter "2" it will be "2nd" and for "330" it will be "330th".

enter image description here

\documentclass[11pt,twoside,openright]{book}
\usepackage[paperheight=8.5in,paperwidth=5.5in]{geometry}
\geometry{showframe=false}
\geometry{margin=0.5in,bottom=0.70in, top=0.50in, bindingoffset=0.2in}
\usepackage[super,comma]{natbib}
\usepackage{setspace}
\renewcommand{\baselinestretch}{1.15} 
\usepackage{url}
\usepackage{amssymb,amsmath,amsthm,amsfonts}
\usepackage{blindtext} % tor the example text
\usepackage{titlesec}
\usepackage{emptypage}
\usepackage{fancyhdr}
\usepackage{pifont}
\usepackage{mathtools}
\usepackage{enumitem}
\usepackage{tabularx}
\usepackage{fontawesome}
\usepackage{tikz}
\usepackage{subfigure}
\usepackage{colortbl}
\usepackage{pdfpages}
\usepackage{multicol}
\usepackage{lettrine}
\usepackage{titlesec}
\usepackage{wrapfig}
\usepackage{graphicx}
\usepackage{lipsum}
\renewcommand{\labelitemi}{$\rhd$}
\usepackage{booktabs}
\usepackage[svgnames,table]{xcolor}
\usepackage[tableposition=above]{caption}
\usepackage{pifont}
\usepackage{tex4ebook}

%%% Chapter Heading %%%
\makeatletter
\def\thickhrule{\leavevmode \leaders \hrule height 0.5ex \hfill \kern \z@}
\def\position{\centering}
%% Note the difference between the commands the one is 
%% make and the other one is makes
\renewcommand{\@makechapterhead}[1]{%
  \vspace*{0.5\p@}%
  {\parindent \z@ \position \reset@font
        {\huge \scshape \thechapter}
        \par\nobreak
        \vspace*{5\p@}%
        \interlinepenalty\@M
        \thickhrule
        \par\nobreak
        \vspace*{2\p@}%
        {\large \bfseries #1\par\nobreak}
        \par\nobreak
        \vspace*{2\p@}%
        \thickhrule
        \vskip 10\p@
  }}

\begin{document}

\chapter{Title name}

\end{document}
0

2 Answers 2

12

I suggest you employ the machinery of the fmtcount package to achieve your formatting goal for chapter numbers.

enter image description here

How to "decorate" the chapter header further is a topic best left to another package, such as the titlesec package.

\documentclass[11pt,twoside,openright]{book}
\usepackage[paperheight=8.5in,paperwidth=5.5in]{geometry}

\usepackage{fmtcount}             % for "\ordinal" macro
\fmtcountsetoptions{fmtord=level} % don't raise the ordinal indicator

\usepackage{etoolbox}
\makeatletter
\patchcmd{\@makechapterhead}{\thechapter}{\ordinal{chapter}}{}{}
\makeatother

\begin{document}
\chapter{Title name}
\end{document}

Addendum: The fmtcount package can provide ordinal numbers not just for English-language documents, but for quite a few other languages as well, and even for dialect forms within a given language. If you don't need this sophistication, you could load the engord package (presumably with the option normal) instead and replace \ordinal{chapter} with \engord{chapter} in the third argument of \patchcmd.

1
  • 1
    Good to know! +1
    – Zarko
    Feb 27 at 7:01
2

The memoir class (a superset of the book class) provides for both ordinal and cardinal numbers. Read the documentation, section 18.14 Number Formatting.

You must log in to answer this question.

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