LaTeX forum ⇒ Fonts & Character SetsChanging 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

Postby Gilles T » Wed Jul 21, 2021 4:57 pm

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?

User avatar
Stefan Kottwitz
Site Admin
Posts: 9733
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Wed Jul 21, 2021 5:03 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
LaTeX.org admin

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

Postby Gilles T » Wed Jul 21, 2021 5:37 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

Postby Gilles T » Thu Jul 22, 2021 10:06 am

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}}}
%\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: 9733
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Thu Jul 22, 2021 10:46 am

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
LaTeX.org admin

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

Postby Gilles T » Thu Jul 22, 2021 12:58 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?

User avatar
Stefan Kottwitz
Site Admin
Posts: 9733
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Thu Jul 22, 2021 1:33 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
LaTeX.org admin

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

Postby Gilles T » Thu Jul 22, 2021 1:41 pm

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

Thank you again,

Gilles


Return to “Fonts & Character Sets”

Who is online

Users browsing this forum: No registered users and 6 guests