mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Add support for multiple indexes in Memoir
As with almost everything, this class bakes its own cake also with multiple indexes. So we need to account for this to produce compilable output. Not very nice, but there you go!
This commit is contained in:
parent
fe1a3b57df
commit
d4f58c96b5
@ -18,6 +18,8 @@ PageSize letter
|
||||
Provides makeidx 1
|
||||
Provides framed 1
|
||||
Provides subscript 1
|
||||
# Memoir has its own implementation
|
||||
Provides memoir-idx 1
|
||||
# Geometry is supported, but the package options and paper sizes
|
||||
# are ignored
|
||||
Provides geometry-light 1
|
||||
|
@ -1886,6 +1886,7 @@ Buffer::ExportStatus Buffer::writeLaTeXSource(otexstream & os,
|
||||
runparams.use_hyperref = features.isRequired("hyperref")
|
||||
|| features.isProvided("hyperref");
|
||||
runparams.use_CJK = features.mustProvide("CJK");
|
||||
runparams.use_memindex = features.isProvided("memoir-idx");
|
||||
}
|
||||
LYXERR(Debug::OUTFILE, " Buffer validation done.");
|
||||
|
||||
@ -4220,6 +4221,7 @@ unique_ptr<TexRow> Buffer::getSourceCode(odocstream & os, string const & format,
|
||||
runparams.use_babel = features.useBabel();
|
||||
runparams.use_hyperref = features.isRequired("hyperref")
|
||||
|| features.isProvided("hyperref");
|
||||
runparams.use_memindex = features.isProvided("memoir-idx");
|
||||
// latex or literate
|
||||
otexstream ots(os);
|
||||
// output above
|
||||
|
@ -2279,8 +2279,16 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
|
||||
// Additional Indices
|
||||
if (features.isRequired("splitidx")) {
|
||||
for (auto const & idx : indiceslist()) {
|
||||
if (features.isProvided("memoir-idx")) {
|
||||
if (idx.shortcut() == "idx")
|
||||
continue;
|
||||
os << "\\makeindex[";
|
||||
} else
|
||||
os << "\\newindex{";
|
||||
os << escape(idx.shortcut());
|
||||
if (features.isProvided("memoir-idx"))
|
||||
os << "]\n";
|
||||
else
|
||||
os << "}\n";
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "Format.h"
|
||||
#include "InsetList.h"
|
||||
#include "Language.h"
|
||||
#include "LaTeXFeatures.h"
|
||||
#include "LaTeX.h"
|
||||
#include "LyXRC.h"
|
||||
#include "Mover.h"
|
||||
@ -555,6 +556,15 @@ Converters::RetVal Converters::convert(Buffer const * buffer,
|
||||
"tmpfile.out"));
|
||||
}
|
||||
|
||||
if (buffer && buffer->params().use_indices && conv.latex()) {
|
||||
// We need to validate the buffer to get access to features.
|
||||
// FIXME Not nice that we need to do this here.
|
||||
LYXERR(Debug::OUTFILE, " Validating buffer...");
|
||||
LaTeXFeatures features(*buffer, buffer->params(), runparams);
|
||||
buffer->validate(features);
|
||||
runparams.use_memindex = features.isProvided("memoir-idx");
|
||||
}
|
||||
|
||||
if (buffer && buffer->params().use_minted
|
||||
&& lyxrc.pygmentize_command.empty() && conv.latex()) {
|
||||
bool dowarn = false;
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "Buffer.h"
|
||||
#include "BufferList.h"
|
||||
#include "BufferParams.h"
|
||||
#include "IndicesList.h"
|
||||
#include "LyXRC.h"
|
||||
#include "LyX.h"
|
||||
#include "DepTable.h"
|
||||
@ -466,6 +467,41 @@ int LaTeX::run(TeXErrors & terr)
|
||||
iscanres = scanIlgFile(terr);
|
||||
rerun = true;
|
||||
}
|
||||
// This is Memoir's multi-index idiosyncracy
|
||||
if (runparams.use_indices && runparams.use_memindex) {
|
||||
Buffer const * buf = theBufferList().getBufferFromTmp(file.absFileName());
|
||||
if (buf) {
|
||||
IndicesList const & indiceslist = buf->params().indiceslist();
|
||||
if (!indiceslist.empty()) {
|
||||
IndicesList::const_iterator it = indiceslist.begin();
|
||||
IndicesList::const_iterator const end = indiceslist.end();
|
||||
for (; it != end; ++it) {
|
||||
docstring const & ci = it->shortcut();
|
||||
if (ci == "idx")
|
||||
continue;
|
||||
FileName const aidxfile(to_utf8(ci + ".idx"));
|
||||
LYXERR(Debug::OUTFILE, "Running Index Processor for " << ci);
|
||||
message(_("Running Index Processor."));
|
||||
// onlyFileName() is needed for cygwin
|
||||
int const ret =
|
||||
runMakeIndex(onlyFileName(aidxfile.absFileName()), runparams);
|
||||
if (ret == Systemcall::KILLED || ret == Systemcall::TIMEOUT)
|
||||
return ret;
|
||||
else if (ret != Systemcall::OK) {
|
||||
iscanres |= INDEX_ERROR;
|
||||
terr.insertError(0,
|
||||
_("Index Processor Error"),
|
||||
_("The index processor did not run successfully. "
|
||||
"Please check the output of View > Messages Pane!"));
|
||||
}
|
||||
FileName const ailgfile(changeExtension(aidxfile.absFileName(), ".ilg"));
|
||||
if (ailgfile.exists())
|
||||
iscanres = scanIlgFile(terr, ailgfile);
|
||||
rerun = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (run_nomencl) {
|
||||
int const ret = runMakeIndexNomencl(file, ".nlo", ".nls");
|
||||
if (ret == Systemcall::KILLED || ret == Systemcall::TIMEOUT)
|
||||
@ -592,7 +628,7 @@ int LaTeX::runMakeIndex(string const & f, OutputParams const & rp,
|
||||
tmp = subst(tmp, "$$lang", doc_lang->babel());
|
||||
tmp = subst(tmp, "$$lcode", doc_lang->code());
|
||||
}
|
||||
if (rp.use_indices) {
|
||||
if (rp.use_indices && !rp.use_memindex) {
|
||||
tmp = lyxrc.splitindex_command + " -m " + quoteName(tmp);
|
||||
LYXERR(Debug::OUTFILE,
|
||||
"Multiple indices. Using splitindex command: " << tmp);
|
||||
@ -1640,9 +1676,11 @@ int LaTeX::scanBlgFile(DepTable & dep, TeXErrors & terr)
|
||||
}
|
||||
|
||||
|
||||
int LaTeX::scanIlgFile(TeXErrors & terr)
|
||||
int LaTeX::scanIlgFile(TeXErrors & terr, FileName const fn)
|
||||
{
|
||||
FileName const ilg_file(changeExtension(file.absFileName(), "ilg"));
|
||||
FileName const ilg_file = fn.empty()
|
||||
? FileName(changeExtension(file.absFileName(), "ilg"))
|
||||
: fn;
|
||||
LYXERR(Debug::OUTFILE, "Scanning ilg file: " << ilg_file);
|
||||
|
||||
ifstream ifs(ilg_file.toFilesystemEncoding().c_str());
|
||||
|
@ -230,7 +230,7 @@ private:
|
||||
int scanBlgFile(DepTable & head, TeXErrors & terr);
|
||||
|
||||
///
|
||||
int scanIlgFile(TeXErrors & terr);
|
||||
int scanIlgFile(TeXErrors & terr, support::FileName const fn = support::FileName());
|
||||
|
||||
///
|
||||
bool runBibTeX(std::vector<AuxInfo> const &,
|
||||
|
@ -1360,7 +1360,7 @@ string const LaTeXFeatures::getPackages() const
|
||||
if (isRequired("makeidx") || isRequired("splitidx")) {
|
||||
if (!isProvided("makeidx") && !isRequired("splitidx"))
|
||||
packages << "\\usepackage{makeidx}\n";
|
||||
if (mustProvide("splitidx"))
|
||||
if (mustProvide("splitidx") && !isProvided("memoir-idx"))
|
||||
packages << "\\usepackage{splitidx}\n";
|
||||
packages << "\\makeindex\n";
|
||||
}
|
||||
|
@ -223,6 +223,11 @@ public:
|
||||
*/
|
||||
bool use_indices = false;
|
||||
|
||||
/** Are we using the memoir way to
|
||||
* to multiple indices?
|
||||
*/
|
||||
bool use_memindex = false;
|
||||
|
||||
/** Are we using japanese (pLaTeX)?
|
||||
*/
|
||||
bool use_japanese = false;
|
||||
|
@ -142,6 +142,9 @@ void InsetIndex::latex(otexstream & ios, OutputParams const & runparams_in) cons
|
||||
|
||||
if (buffer().masterBuffer()->params().use_indices && !params_.index.empty()
|
||||
&& params_.index != "idx") {
|
||||
if (runparams.use_memindex)
|
||||
os << "\\index[";
|
||||
else
|
||||
os << "\\sindex[";
|
||||
os << escape(params_.index);
|
||||
os << "]{";
|
||||
@ -1406,6 +1409,16 @@ void InsetPrintIndex::latex(otexstream & os, OutputParams const & runparams_in)
|
||||
return;
|
||||
}
|
||||
OutputParams runparams = runparams_in;
|
||||
if (runparams.use_memindex) {
|
||||
if (getParam("type") == from_ascii("idx"))
|
||||
os << "\\printindex" << termcmd;
|
||||
else {
|
||||
os << "\\begingroup" << breakln;
|
||||
os << "\\renewcommand{\\indexname}{" << getParam("name") << "}" << breakln;
|
||||
os << "\\printindex[" << getParam("type") << "]" << breakln;
|
||||
os << "\\endgroup" << breakln;
|
||||
}
|
||||
} else
|
||||
os << getCommand(runparams);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user