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 »

Hello,

I am writing a book, compiled in XeLaTeX, with, among other things, an index. My concern is the following:

I don't like the lowercase roman page numbering (in \frontmatter) because of the dots (i, ii, iii). I would like to have small caps instead.

I found the following 6 lines (under the comment %numéros pages roman petites majuscules dans \frontmatter% in my code) in this book to do it (https://framabook.org/docs/latex/framab ... -libre.pdf) p.185-186.

Here is a summary of my 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}
\setmainfont[Ligatures=Rare]{Linux Libertine O}
\newfontfamily\fancy{Z003-MediumItalic.otf}

%%%%%%%%%%%%%%
% numéros pages roman petites majuscules dans frontmatter
%%%%%%%%%%%%%%
\frontmatter
\renewcommand{\thepage}{\textsc{\roman{page}}}
 \def\frontmatter{
 \let\indexORI\index
\renewcommand{\index}[1]{\indexORI{##1|textsc}}
\fancyhead[LE,RO]{\textsc{\thepage}}
}
%%%%%%%%%%%%%%%%%%%%

\makeatletter           %Supprime les
\let\ps@plain\ps@empty  %numéros de page
\makeatother %des titres
%%%%%%%%%%%%%%%%%%%

\usepackage[automake=true]{glossaries-extra} % glossaries ne fonctionne pas
\makeglossaries
\newglossaryentry{Décryptement}
{name=Décryptement,
description={recherche sans l'aide de documents}}

\newenvironment{smquote}{\begin{quote}\small}{\end{quote}}

\title{TITRE DU LIVRE}
\author{}
\date{}

\begin{document}

%%%%%%%%%%%%
\frontmatter
%%%%%%%%%%%%

\maketitle

\thispagestyle{empty}

\cleardoublepage

\thispagestyle{empty}

\vspace*{\stretch{1}}
\begin{center}
 \Huge{TITRE DU LIVRE}
 \bigskip
 
 \large{AUTEUR}
\end{center}
\vspace*{\stretch{1}}

\clearpage
\thispagestyle{empty}

%%%%%%%% Début du contenu %%%%%%%%%%

\include{01_preface.tex}
\thispagestyle{empty}

\include{02_intro.tex}
\thispagestyle{empty}   %supprime page et entête après preface

%%%%%%%%%
% PREMIÈRE PARTIE
%%%%%%%%%

%%%%%%%%%%%
\mainmatter
%%%%%%%%%%%
\setcounter{footnote}{0}
%%%%%%%%%%%
\part{PART 1}
%%%%%%%%%%%

%%%%%%%%%%%
% Chapitre 0 - Prologue
%%%%%%%%%%%

\include{03_prologue.tex}

%%%%%%%%%%%
\backmatter
%%%%%%%%%%%

\appendix

%%%%%%%%%%%%%%
\part{ANNEXES}
%%%%%%%%%%%%%%

\include{annexe_une.tex}

\thispagestyle{empty}

\printindex{}
\addcontentsline{toc}{chapter}{Index}%Pour qu'il apparaisse dans la TOC

\glsaddall
\printglossary[title=Glossaire, toctitle=Glossaire]


\tableofcontents

\end{document}
This 6 lines code do give me small caps roman in the \frontmatter, but the index disappears.

What can I do to get both?

Thanks for your help

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 »

Hi Gilles,

it seems that you forgot \let\index\indexORI after \mainmatter to restore the \index command.

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, Stefan,

It seemed to me that this was the root of the problem, but I failed to resolve it. I am probably not placing or writing the command correctly.

What is the exact command? \let\index\indexORI or \def\mainmatter{\let\index\indexORI} or something else?

And where to place it? In the preamble? In the body of the document after \mainmatter?

Thanks for your help
Last edited by Gilles T on Wed Jul 21, 2021 3:59 pm, edited 1 time in total.
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 »

Place it right aftert \mainmatter:

Code: Select all

...
%%%%%%%%%
% PREMIÈRE PARTIE
%%%%%%%%%

%%%%%%%%%%%
\mainmatter
%%%%%%%%%%%
\let\index\indexORI
...
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 »

I did it, but the Index still does not appear (it appears in the TOC).

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 »

Are you sure you need \index commands in the frontmatter? Because if not, you can omit that redefinition. Like

Code: Select all

%%%%%%%%%%%%
\frontmatter
%%%%%%%%%%%%
\let\indexORI\index
\renewcommand{\thepage}{\textsc{\roman{page}}}
\fancyhead[LE,RO]{\textsc{\thepage}}
(instead of those earlier 6 lines more above)

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 »

Hi Stefan,

You are right, I don't need the 6 lines above. The code as you present it is simpler and clearer. It works to give me roman small caps.

But, the Index still refuses to appear.
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 »

There is no \index command, so no entries in the index, it won't be printed then. Add an \index command for some keyword to be indexed.

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 »

I did that. Two words in the Introduction.

The Index appears as as long as the \renewcommand{\thepage}{\textsc{\roman{page}}} command is not present.
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 »

That should not be a problem. It worked, when I tested it with your code.

Here is a small example, your code reduced, where it works too:

Code: Select all

\documentclass{book}
\usepackage{fontspec}
\usepackage{polyglossia}
\usepackage{fancyhdr}
\usepackage{imakeidx}
\makeindex[title=Index]
\setdefaultlanguage[frenchpart=false]{french}
\begin{document}
\frontmatter
\renewcommand{\thepage}{\textsc{\roman{page}}}
\fancyhead[LE,RO]{\textsc{\thepage}}
\mainmatter
test\index{test}
\backmatter
\appendix
\printindex{}
\addcontentsline{toc}{chapter}{Index}
\tableofcontents
\end{document}
Perhaps post your code again in the current status, as it's already changed, so we have a base to check. Again as a small compilable example that can be tested, without non-relevant parts (such as \newfontfamily\fancy{Z003-MediumItalic.otf} etc.) that may disturb testing. And you can attach your .log file.

You can click on "Run LaTeX here" below that shortened example here. Post your code so that it can be tested here too. We don't have Z003-MediumItalic.otf and there's much in the document that's not relevant for an index. :-)

Stefan
LaTeX.org admin
Post Reply