LaTeX forum ⇒ Fonts & Character Sets ⇒ Changing the font in \frontmatter causes the Index to disappear Topic is solved

Information and discussion about fonts and character sets (e.g. how to use language specific characters)
Gilles T
Posts: 12
Joined: Sat Jan 09, 2021 1:42 pm

Changing the font in \frontmatter causes the Index to disappear

Hi again Stefan, thanks for you patience,

Your code works, your entry appears test\index{test}. But I don't see the entries that I defined like that in my text. For example: Articles\index{Article} pour l'index. Essai\index{Essai}.

Is there the problem?

Stefan Kottwitz
Posts: 9733
Joined: Mon Mar 10, 2008 9:44 pm
If you post a compilable example (reduced as much as possible, just relevant code remaining in copy code) we find the cause for sure.

You can make a copy, reduce, test, as long as the error persist reduce non-relevant stuff and post the final problem code here.

If we can compile and see the problem, we usually can fix it here. Articles\index{Article} etc. is fine, there's another problem in the code.

Stefan

Gilles T
Posts: 12
Joined: Sat Jan 09, 2021 1:42 pm
Thank you so much, Stefan,

I will do this tomorrow. I have to leave now.

By, in the meantime

Gilles T
Posts: 12
Joined: Sat Jan 09, 2021 1:42 pm
Good morning,

Here is my simplified code:
\documentclass[a4paper, 12pt]{book}
\usepackage{fontspec}
\usepackage{polyglossia}
\usepackage{fancyhdr}
\usepackage{lipsum}
\usepackage{graphicx}
\usepackage{imakeidx}
\makeindex[title= Index]
\setdefaultlanguage[frenchpart=false]{french}
%%%%%%%%%%%%%%%%%%%%
\makeatletter
\let\ps@plain\ps@empty
%%%%%%%%%%%%%%%%%%%
\title{TITRE DU LIVRE}
\author{}
\date{}
\begin{document}
%%%%%%%%%%%%
\frontmatter
%%%%%%%%%%%%
%\renewcommand{\thepage}{\textsc{\roman{page}}}
\maketitle
\chapter{Préface}
Articles\index{Article} pour l'index. Essai\index{Essai}.
\lipsum[1-5]
%%%%%%%%%%%
\mainmatter
%%%%%%%%%%%
\chapter{Prologue}
\lipsum[1-5]
%%%%%%%%%%%
\backmatter
%%%%%%%%%%%
\appendix
\printindex
\addcontentsline{toc}{chapter}{Index}%Pour qu'il apparaisse dans la TOC
\tableofcontents
\end{document}

The two commands after\frontmatter are commented. The index appears.
When we activate them, the index disappears.

Another point, a little off topic, without this command \makeatletter\let\ps@plain\ps@empty, the page numbers appear at the same time at the top and at the bottom. I don't understand how it works, but with this command the numbers appear as I want.
If you have any clarification on this point, it will be welcome, but it is not obligatory.

Thanks

Stefan Kottwitz
Posts: 9733
Joined: Mon Mar 10, 2008 9:44 pm
Instead of small roman numbers you can easily have them in upper case by \pagenumbering{Roman}:

\documentclass[a4paper, 12pt]{book}
\usepackage{fontspec}
\usepackage{polyglossia}
\usepackage{fancyhdr}
\usepackage{lipsum}
\usepackage{graphicx}
\usepackage{imakeidx}
\makeindex[title= Index]
\setdefaultlanguage[frenchpart=false]{french}
%%%%%%%%%%%%%%%%%%%%
\makeatletter
\let\ps@plain\ps@empty
%%%%%%%%%%%%%%%%%%%
\title{TITRE DU LIVRE}
\author{}
\date{}
\begin{document}
%%%%%%%%%%%%
\frontmatter
%%%%%%%%%%%%
\pagenumbering{Roman}
\maketitle
\chapter{Préface}
Articles\index{Article} pour l'index. Essai\index{Essai}.
\lipsum[1-5]
%%%%%%%%%%%
\mainmatter
%%%%%%%%%%%
\chapter{Prologue}
\lipsum[1-5]
%%%%%%%%%%%
\backmatter
%%%%%%%%%%%
\appendix
\printindex
\addcontentsline{toc}{chapter}{Index}%Pour qu'il apparaisse dans la TOC
\tableofcontents
\end{document}

Does this fit for you? Note, a small caps "capitalizing" makes the numbers smaller compared to the normal font size and smaller as other page numbers. For consistent size, I would use \pagenumbering{Roman}.

Stefan

Gilles T
Posts: 12
Joined: Sat Jan 09, 2021 1:42 pm
It works with Roman. If there is no better solution, I can live with that one.

But why it does not work with roman small caps?

Stefan Kottwitz
Posts: 9733
Joined: Mon Mar 10, 2008 9:44 pm
The way indexing works, has issues when macros are included.

With the small caps change, the index file would contain:

\indexentry{Article|textsc}{\textsc  {iii}}

The indexer would complain:

!! Input index error (file = text.idx, line = 1):
-- Illegal space within numerals in second argument.

It expects an argument that is the page number here, but it cannot execute \textsc at that place. The way of formatting page number would be like here:

\documentclass{article}
\usepackage{imakeidx}
\makeindex
\begin{document}
\pagenumbering{roman}
Text
\index{Article}
\index{Article|textsc}
\printindex
\end{document}

You can test it here by clicking the "Run LaTeX here" button.

There is of cause a way to work around this limitation, but in my opinion very complex.

I like the \pagenumbering{Roman} that is easy and consistent, because if we want capital Roman numbers than this is it, instead of smaller-non-capital-capitals.

Stefan

Gilles T
Posts: 12
Joined: Sat Jan 09, 2021 1:42 pm
That's right, I can live with Roman, the code is simple.

Thank you again,

Gilles