const char * const known_lyx_packages[] = {"amsbsy", "amsmath", "amssymb",
"amstext", "amsthm", "array", "babel", "booktabs", "calc", "CJK", "color",
"float", "fontspec", "graphicx", "hhline", "ifthen", "longtable", "makeidx",
-"multirow", "nomencl", "pdfpages", "refstyle", "rotating", "rotfloat", "splitidx",
-"setspace", "subscript", "textcomp", "tipa", "tipx", "tone", "ulem", "url",
-"varioref", "verbatim", "wrapfig", "xunicode", 0};
+"multirow", "nomencl", "pdfpages", "prettyref", "refstyle", "rotating",
+"rotfloat", "splitidx", "setspace", "subscript", "textcomp", "tipa", "tipx",
+"tone", "ulem", "url", "varioref", "verbatim", "wrapfig", "xunicode", 0};
// used for the handling of \newindex
int index_number = 0;
h_use_geometry = "false";
h_use_default_options = "false";
h_use_hyperref = "false";
- h_use_refstyle = "0";
+ h_use_refstyle = false;
h_use_packages["amsmath"] = "1";
h_use_packages["amssymb"] = "0";
h_use_packages["esint"] = "1";
h_language_package = "\\usepackage{" + name + "}";
}
- else if (name == "prettyref")
- ; // ignore this FIXME: Use the package separator mechanism instead
-
else if (name == "lyxskak") {
// ignore this and its options
const char * const o[] = {"ps", "mover", 0};
if (name == "splitidx")
h_use_indices = "true";
if (name == "refstyle")
- h_use_refstyle = "1";
+ h_use_refstyle = true;
+ else if (name == "prettyref")
+ h_use_refstyle = false;
if (!in_lyx_preamble) {
h_preamble << package_beg_sep << name
<< package_mid_sep << "\\usepackage{"
|| name == "thmref"
|| name == "lemref") {
p.skip_spaces();
- preamble.registerAutomaticallyLoadedPackage("refstyle");
in_lyx_preamble = true;
}
// only non-lyxspecific stuff
|| name == "\\providecommand\\corref[1]{\\ref{cor:#1}}"
|| name == "\\providecommand\\propref[1]{\\ref{prop:#1}}") {
p.skip_spaces();
- preamble.registerAutomaticallyLoadedPackage("refstyle");
in_lyx_preamble = true;
}
// only non-lyxspecific stuff
///
std::string notefontcolor() const { return h_notefontcolor; }
///
- std::string refstyle() const { return h_use_refstyle; }
+ bool refstyle() const { return h_use_refstyle; }
///
bool fontCJKSet() const { return h_font_cjk_set; }
///
std::map<std::string, std::string> h_use_packages;
std::string h_use_default_options;
std::string h_use_hyperref;
- std::string h_use_refstyle;
+ bool h_use_refstyle;
/*!
* Add package \p name with options \p options to used_packages.
\textclass article
\begin_preamble
+% Load refstyle before prettyref so that prettyref wins.
+% The real refstyle tests are in test-refstyle-theorems.tex.
+\usepackage{refstyle}
+
+
\def\mycommand{\textquestiondown}
\end_inset
-.
+. The command
+\begin_inset ERT
+status collapsed
+
+\begin_layout Plain Layout
+
+\backslash
+secref
+\end_layout
+
+\end_inset
+
+
+\begin_inset ERT
+status collapsed
+
+\begin_layout Plain Layout
+{
+\end_layout
+
+\end_inset
+
+lab:test
+\begin_inset ERT
+status collapsed
+
+\begin_layout Plain Layout
+}
+\end_layout
+
+\end_inset
+
+ will be parsed in ERT, since
+\begin_inset ERT
+status collapsed
+
+\begin_layout Plain Layout
+LyX
+\end_layout
+
+\end_inset
+
+ does not support refstyle and prettyref natively at the same time.
\end_layout
\begin_layout Section
\providecommand{\makenomenclature}{\makeglossary}
\makenomenclature
\usepackage{varioref}
-\usepackage{prettyref}
\usepackage{splitidx}
\makeindex
\newindex[Index]{idx}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
+% Load refstyle before prettyref so that prettyref wins.
+% The real refstyle tests are in test-refstyle-theorems.tex.
+\usepackage{refstyle}
+\AtBeginDocument{\providecommand\secref[1]{\ref{sec:#1}}}
+\usepackage{prettyref}
+
\def\mycommand{\textquestiondown}
\begin{document}
reference~\eqref{lab:test} (from amsmath package), or varioref's
equivalents~\vref{lab:test} and~\vpageref{lab:test}, without
forgetting pretty references like~\prettyref{lab:test}.
+The command \secref{lab:test} will be parsed in ERT, since LyX
+does not support refstyle and prettyref natively at the same time.
\section{Cites\index{Cites}}
skip_spaces_braces(p);
}
- else if ((where = is_known(t.cs(), known_ref_commands))) {
- // \eqref can also occur if refstyle is used
- if (t.cs() == "eqref" && preamble.refstyle() == "1") {
- context.check_layout(os);
- begin_command_inset(os, "ref", "formatted");
- os << "reference \"eq:"
- << convert_command_inset_arg(p.verbatim_item())
- << "\"\n";
- end_inset(os);
- preamble.registerAutomaticallyLoadedPackage("refstyle");
- } else {
- string const opt = p.getOpt();
- if (opt.empty()) {
- context.check_layout(os);
- begin_command_inset(os, "ref",
- known_coded_ref_commands[where - known_ref_commands]);
- os << "reference \""
- << convert_command_inset_arg(p.verbatim_item())
- << "\"\n";
- end_inset(os);
- if (t.cs() == "vref" || t.cs() == "vpageref")
- preamble.registerAutomaticallyLoadedPackage("varioref");
- } else {
- // LyX does not yet support optional arguments of ref commands
- output_ert_inset(os, t.asInput() + '[' + opt + "]{" +
- p.verbatim_item() + "}", context);
- }
- }
- }
-
- else if ((where = is_known(t.cs(), known_refstyle_commands))) {
+ // handle refstyle first to catch \eqref which can also occur
+ // without refstyle. Only recognize these commands if
+ // refstyle.sty was found in the preamble (otherwise \eqref
+ // and user defined ref commands could be misdetected).
+ else if ((where = is_known(t.cs(), known_refstyle_commands)) &&
+ preamble.refstyle()) {
context.check_layout(os);
- // \eqref can also occur if refstyle is not used
- // this case is already handled in the previous else if
begin_command_inset(os, "ref", "formatted");
os << "reference \"";
os << known_refstyle_prefixes[where - known_refstyle_commands]
preamble.registerAutomaticallyLoadedPackage("refstyle");
}
+ // if refstyle is used, we must not convert \prettyref to a
+ // formatted reference, since that would result in a refstyle command.
+ else if ((where = is_known(t.cs(), known_ref_commands)) &&
+ (t.cs() != "prettyref" || !preamble.refstyle())) {
+ string const opt = p.getOpt();
+ if (opt.empty()) {
+ context.check_layout(os);
+ begin_command_inset(os, "ref",
+ known_coded_ref_commands[where - known_ref_commands]);
+ os << "reference \""
+ << convert_command_inset_arg(p.verbatim_item())
+ << "\"\n";
+ end_inset(os);
+ if (t.cs() == "vref" || t.cs() == "vpageref")
+ preamble.registerAutomaticallyLoadedPackage("varioref");
+ else if (t.cs() == "prettyref")
+ preamble.registerAutomaticallyLoadedPackage("prettyref");
+ } else {
+ // LyX does not yet support optional arguments of ref commands
+ output_ert_inset(os, t.asInput() + '[' + opt + "]{" +
+ p.verbatim_item() + '}', context);
+ }
+ }
+
else if (use_natbib &&
is_known(t.cs(), known_natbib_commands) &&
((t.cs() != "citefullauthor" &&