Question

I am trying to redefine the \nomencl_command in LyX, in order to be able to use the glossaries package in stead of the obsolete nomencl.

LyX allows you to specify the Nomenclature command, which by default is set to:

makeindex -s nomencl.ist

For glossaries the command is thus changed to:

makeglossaries

However, the LyX implementation of nomencl uses the more recent .nlo as an input file, and the .nls as an output file. Whereas glossaries uses the 'older' .glo and .gls Unfortunately, the extensions cannot be specified.

I found that the preferences file only says:

\nomencl_command "makeglossaries"

but the log output says:

makeglossaries "[filename].nlo" -o [filename].nls

So my question is where is \nomencl_command defined further?

Was it helpful?

Solution

The relevant code is in src/LaTeX.cpp. Note below that some diagnostic information is written to the latex debug flag. You can see this info on the terminal if you run LyX with lyx -dbg latex.

The following are excerpts from the file src/LaTeX.cpp from the soon-to-be-released (a matter of days) LyX 2.1.

FileName const nlofile(changeExtension(file.absFileName(), ".nlo"));
// If all nomencl entries are removed, nomencl writes an empty nlo file.
// DepTable::hasChanged() returns false in this case, since it does not
// distinguish empty files from non-existing files. This is why we need
// the extra checks here (to trigger a rerun). Cf. discussions in #8905.
// FIXME: Sort out the real problem in DepTable.
if (head.haschanged(nlofile) || (nlofile.exists() && nlofile.isFileEmpty()))
    rerun |= runMakeIndexNomencl(file, ".nlo", ".nls");
FileName const glofile(changeExtension(file.absFileName(), ".glo"));
if (head.haschanged(glofile))
    rerun |= runMakeIndexNomencl(file, ".glo", ".gls");

and

bool LaTeX::runMakeIndexNomencl(FileName const & file,
        string const & nlo, string const & nls)
{
    LYXERR(Debug::LATEX, "Running MakeIndex for nomencl.");
    message(_("Running MakeIndex for nomencl."));
    string tmp = lyxrc.nomencl_command + ' ';
    // onlyFileName() is needed for cygwin
    tmp += quoteName(onlyFileName(changeExtension(file.absFileName(), nlo)));
    tmp += " -o "
        + onlyFileName(changeExtension(file.toFilesystemEncoding(), nls));
    Systemcall one;
    one.startscript(Systemcall::Wait, tmp, path);
    return true;
}

and

// nomencl file
FileName const nls(changeExtension(file.absFileName(), ".nls"));
nls.removeFile();

// nomencl file (old version of the package)
FileName const gls(changeExtension(file.absFileName(), ".gls"));
gls.removeFile();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top