How can one run makeindex
from within a memoir
documentclass source so as to create a glossary?
For a glossary, calling makeindex
(via the imakeidx
package) fails with memoir
.
Here is my source, which calls makeindex
(via the imakeidx
package) seemingly using the syntax as described in Section 17.3 of memman.pdf
.
When I run a pdflatex make file on the source (from within TeXShop, via the pdflatexmk engine), I get the following error:
Rule 'cusdep goo gas book': File changes, etc:
Non-existent destination files:
'book.gls
The source:
% BOOK.TEX
\documentclass{memoir}
\usepackage{amsmath}
\usepackage[makeindex]{imakeidx}
\makeglossary
\makeindex[options=-s glossarystyle.gst,-o book.gls book.glo]
\begin{document}
The empty set is denoted by $\emptyset$.%
\glossary{$\emptyset$}{empty set}
The set of all subsets of a set $X$ is denoted by $\mathcal{P}(X)$.%
\glossary{$\mathcal{P}(X)$}{power set of set}
\newpage
For sets $X$ and $Y$, the notation $f \colon X \to Y$ means that $f$ is a functions from $X$ to $Y$.%
\glossary{$f \colon X \to Y$}{functions from one set to another}.
\printglossary
\end{document}
The referenced style file `glossarystyle.gst:
% GLOSSARYSTYLE.GST
%%% basic.gst basic makindex glossary style file
%%% Output style parameters
preamble "\\begin{theglossary}"
postamble "\n\\end{theglossary}\n"
item_0 "\n\\glossitem"
delim_0 "{\\memglonum{"
encap_suffix "}}}"
headings_flag 1
heading_prefix "\\doglobookmark{"
heading_suffix "}"
%%% Input style parameters
keyword "\\glossaryentry"
Note that I am using just the built-in glossary facilities of the memoir
class, and not the external package glossaries
!
the latexmkrc
file being called by the TeXShop.app's built-in pdflatexmk engine is:
# latexmkrcedit
# Edit this File to add/change dependencies and rules
# The following is used by ALL the latexmk engine files
# change the empty string ,'', to '--shell-escape' to add the shell-escape default
$TSUserCompileOptions = '';
#$TSUserCompileOptions = '--shell-escape';
# turn recorder option off (no .fls file generated)
#$recorder=0;
# Custom dependency for glossary/glossaries package
# if you make custom glossaries you may have to add items to the @cus_dep_list and corresponding sub-routines
add_cus_dep('glo', 'gls', 0, 'makeglo2gls');
sub makeglo2gls {
system("makeindex -s '$_[0]'.ist -t '$_[0]'.glg -o '$_[0]'.gls '$_[0]'.glo");
}
# The glossaries package, with the [acronym] option, produces a .acn file when processed with (xe/pdf)latex and
# then makeindex to process the .acn into .acr and finally runs of (xe/pdf)latex to read in the .acr file. Unfortunately
# the glossary package does just the reverse; i.e. (xe/pdf)latex processing produces a .acr files and makeindex then
# is used to convert the .acr file to a .acn file which is then ... . This dependency assumes the glossaries package.
add_cus_dep('acn', 'acr', 0, 'makeacn2acr');
sub makeacn2acr {
system("makeindex -s '$_[0]'.ist -t '$_[0]'.alg -o '$_[0]'.acr '$_[0]'.acn");
}
# for glossary package (Sigh...) --- they can co-exist!
add_cus_dep('acr', 'acn', 0, 'makeacr2acn');
sub makeacr2acn {
system("makeindex -s '$_[0]'.ist -t '$_[0]'.alg -o '$_[0]'.acn '$_[0]'.acr");
}
# example of an added custom glossary type that is used in some of the glossary/glossaries example files:
# this is for the new glossary type command \newglossary[nlg]{notation}{not}{ntn}{Notation} from the glossaries package
# NOTE: the glossary package uses a very different command: the <in-ext> and <out-ext>
# are reversed in the calling sequence :-(
add_cus_dep('ntn', 'not', 0, 'makentn2not');
sub makentn2not {
system("makeindex -s '$_[0]'.ist -t '$_[0]'.nlg -o '$_[0]'.not '$_[0]'.ntn");
}
# for the glossary package (Sigh...) --- they can co-exist!
add_cus_dep('not', 'ntn', 0, 'makenot2ntn');
sub makenot2ntn {
system("makeindex -s '$_[0]'.ist -t '$_[0]'.nlg -o '$_[0]'.ntn '$_[0]'.not");
}
# dependencies for custom indexes using the index package
# examples for sample.tex for index package:
add_cus_dep('adx', 'and', 0, 'makeadx2and');
sub makeadx2and {
system("makeindex -o '$_[0]'.and '$_[0]'.adx");
}
add_cus_dep('ndx', 'nnd', 0, 'makendx2nnd');
sub makendx2nnd {
system("makeindex -o '$_[0]'.nnd '$_[0]'.ndx");
}
add_cus_dep('ldx', 'lnd', 0, 'makeldx2lnd');
sub makeldx2lnd {
system("makeindex -o '$_[0]'.lnd '$_[0]'.ldx");
}
# Custom dependency and function for nomencl package
add_cus_dep('nlo', 'nls', 0, 'makenlo2nls');
sub makenlo2nls {
system("makeindex -s nomencl.ist -o '$_[0]'.nls '$_[0]'.nlo");
}
And in turn the pdflatexmk engine is the script file:
#!/bin/bash
# pdflatexmk.engine
#
export TSBIN="$HOME/Library/TeXShop/bin/tslatexmk"
export LTMKBIN="$HOME/Library/TeXShop/bin/tslatexmk"
export LTMKEDIT="$HOME/Library/TeXShop/bin"
# make sure latexmkrcedit exists in bin
if [ ! -e "${LTMKEDIT}/latexmkrcedit" ] ; then
cp "${TSBIN}/latexmkrcDONTedit" "${LTMKEDIT}/latexmkrcedit"
fi
# Use local rc file platexmkrc if it exists. p = project
export localrc=""
if [ -e ./platexmkrc ] ; then
export localrc="-r ./platexmkrc"
fi
"${LTMKBIN}"/latexmk -pdf -r "${LTMKEDIT}/latexmkrcedit" -r "${TSBIN}/pdflatexmkrc" ${localrc} "$1"
For an ordinary index, calling makeindex
(via the imakeidx
package) does work with memoir
.
For example, the following does produce an index:
\documentclass{memoir}
\usepackage{amsmath}
\usepackage[makeindex]{imakeidx}
\makeindex[options=-s indexheaders]
%%\makeglossary
%%\makeindex[options=-s glossarystyle.gst -o book.gls book.glo]
\begin{document}
The empty set is denoted by $\emptyset$.%
\index{empty set!notation}
%%\glossary{$\emptyset$}{empty set}
The set of all subsets of a set $X$ is denoted by $\mathcal{P}(X)$.%
\index{power set}
%%\glossary{$\mathcal{P}(X)$}{power set of set}
\newpage
For sets $X$ and $Y$, the notation $f \colon X \to Y$ means that $f$ is a functions from $X$ to $Y$.%
\index{function!notation}
%%\glossary{$f \colon X \to Y$}{functions from one set to another}.
\printindex
%%\printglossary
\end{document}
Here the referenced index style file indexheaders.ist
is:
headings_flag 1
heading_prefix "{\\medskip\\hfill\\large\\textsf{\\textbf{"
heading_suffix "}}\\hfill}\\medskip\\nopagebreak\n"
New try: no error but no glossary
I changed the source file line
\makeindex[options=-s glossarystyle.gst,-o book.gls book.glo]
to
\makeindex[name=glossary,title=Index of notation,options=-s glossarystyle.gst -o book.gls book.glo]
and changed each \glossary
command so as to add optional file name (glossary
), e.g.:
glossary[glossary]{$\emptyset$}{empty set}
Now when I run TeXShop's pdflatexmk engine, it generates no errors -- but no glossary at all! It generates the expected glossary.glo
file with the several \glossaryentry
commands, but the glossary.gls
file is empty.
Solution!
Thanks to help from Herb Schulz on the macosx-tex mailing list and privately, the following solves the problem while still using only the internal glossary facility of memoir
, without the glossaries
package.
The corrected source:
\documentclass{memoir}
\usepackage{amsmath}
\newcommand{\from}{\mathpunct{:}}
%\newcommand{\from}{\protect\colon}
%\newcommand{\from}{:}
\makeglossary[glossary]
\renewcommand*{\glossaryname}{Index of Notation}
\makeindex
\begin{document}
The empty set is denoted by $\emptyset$.%
\index{empty set!notation}
\glossary[glossary]{$\emptyset$}{empty set}
The set of all subsets of a set $X$ is denoted by $\mathcal{P}(X)$.%
\index{power set}
\glossary[glossary]{$\mathcal{P}(X)$}{power set of set}
\newpage
$f \from X \to Y$
For sets $X$ and $Y$, the notation $f \from X \to Y$ means that $f$ is a functions from $X$ to $Y$.%
\index{function!notation}
\glossary[glossary]{$f \from X \to Y$}{function from one set to another}
\printglossary[glossary]
\printindex
\end{document}
Indeed, with TeXShop there is no need for imakeidx
. The source is processed from within TeXShop using its pdflatexmk
engine and the following additional file platexmkrc
placed in the source directory:
add_cus_dep('glo', 'gls', 0, 'makeglo2gls');
sub makeglo2gls {
system("makeindex -s basic.gst -t '$_[0]'.glg -o '$_[0]'.gls '$_[0]'.glo");
};
(For completeness: the three \newcommand{\from}...
versions shown are ways of avoiding an error with the math relation \colon
in the argument to \glosary
, without having to work around an error in \@@glossary
, per Extra '@' in glossary entry with memoir class .)
-s glossarystyle.gst
(in\makeindex
)? It doesn't look right, but I might be wrong. It looks as though you're creating the glossary files both through\write18
andpdflatexmk
, which might be confusing things.imakeidx
is supported on first glance through section 17.3 of the manual.pdflatexmk
not from TeX (ormemoir
). Do you have extra code forlatexmk
in a.latexmkrc
file?memoir
class does support usingimakeidx
in order to be able to callmakeindex
from within the source.tex
file. I'll edit my post to indicate how that works.