UPDATED ANSWER
I answer this question for two index processors: makeindex
and texindy
.
Both examples use the package imakeidx
to simplify the compilation.
texindy
With texindy
you have to compile with the option shell-escape
.
First of all I set the option texindy
of the package imakeidx
to specify the index processor.
\makeindex[program=texindy,options=-M mystyle.xdy]
The options
specify what will be passed as an argument to texindy
. The option -M mystyle.xdy
means that texindy
use the style filemystyle.xdy
.
the algorithm
Before I explain the code I want to explain the algorithm which I use.
- The comma between the index entry and the page number is a simple predefined operator of the
texindy
style. So I can change it by setting them inside the style file.
Every page number of the index entry can be surrounded and modified with a command. To suppress the output of the page number, I can use the LaTeX kernel command \@gobble
which is simply defined as
\def\@gobble#1{}
These modification must be executed after the sorting algorithm of the index processor. So you can't remove the page of \indexentry
.
Now the implementation.
The index processor texindy
(and also makeindex
) can't handle LaTeX commands with an @
symbol, because @
is a special character for the index processor. So I defined a command equal to \@gobble
\let\mygobble\@gobble
The usage will be explained later. Next I have to manipulate the command \index
so that every page number of the the command index
will be modified. Therefore you can use the expansion |
. For example to print a bold page number you use \index{foo|textbf}
. The textbf
is a predefined attribute of the index processor. Instead of textbf
I use the attribute gobble
. The command \index
provided by imakeidx
has an optional argument so I recommend the macro \LetLtxMacro
provided by package letltxmacro
instead of \let
\LetLtxMacro\OldIndex\index
\renewcommand{\index}[1]{\OldIndex{#1|gobble}}
Through this redefinition every index command gets the attribute gobble
.
This attribute is defined in the style file for the texindy
run:
(define-attributes (("gobble" "default")))
(markup-locref :open "\mygobble{" :close "}" :attr "gobble")
(markup-locclass-list :open "" :sep "")
In the first line I define a new attribute. In the second line I say what the attribute should do. Here the command \mygobble
is used. The third line defines the separator to be empty ""
.
Side note: Comments in a texindy
style file are introduced with a ;
.
Altogether we get the following example:
%% !TEX program = pdflatex --shell-escape
\documentclass{article}
\usepackage{xcolor}
\usepackage{imakeidx}
\makeindex[program=texindy,options=-M mystyle.xdy]
\usepackage{letltxmacro}
\usepackage{filecontents}
\makeatletter
\let\mygobble\@gobble
\LetLtxMacro\OldIndex\index
\renewcommand{\index}[1]{\OldIndex{#1|gobble}}
\makeatother
\begin{filecontents*}{mystyle.xdy}
;;; xindy style file
(define-attributes (("gobble" "default")))
(markup-locref :open "\mygobble{" :close "}" :attr "gobble")
(markup-locclass-list :open "" :sep "")
\end{filecontents*}
\begin{document}
Test\index{foo}
\index{bar}
\printindex
\end{document}
The result is:
![](https://i.stack.imgur.com/BHLEa.png)
makeindex
In relation to makeindex
here are the options for the package imakeidx
\makeindex[program=makeindex,options=-s mystyle.ist]
The option options
must be set to -s mystyle.ist
because in this way you pass a style file to the index processor makeindex
.
makeindex
works with the same algorithm. So the lines are almost identical
\let\mygobble\@gobble
\LetLtxMacro\OldIndex\index
\renewcommand{\index}[1]{\OldIndex{#1|mygobble}}
Unlike texindy
, makeindex
doesn't work with attributes. The command mygobble
without backslash will be passed as an argument of \index
to the processor. The processor will write \mygobble{\thepage}
.
The separator must be redefined inside a style file.
quote '+'
delim_0 " "
delim_1 " "
delim_2 " "
delim_n " "
delim_0
etc. are the separator of the different levels.
Side note: Comments in a makeindex
style file are introduced with a the same as in LaTeX the %
.
So we get the following example with makeindex
:
\documentclass{article}
\usepackage{xcolor}
\usepackage{imakeidx}
\makeindex[program=makeindex,options=-s mystyle.ist]
\usepackage{letltxmacro}
\usepackage{filecontents}
\makeatletter
\let\mygobble\@gobble
\LetLtxMacro\OldIndex\index
\renewcommand{\index}[1]{\OldIndex{#1|mygobble}}
\makeatother
\begin{filecontents*}{mystyle.ist}
quote '+'
delim_0 " "
delim_1 " "
delim_2 " "
delim_n " "
\end{filecontents*}
\begin{document}
Test\index{foo}
\index{bar}
\printindex
\end{document}
hyperref support
Remember to load imakeidx
before hyperref
.
In combination with hyperref
the approach with makeindex
doesn't need any special handling. If you use texindy
in combination with hyperref you have to change the style file *.xdy
in the following way:
(markup-locclass-list :open "" :sep "")
(markup-range :sep "")
In the document body you must change the printing of the index as follows to gobble the page numbers:
\begingroup
\def\hyperpage#1{}
\printindex
\endgroup
Here the complete MWE:
\documentclass{article}
\usepackage{xcolor}
\usepackage{imakeidx}
\makeindex[program=texindy,options=-M mystyle.xdy]
\usepackage{letltxmacro}
\usepackage{hyperref}
\usepackage{filecontents}
\begin{filecontents*}{mystyle.xdy}
;;; xindy style file
(markup-locclass-list :open "" :sep "")
(markup-range :sep "")
\end{filecontents*}
\begin{document}
Test\index{foo}
\index{bar}
\begingroup
\def\hyperpage#1{}
\printindex
\endgroup
\end{document}
There are two ways: use afterpage
or put \thispagestyle{empty}
inside the figure
environment as commented by Peter.
\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{afterpage}
\usepackage{lipsum}
\begin{document}
Here is some text with an equation in it: $f(x)=x^2+3x_0\cdot\sin x$
and the textual content continues into the second line. No other math
content is contained within this paragraph.
\afterpage{%
\thispagestyle{empty}
\begin{figure}
\centering
\includegraphics[width=\textwidth]{images/rlexample.png}
\caption{---}
\label{rlexample}
\end{figure}
}
Here is some text with an equation in it: $f(x)=x^2+3x_0\cdot\sin x$
and the textual content continues into the second line. No other math
content is contained within this paragraph.
\lipsum[1-10]
\begin{figure}
\thispagestyle{empty}
\centering
\includegraphics[width=\textwidth]{images/rlexample.png}
\caption{---}
\label{rlexample}
\end{figure}
\lipsum[11-20]
\end{document}
Note: Putting thispagestyle{empty}
inside figure
environment may need some \clearpage
at appropriate places and may not work properly if [p]
in \begin{figure}[p]
is used as noted by Enrico. I would advice the use of afterpage
though.
The code supplied in comment:
\documentclass[a4paper,12pt,oneside]{article}
\usepackage[utf8]{inputenc}
\usepackage{enumerate}
\usepackage[demo]{graphicx}
\usepackage{afterpage}
\usepackage{lipsum}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@misc{B02,
author = {Buthor, B.},
year = {2002},
title = {Bravo},
}
\end{filecontents}
\title{42}
\author{Jane Doe}
\date{June 2011}
\begin{document}
\maketitle
\section{Introduction}
\subsection{text}
text text \cite{B02} texttext text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
\afterpage{%
\thispagestyle{empty}
\begin{figure}[p]
\centering
\vspace*{-3cm}
\includegraphics[scale=0.4]{image.jpg}
\caption{caption}
\label{rlexample}
\end{figure}
\clearpage
}
\lipsum[1-10]
\bibliographystyle{plain}
\bibliography{\jobname}
\end{document}
Best Answer
To remove the page number (as well as header and whole footer), you should use the
\thispagestyle{empty}
. Indeed, in thebook
class, new chapter pages are of styleplain
, that means without header yet with page numbering at the bottom.MWE