mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-11 13:46:43 +00:00
tex2lyx: support for multiple indices and subindices
This commit is contained in:
parent
a8563a0f02
commit
1d6573a330
@ -185,6 +185,9 @@ const char * const known_lyx_packages[] = {"amsbsy", "amsmath", "amssymb",
|
|||||||
"setspace", "subscript", "textcomp", "tipa", "tipx", "ulem", "url", "varioref",
|
"setspace", "subscript", "textcomp", "tipa", "tipx", "ulem", "url", "varioref",
|
||||||
"verbatim", "wrapfig", "xunicode", 0};
|
"verbatim", "wrapfig", "xunicode", 0};
|
||||||
|
|
||||||
|
// used for the handling of \newindex
|
||||||
|
int index_number = 0;
|
||||||
|
|
||||||
// codes used to remove packages that are loaded automatically by LyX.
|
// codes used to remove packages that are loaded automatically by LyX.
|
||||||
// Syntax: package_beg_sep<name>package_mid_sep<package loading code>package_end_sep
|
// Syntax: package_beg_sep<name>package_mid_sep<package loading code>package_end_sep
|
||||||
const char package_beg_sep = '\001';
|
const char package_beg_sep = '\001';
|
||||||
@ -469,7 +472,7 @@ Preamble::Preamble() : one_language(true), title_layout_found(false),
|
|||||||
h_html_be_strict = "false";
|
h_html_be_strict = "false";
|
||||||
h_html_css_as_file = "0";
|
h_html_css_as_file = "0";
|
||||||
h_html_math_output = "0";
|
h_html_math_output = "0";
|
||||||
h_index = "Index";
|
h_index[0] = "Index";
|
||||||
h_index_command = "default";
|
h_index_command = "default";
|
||||||
h_inputencoding = "auto";
|
h_inputencoding = "auto";
|
||||||
h_justification = "true";
|
h_justification = "true";
|
||||||
@ -508,7 +511,7 @@ Preamble::Preamble() : one_language(true), title_layout_found(false),
|
|||||||
//h_pdf_quoted_options;
|
//h_pdf_quoted_options;
|
||||||
h_quotes_language = "english";
|
h_quotes_language = "english";
|
||||||
h_secnumdepth = "3";
|
h_secnumdepth = "3";
|
||||||
h_shortcut = "idx";
|
h_shortcut[0] = "idx";
|
||||||
h_spacing = "single";
|
h_spacing = "single";
|
||||||
h_suppress_date = "false";
|
h_suppress_date = "false";
|
||||||
h_textclass = "article";
|
h_textclass = "article";
|
||||||
@ -1141,10 +1144,19 @@ bool Preamble::writeLyXHeader(ostream & os, bool subdoc)
|
|||||||
os << "\\backgroundcolor " << h_backgroundcolor << '\n';
|
os << "\\backgroundcolor " << h_backgroundcolor << '\n';
|
||||||
if (!h_boxbgcolor.empty())
|
if (!h_boxbgcolor.empty())
|
||||||
os << "\\boxbgcolor " << h_boxbgcolor << '\n';
|
os << "\\boxbgcolor " << h_boxbgcolor << '\n';
|
||||||
os << "\\index " << h_index << '\n'
|
if (index_number != 0)
|
||||||
<< "\\shortcut " << h_shortcut << '\n'
|
for (int i = 0; i < index_number; i++) {
|
||||||
|
os << "\\index " << h_index[i] << '\n'
|
||||||
|
<< "\\shortcut " << h_shortcut[i] << '\n'
|
||||||
<< "\\color " << h_color << '\n'
|
<< "\\color " << h_color << '\n'
|
||||||
<< "\\end_index\n";
|
<< "\\end_index\n";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
os << "\\index " << h_index[0] << '\n'
|
||||||
|
<< "\\shortcut " << h_shortcut[0] << '\n'
|
||||||
|
<< "\\color " << h_color << '\n'
|
||||||
|
<< "\\end_index\n";
|
||||||
|
}
|
||||||
os << h_margins
|
os << h_margins
|
||||||
<< "\\secnumdepth " << h_secnumdepth << "\n"
|
<< "\\secnumdepth " << h_secnumdepth << "\n"
|
||||||
<< "\\tocdepth " << h_tocdepth << "\n"
|
<< "\\tocdepth " << h_tocdepth << "\n"
|
||||||
@ -1369,6 +1381,23 @@ void Preamble::parse(Parser & p, string const & forceclass,
|
|||||||
p.setCatcode('@', catOther);
|
p.setCatcode('@', catOther);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (t.cs() == "makeindex") {
|
||||||
|
// LyX will re-add this if a print index command is found
|
||||||
|
p.skip_spaces();
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (t.cs() == "newindex") {
|
||||||
|
string const indexname = p.getArg('[', ']');
|
||||||
|
string const shortcut = p.verbatim_item();
|
||||||
|
if (!indexname.empty())
|
||||||
|
h_index[index_number] = indexname;
|
||||||
|
else
|
||||||
|
h_index[index_number] = shortcut;
|
||||||
|
h_shortcut[index_number] = shortcut;
|
||||||
|
index_number += 1;
|
||||||
|
p.skip_spaces();
|
||||||
|
}
|
||||||
|
|
||||||
else if (t.cs() == "RS@ifundefined") {
|
else if (t.cs() == "RS@ifundefined") {
|
||||||
string const name = p.verbatim_item();
|
string const name = p.verbatim_item();
|
||||||
string const body1 = p.verbatim_item();
|
string const body1 = p.verbatim_item();
|
||||||
|
@ -138,7 +138,7 @@ private:
|
|||||||
std::string h_html_be_strict;
|
std::string h_html_be_strict;
|
||||||
std::string h_html_css_as_file;
|
std::string h_html_css_as_file;
|
||||||
std::string h_html_math_output;
|
std::string h_html_math_output;
|
||||||
std::string h_index;
|
std::string h_index[99];
|
||||||
std::string h_index_command;
|
std::string h_index_command;
|
||||||
std::string h_inputencoding;
|
std::string h_inputencoding;
|
||||||
std::string h_justification;
|
std::string h_justification;
|
||||||
@ -178,7 +178,7 @@ private:
|
|||||||
std::string h_pdf_quoted_options;
|
std::string h_pdf_quoted_options;
|
||||||
std::string h_quotes_language;
|
std::string h_quotes_language;
|
||||||
std::string h_secnumdepth;
|
std::string h_secnumdepth;
|
||||||
std::string h_shortcut;
|
std::string h_shortcut[99];
|
||||||
std::string h_spacing;
|
std::string h_spacing;
|
||||||
std::string h_suppress_date;
|
std::string h_suppress_date;
|
||||||
std::string h_textclass;
|
std::string h_textclass;
|
||||||
|
@ -29,8 +29,6 @@ Format LaTeX feature LyX feature
|
|||||||
329 master documents \master
|
329 master documents \master
|
||||||
332 ? InsetGraphics groupId
|
332 ? InsetGraphics groupId
|
||||||
343 ? \use_default_options
|
343 ? \use_default_options
|
||||||
353 \printsubindex InsetIndex
|
|
||||||
354 \printindex*, \printsubindex* InsetIndex
|
|
||||||
358 custom bibtex command \bibtex_command
|
358 custom bibtex command \bibtex_command
|
||||||
358 custom makeindex command \index_command
|
358 custom makeindex command \index_command
|
||||||
363 horizontal longtable alignment InsetTabular
|
363 horizontal longtable alignment InsetTabular
|
||||||
|
@ -60,6 +60,14 @@
|
|||||||
\shortcut idx
|
\shortcut idx
|
||||||
\color #008000
|
\color #008000
|
||||||
\end_index
|
\end_index
|
||||||
|
\index new
|
||||||
|
\shortcut new
|
||||||
|
\color #008000
|
||||||
|
\end_index
|
||||||
|
\index test
|
||||||
|
\shortcut test
|
||||||
|
\color #008000
|
||||||
|
\end_index
|
||||||
\secnumdepth 3
|
\secnumdepth 3
|
||||||
\tocdepth 3
|
\tocdepth 3
|
||||||
\paragraph_separation indent
|
\paragraph_separation indent
|
||||||
|
@ -60,6 +60,14 @@
|
|||||||
\shortcut idx
|
\shortcut idx
|
||||||
\color #008000
|
\color #008000
|
||||||
\end_index
|
\end_index
|
||||||
|
\index new
|
||||||
|
\shortcut new
|
||||||
|
\color #008000
|
||||||
|
\end_index
|
||||||
|
\index test
|
||||||
|
\shortcut test
|
||||||
|
\color #008000
|
||||||
|
\end_index
|
||||||
\secnumdepth 3
|
\secnumdepth 3
|
||||||
\tocdepth 3
|
\tocdepth 3
|
||||||
\paragraph_separation indent
|
\paragraph_separation indent
|
||||||
|
@ -60,6 +60,14 @@
|
|||||||
\shortcut idx
|
\shortcut idx
|
||||||
\color #008000
|
\color #008000
|
||||||
\end_index
|
\end_index
|
||||||
|
\index new
|
||||||
|
\shortcut new
|
||||||
|
\color #008000
|
||||||
|
\end_index
|
||||||
|
\index test
|
||||||
|
\shortcut test
|
||||||
|
\color #008000
|
||||||
|
\end_index
|
||||||
\secnumdepth 3
|
\secnumdepth 3
|
||||||
\tocdepth 3
|
\tocdepth 3
|
||||||
\paragraph_separation indent
|
\paragraph_separation indent
|
||||||
|
@ -66,6 +66,14 @@
|
|||||||
\shortcut idx
|
\shortcut idx
|
||||||
\color #008000
|
\color #008000
|
||||||
\end_index
|
\end_index
|
||||||
|
\index new
|
||||||
|
\shortcut new
|
||||||
|
\color #008000
|
||||||
|
\end_index
|
||||||
|
\index test
|
||||||
|
\shortcut test
|
||||||
|
\color #008000
|
||||||
|
\end_index
|
||||||
\secnumdepth 3
|
\secnumdepth 3
|
||||||
\tocdepth 3
|
\tocdepth 3
|
||||||
\paragraph_separation indent
|
\paragraph_separation indent
|
||||||
@ -6257,7 +6265,7 @@ options "bibtotoc,test"
|
|||||||
\end_layout
|
\end_layout
|
||||||
|
|
||||||
\begin_layout Standard
|
\begin_layout Standard
|
||||||
normal index:
|
undefined index:
|
||||||
\end_layout
|
\end_layout
|
||||||
|
|
||||||
\begin_layout Standard
|
\begin_layout Standard
|
||||||
@ -6269,6 +6277,79 @@ type "idx"
|
|||||||
\end_inset
|
\end_inset
|
||||||
|
|
||||||
|
|
||||||
|
\end_layout
|
||||||
|
|
||||||
|
\begin_layout Standard
|
||||||
|
index "idx":
|
||||||
|
\end_layout
|
||||||
|
|
||||||
|
\begin_layout Standard
|
||||||
|
|
||||||
|
\begin_inset CommandInset index_print
|
||||||
|
LatexCommand printindex
|
||||||
|
type "idx"
|
||||||
|
|
||||||
|
\end_inset
|
||||||
|
|
||||||
|
|
||||||
|
\end_layout
|
||||||
|
|
||||||
|
\begin_layout Standard
|
||||||
|
index "new":
|
||||||
|
\end_layout
|
||||||
|
|
||||||
|
\begin_layout Standard
|
||||||
|
|
||||||
|
\begin_inset CommandInset index_print
|
||||||
|
LatexCommand printindex
|
||||||
|
type "new"
|
||||||
|
|
||||||
|
\end_inset
|
||||||
|
|
||||||
|
|
||||||
|
\end_layout
|
||||||
|
|
||||||
|
\begin_layout Standard
|
||||||
|
subindex "new":
|
||||||
|
\end_layout
|
||||||
|
|
||||||
|
\begin_layout Standard
|
||||||
|
|
||||||
|
\begin_inset CommandInset index_print
|
||||||
|
LatexCommand printsubindex
|
||||||
|
type "idx"
|
||||||
|
|
||||||
|
\end_inset
|
||||||
|
|
||||||
|
|
||||||
|
\end_layout
|
||||||
|
|
||||||
|
\begin_layout Standard
|
||||||
|
index of all indices:
|
||||||
|
\end_layout
|
||||||
|
|
||||||
|
\begin_layout Standard
|
||||||
|
|
||||||
|
\begin_inset CommandInset index_print
|
||||||
|
LatexCommand printindex*
|
||||||
|
|
||||||
|
\end_inset
|
||||||
|
|
||||||
|
|
||||||
|
\end_layout
|
||||||
|
|
||||||
|
\begin_layout Standard
|
||||||
|
subindex of all indices:
|
||||||
|
\end_layout
|
||||||
|
|
||||||
|
\begin_layout Standard
|
||||||
|
|
||||||
|
\begin_inset CommandInset index_print
|
||||||
|
LatexCommand printsubindex*
|
||||||
|
|
||||||
|
\end_inset
|
||||||
|
|
||||||
|
|
||||||
\end_layout
|
\end_layout
|
||||||
|
|
||||||
\begin_layout Standard
|
\begin_layout Standard
|
||||||
|
@ -21,7 +21,9 @@
|
|||||||
\usepackage{prettyref}
|
\usepackage{prettyref}
|
||||||
\usepackage{splitidx}
|
\usepackage{splitidx}
|
||||||
\makeindex
|
\makeindex
|
||||||
|
\newindex[Index]{idx}
|
||||||
|
\newindex[new]{new}
|
||||||
|
\newindex{test}
|
||||||
\usepackage{graphicx}
|
\usepackage{graphicx}
|
||||||
\usepackage{longtable}
|
\usepackage{longtable}
|
||||||
\usepackage{xargs}
|
\usepackage{xargs}
|
||||||
@ -611,10 +613,30 @@ with \textbackslash{}addcontentsline and \textbackslash{}nocite\{{*}\}:
|
|||||||
\bibliography{xampl}
|
\bibliography{xampl}
|
||||||
|
|
||||||
|
|
||||||
normal index:
|
undefined index:
|
||||||
|
|
||||||
\printindex{}
|
\printindex{}
|
||||||
|
|
||||||
|
index "idx":
|
||||||
|
|
||||||
|
\printindex[idx]{}
|
||||||
|
|
||||||
|
index "new":
|
||||||
|
|
||||||
|
\printindex[new]{}
|
||||||
|
|
||||||
|
subindex "new":
|
||||||
|
|
||||||
|
\printsubindex[idx]{}
|
||||||
|
|
||||||
|
index of all indices:
|
||||||
|
|
||||||
|
\printindex*{}
|
||||||
|
|
||||||
|
subindex of all indices:
|
||||||
|
|
||||||
|
\printsubindex*{}
|
||||||
|
|
||||||
normal nomenclature:
|
normal nomenclature:
|
||||||
|
|
||||||
\printnomenclature hello
|
\printnomenclature hello
|
||||||
|
@ -3526,10 +3526,23 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
|
|||||||
end_inset(os);
|
end_inset(os);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (t.cs() == "printindex") {
|
else if (t.cs() == "printindex" || t.cs() == "printsubindex") {
|
||||||
context.check_layout(os);
|
context.check_layout(os);
|
||||||
begin_command_inset(os, "index_print", "printindex");
|
string commandname = t.cs();
|
||||||
|
bool star = false;
|
||||||
|
if (p.next_token().asInput() == "*") {
|
||||||
|
commandname += "*";
|
||||||
|
star = true;
|
||||||
|
p.get_token();
|
||||||
|
}
|
||||||
|
begin_command_inset(os, "index_print", commandname);
|
||||||
|
string const indexname = p.getArg('[', ']');
|
||||||
|
if (!star) {
|
||||||
|
if (indexname.empty())
|
||||||
os << "type \"idx\"\n";
|
os << "type \"idx\"\n";
|
||||||
|
else
|
||||||
|
os << "type \"" << indexname << "\"\n";
|
||||||
|
}
|
||||||
end_inset(os);
|
end_inset(os);
|
||||||
skip_spaces_braces(p);
|
skip_spaces_braces(p);
|
||||||
preamble.registerAutomaticallyLoadedPackage("makeidx");
|
preamble.registerAutomaticallyLoadedPackage("makeidx");
|
||||||
|
Loading…
Reference in New Issue
Block a user