# After I compiled a tex file by xelatex, I use Glosarries with Xindy to make a index, it reported:

    $makeglossaries test makeglossaries version 2.04 (2012-05-19) added glossary type 'main' (glg,gls,glo) xindy -L english -I xindy -M "test" -t "test.glg" -o "test.gls" "test.glo" Opening logfile "test.glg" ERROR: Opening logfile "test.glg" failed! ***Call to xindy failed*** Check 'test.glg' for details  And in test.glg, there are: *** Unable to execute: 'xindy -L english -I xindy -M "test" -t "test.glg" -o "test.gls" "test.glo"' *** Status report: Opening logfile "test.glg" ERROR: Opening logfile "test.glg" failed!  But I can use xindy on my Mac in my terminal:  Jing@Jing2MacBook-Pro ~$ xindy
You need to specify --out-file if the raw index is read from standard input.
usage: xindy [-V?h] [-qv] [-d magic] [-o outfile.ind] [-t log] \
................


What's the problem?

# There is a similar problem and provided me an useful idea:

Makeindex fails when called from a script

# There is the true problem same as my question:

xindy cannot open the temp file

For 'glossaries' when it doesn't use Xindy, we have to use 'makeglossaries test.tex' in the folder where .tex is.

For 'glossaries' when it's with Xindy, Xindy also has the path problem, but we must copy the tex file to xindy's Temp folders, then xindy can only work.

# The keypoint is:

'makeglossaries' or xindy can not use the folder where .tex file(and some other files came from .tex after compiled by xelatex ) as the TMPDIR, it uses the system default TMPDIR, so 'makeglossaries' can not find .glg, then 'makeglossaries' can't make a index.

You can use command 'env' in Terminal to find out what is your default TMPDIR of system. My default TMPDIR in system is:

TMPDIR=/var/folders/9h/71txqqf572x998x6sm4c6l440000gn/T/


So I must copy all the tex file I want to make index in /var/folders/9h/71txqqf572x998x6sm4c6l440000gn/T/, compile tex file there, then xindy can only work.

Otherwise, we have to manully change the TMPDIR in Terminal to the folder where .tex file is after xelatex test.tex in current session.

If your tex file are in /Users/Jhering/mynewbook/,in Mac/Linux/Unix-like, to change TMPDIR looks like:

export TMPDIR=/Users/Jhering/mynewbook/


In windows ,eg:

set TEMP=C:\Users\Jhering\mynewbook


Then you can

makeglossaries test

xelatex test.tex


# But how can we don't need change the TMPDIR to the folder where .tex file is every time?

Sample Code (originally came from the package glossaries, none was edited):

Make sure you have had the parameter 'xindy' as follows:

      \usepackage[xindy]{glossaries}


The test.tex file is:

% This file is public domain.
%
% This is a sample document illustrating how to use the
% glossaries package with xindy. To create the document:
%
%   latex samplexdy
%   makeglossaries samplexdy
%   latex samplexdy
%
% If you don't have Perl installed, then use one of the
%
% If you want to have a separate "Mc" letter group do:
%
%    xindy -I xindy -M samplexdy-mc -t samplexdy.glg -o samplexdy.gls samplexdy.glo
%
% Otherwise do:
%
%  xindy -L english -C utf8 -I xindy -M samplexdy -t samplexdy.glg -o samplexdy.gls samplexdy.glo
%
\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fmtcount}

\usepackage[xindy,style=altlistgroup]{glossaries}

% Define a new command to do bold italic:

\newcommand*{\hyperbfit}[1]{\textit{\hyperbf{#1}}}

% Need to add this to the list of attributes in order
% to use it with xindy:
% (This command will have no effect if \noist is used)

% Redefine the page numbers so that they appear as a word:

\renewcommand*{\thepage}{\Numberstring{page}}

% Need to add this to the list of location styles.
% \Numberstring{page} gets expanded to
% \protect \Numberstringnum {<n>} (where <n> is the page number)
% so need to define the location in that format:
% (This command will have no effect if \noist is used)

\string\Numberstringnum\space\glsopenbrace"
"arabic-numbers" :sep "\glsclosebrace"}

% (Need to redefine \glsXpageXhyperbfit and
% \glsXpageXglsnumberformat after \makeglossaries to get the

% To have Mc as a separate group uncomment the following three
% lines:

%\setStyleFile{samplexdy-mc} % note no extension
%\noist
%\GlsSetXdyLanguage{}

% The above three lines specify to use samplexdy-mc.xdy (supplied
% with this file) and don't overwrite it. The language is
% unset using \GlsSetXdyLanguage{} as all the language
% dependent information is contained in samplexdy-mc.xdy
% Note that using \noist means that commands like
% an effect.

% Write the style file (if \noist isn't used)
% and activate glossary entries

\makeglossaries

% Each page location will be specified in the form:
%
% "\glsXpageXglsnumberformat{}{\protect \Numberstringnum "\marg{n}"}"
% or
% "\glsXpageXhyperbfit{}{\protect \Numberstringnum "\marg{n}"}"
%

\renewcommand{\glsXpageXglsnumberformat}[2]{%
}

\renewcommand{\glsXpageXhyperbfit}[2]{%
}

% Define glossary entries
% page numbers also appear in the locations, however I need
% to ensure that the referenced entries are added to the

description={Scottish engineer}}

\newglossaryentry{maclaurin}{name={Maclaurin, Colin},
first={Colin Maclaurin},text={Maclaurin},
description={Scottish mathematician best known for the
\gls{maclaurinseries}}}

\newglossaryentry{maclaurinseries}{name={Maclaurin series},
description={Series expansion},see={taylorstheorem}}

\newglossaryentry{taylorstheorem}{name={Taylor's theorem},
description={Theorem expressing a function $f(x)$ as the sum of
a polynomial and a remainder:
$f(x) = f(a)+f'(a)(x-a)+f''(a)(x-a^2)/2!+\cdots+R_n$
If $n\to\infty$ the expansion is a \glshyperlink{taylorseries}
and if $a=0$, the series is called a
\gls{maclaurinseries}}}

\newglossaryentry{taylorseries}{name={Taylor series},
description={Series expansion},see={taylorstheorem}}

\newglossaryentry{taylor}{name={Taylor, Brook},
first={Brook Taylor},text={Taylor},
description={English mathematician}}

\newglossaryentry{mcnemar}{name={McNemar, Quinn},
first={Quinn McNemar},text={McNemar},
description={Mathematician who introduced
\gls{mcnemarstest}. This entry has the number list
suppressed},nonumberlist}

\newglossaryentry{mcnemarstest}{name={McNemar's test},
description={A nonparametric test introduced by
\gls{mcnemar} in 1947}}

\newglossaryentry{mach}{name={Mach, Ernst},
first={Ernst Mach},text={Mach},
% if using samplexdy-mc.xdy, the following line is needed
% to prevent this entry being put in the "Mc" group
sort={mach, Ernst},
description={Czech/Austrian physicist and philosopher}}

\newglossaryentry{machnumber}{name={Mach number},
% if using samplexdy-mc.xdy, the following line is needed
% to prevent this entry being put in the "Mc" group
sort={mach number},
description={Ratio of the speed of a body in a fluid to the
speed of sound in that fluid named after \gls{mach}}}

\newglossaryentry{malthus}{name={Malthus, Thomas Robert},
first={Thomas Robert Malthus},text={Malthus},
description={English mathematician, sociologist and classicist}}

\newglossaryentry{ampereandre}{name={Ampère, André-Marie},
first={André-Marie Ampère},text={Ampère},
description={French mathematician and physicist}}

\newglossaryentry{ampere}{name={ampere},
description={SI unit of electric current named after
\gls{ampereandre}}}

\newglossaryentry{archimedes}{name={Archimedes of Syracuse},
first={Archimedes of Syracuse},text={Archimedes},
description={Greek mathematician}}

\newglossaryentry{archimedesprinciple}{name={Archemedes' principle},
description={Principle that if a body is submerged in a fluid
it experiences upthrust equal to the weight of the displaced
fluid. Named after \gls{archimedes}}}

\newglossaryentry{galton}{name={Galton, Sir Francis},
first={Sir Francis Galton},text={Galton},
description={English anthropologist}}

\newglossaryentry{gauss}{name={Gauss, Karl Friedrich},
first={Karl Friedrich Gauss},text={Gauss},
description={German mathematician}}

\newglossaryentry{gaussianint}{name={Gaussian integer},
description={Complex number where both real and imaginary
parts are integers}}

\newglossaryentry{peano}{name={Peano, Giuseppe},
first={Giuseppe Peano},text={Peano},
description={Italian mathematician}}

\newglossaryentry{peanoscurve}{name={Peano's curve},
description={A space-filling curve discovered by
\gls{peano}}}

\newglossaryentry{pearson}{name={Pearson, Karl},
first={Karl Pearson},text={Pearson},
description={English mathematician}}

\newglossaryentry{pearspmcc}{name={Pearson's product moment
correlation coefficient},description={Product moment correlation
coefficient named after \gls{pearson}}}

\begin{document}
\title{Sample Document Using the Glossaries Package With Xindy}
\author{Nicola Talbot}
\maketitle

\section{\glsentryfirst{gauss}}

This is a section on \gls[format=(]{gauss}. This section spans
several pages.

\newpage

it's the principle definition, the user-defined hyperbfit format is
used.

\newpage

The section on \gls[format=)]{gauss} ends here.

\section{Series Expansions}

This section is about series expansions. It mentions
\gls{maclaurin} and \gls{taylor}. It also discusses
\gls{taylorstheorem} which is related to the \gls{taylorseries}.
The \gls{maclaurinseries} is a special case of the
\gls{taylorseries}.

\section{\glsentryname{archimedesprinciple}}

This section discusses \gls{archimedesprinciple} which was
introduced by \gls{archimedes}.

\section{Another section}

This section covers \gls{mach} who introduced the \gls{machnumber}.
It also mentions \gls{ampereandre} after whom the
SI unit \gls{ampere} is named. It then discusses \gls{galton}
and \gls{malthus}. Finally it mentions \gls{mcadam}.

\newpage
\gls{mcnemarstest} and \gls{peano} who discovered \gls{peanoscurve}.

\printglossaries
\end{document}


# What an issue now in 21 century!

-
May you report the result of the command "ls -l test.glg" issued to the terminal? You have first to cd to the folder containing your test.tex file. –  egreg Oct 12 '12 at 6:43
Yes, I have in the folder containing your test.tex file, It just looks like above. Now I resolve the problem on a dirty way: I use xindy --inactive .... to find the temp folder of the xindy, then I copy the test.tex in it--/private/var/folders/9u/3d3d34trdetrgdDEffg/ Then I xelatex test.tex, makeglossaries test, xelatex test.tex there, It works. But it is so dirty, I don't know how to resolve it fine. –  WonderTree Oct 12 '12 at 6:50
Please, tell how you perform the compilation. It's rather strange that /private/var/folders is implicated in the procedure. What is the folder where test.tex is? –  egreg Oct 12 '12 at 6:56
I describe it in answer. –  WonderTree Oct 12 '12 at 8:33

1. test.tex is in the folder ~/翻译
2. I use xindy --interactive -L english -M.... in Terminal to find where the temp folder of xindy.

1. Copy test.tex in the temp folder of xindy.

4. In this folder use

xelatex test.tex
makeglossaries test
xelatex test.tex


5. Xindy works.

# But it is so dirty, I don't know how to resolve it fine.

-
I'm not sure that directory names with Chinese characters make TeX and related programs very happy. You could try with a folder name in plain ASCII characters, just to see whether it works without problems. –  egreg Oct 12 '12 at 11:13
@WonderTree: I tried your code with one of my machines (Snow Leopard + MacTeX 2011) and everything worked, including xindy. I had to replace the CJK characters from the folder name, though. Could you tell us a bit about your system, including shell, OS and MacTeX versions? :) –  Paulo Cereda Oct 12 '12 at 12:46
ML 10.8.2 , MacTeX 2012 , GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin12) –  WonderTree Oct 12 '12 at 15:16
My TMPDIR=/var/folders/9h/71txqqf572x998x6sm4c6l440000gn/T/ .And right now the tex file has to be in TMPDIR, then makeglossaries can only find the glg or some other files, otherwise it can't work. –  WonderTree Oct 12 '12 at 16:47
The keypoint is: 'makeglossaries' or xindy can not use the folder where .tex file(and some other files came from .tex) as the TMPDIR, it uses the system default TMPDIR, so 'makeglossaries' can not find .glg, then 'makeglossaries' can't make a index. We have to manully change the TMPDIR to the folder where .tex file is in current session. –  WonderTree Oct 12 '12 at 17:05