Fonts & Character SetsChanging the font in \frontmatter causes the Index to disappear

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

Post by Gilles T »

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?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

Changing the font in \frontmatter causes the Index to disappear

Post by Stefan Kottwitz »

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
LaTeX.org admin
Gilles T
Posts: 12
Joined: Sat Jan 09, 2021 1:42 pm

Changing the font in \frontmatter causes the Index to disappear

Post by Gilles T »

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

Changing the font in \frontmatter causes the Index to disappear

Post by Gilles T »

Good morning,

Here is my simplified code:

Code: Select all

\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}}}
%\fancyhead[LE,RO]{\textsc{\thepage}}
\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
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

Changing the font in \frontmatter causes the Index to disappear

Post by Stefan Kottwitz »

Instead of small roman numbers you can easily have them in upper case by \pagenumbering{Roman}:

Code: Select all

\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
LaTeX.org admin
Gilles T
Posts: 12
Joined: Sat Jan 09, 2021 1:42 pm

Changing the font in \frontmatter causes the Index to disappear

Post by Gilles T »

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?
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

Changing the font in \frontmatter causes the Index to disappear

Post by Stefan Kottwitz »

The way indexing works, has issues when macros are included.

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

Code: Select all

\indexentry{Article|textsc}{\textsc  {iii}}
The indexer would complain:

Code: Select all

!! 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:

Code: Select all

\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
LaTeX.org admin
Gilles T
Posts: 12
Joined: Sat Jan 09, 2021 1:42 pm

Changing the font in \frontmatter causes the Index to disappear

Post by Gilles T »

That's right, I can live with Roman, the code is simple.

Thank you again,

Gilles
Post Reply