commit 4ea81b52f8c17d9eea1655e115ea6bc47377da2e
Author: Juergen Spitzmueller <[email protected]>
Date: Sun Mar 23 13:04:49 2025 +0100
Add support for zref-clever and zref-vario
tex2lyx support will follow.
---
development/FORMAT | 18 +++-
lib/chkconfig.ltx | 2 +
lib/doc/LaTeXConfig.lyx | 99 +++++++++++++++++++
lib/doc/UserGuide.lyx | 141 +++++++++++++++++++++++++--
lib/doc/de/UserGuide.lyx | 113 +++++++++++++++++++--
lib/lyx2lyx/lyx_2_5.py | 93 +++++++++++++++++-
src/LaTeXFeatures.cpp | 2 +
src/frontends/qt/GuiDocument.cpp | 1 +
src/frontends/qt/GuiRef.cpp | 15 ++-
src/frontends/qt/ui/RefUi.ui | 205 +++++++++++++++++++++------------------
src/insets/InsetRef.cpp | 58 ++++++++---
11 files changed, 624 insertions(+), 123 deletions(-)
diff --git a/development/FORMAT b/development/FORMAT
index 4ee108bf48..d9bd340254 100644
--- a/development/FORMAT
+++ b/development/FORMAT
@@ -8,7 +8,8 @@ changes happened in particular if possible. A good example
would be
-----------------------
2025-03-23 Jürgen Spitzmüller <[email protected]>
- * Format incremented to 636: Support for the cleveref package
+ * Format incremented to 636:
+ 1. Support for the cleveref package
\crossref_package cleveref
With CommandInset ref:
* LatexCommand formatted: \cref
@@ -17,6 +18,21 @@ changes happened in particular if possible. A good example
would be
* LatexCommand nameref: \namecref
+ caps "true": \nameCref
+ plural "true": \namecrefs, \nameCrefs
+ 2. Support for zref-clever and zref-vario
+ \crossref_package zref
+ With CommandInset ref:
+ * LatexCommand formatted: \zcref
+ + caps "true": \zcref[S]
+ + nolink "true": \zcref*
+ + options: \zcref[<options>]
+ * LatexCommand vref: \zvref
+ + caps "true": \zvref[S]
+ + nolink "true": \zvref*
+ + options: \zvref[<options>]
+ * LatexCommand vpageref: \zvpageref
+ + caps "true": \zvpageref[S]
+ + nolink "true": \zvpageref*
+ + options: \zvpageref[<options>]
2025-03-22 Jürgen Spitzmüller <[email protected]>
* Format incremented to 635: Rename buffer param \use_refstyle to
\crossref_package
diff --git a/lib/chkconfig.ltx b/lib/chkconfig.ltx
index 5d9e076d46..f36daf0876 100644
--- a/lib/chkconfig.ltx
+++ b/lib/chkconfig.ltx
@@ -439,6 +439,8 @@
\TestPackage{xkeyval}
\TestPackage{xltabular}
\TestPackage{xskak} % required by chessboard
+\TestPackage{zref-clever}
+\TestPackage{zref-vario}
% Packages used by LyX's documentation files
\TestPackage{arydshln}
diff --git a/lib/doc/LaTeXConfig.lyx b/lib/doc/LaTeXConfig.lyx
index 3b7a1ce0fe..c224c7a11c 100644
--- a/lib/doc/LaTeXConfig.lyx
+++ b/lib/doc/LaTeXConfig.lyx
@@ -10291,5 +10291,104 @@ color
uses it to output colored change tracking marks.
\end_layout
+\begin_layout Subsection
+zref-clever
+\end_layout
+
+\begin_layout Description
+Found:
+
+\begin_inset Info
+type "package"
+arg "zref-clever"
+\end_inset
+
+
+\end_layout
+
+\begin_layout Description
+CTAN:
+
+\family typewriter
+macros/latex/contrib/zref-clever
+\end_layout
+
+\begin_layout Description
+Notes:
+ The package
+\family sans
+zref-clever
+\family default
+ provides commands to identify reference labels by their context and
automatically output matching references (e.g.,
+
+\begin_inset Quotes eld
+\end_inset
+
+section
+\begin_inset space ~
+\end_inset
+
+3
+\begin_inset Quotes erd
+\end_inset
+
+).
+ It is an alternative approach to
+\family sans
+prettyref
+\family default
+ and
+\family sans
+refstyle
+\family default
+,
+ which both need a specific label prefix,
+ and
+\family sans
+cleveref
+\family default
+,
+ which it emulates and enhances.
+\end_layout
+
+\begin_layout Subsection
+zref-vario
+\end_layout
+
+\begin_layout Description
+Found:
+
+\begin_inset Info
+type "package"
+arg "zref-vario"
+\end_inset
+
+
+\end_layout
+
+\begin_layout Description
+CTAN:
+
+\family typewriter
+macros/latex/contrib/zref-vario
+\end_layout
+
+\begin_layout Description
+Notes:
+ The package
+\family sans
+zref-vario
+\family default
+ is a companion package to
+\family sans
+zref-clever
+\family default
+ which emulates page references known from the
+\family sans
+varioref
+\family default
+ package.
+\end_layout
+
\end_body
\end_document
diff --git a/lib/doc/UserGuide.lyx b/lib/doc/UserGuide.lyx
index 35f0a0e5d1..8c3ef7f1d1 100644
--- a/lib/doc/UserGuide.lyx
+++ b/lib/doc/UserGuide.lyx
@@ -31881,11 +31881,15 @@ status open
\change_inserted -712698321 1742721546
prettyref
+\change_unchanged
+
\end_layout
\end_inset
+\change_unchanged
+
\end_layout
\end_inset
@@ -32005,7 +32009,7 @@ newref\SpecialChar ligaturebreak
format
\series default
(prettyref)
-\change_inserted -712698321 1742721923
+\change_inserted -712698321 1742730901
,
\series bold
@@ -32015,7 +32019,14 @@ crefname|
\backslash
crefname
\series default
- (cleveref)
+ (cleveref),
+
+\series bold
+
+\backslash
+zcRefTypeSetup
+\series default
+ (zref-clever)
\change_unchanged
or
\series bold
@@ -32129,7 +32140,7 @@ For more information about defining formatted
references,
have a look at the package documentation
\begin_inset CommandInset citation
LatexCommand cite
-key "cleveref,prettyref,refstyle"
+key "cleveref,prettyref,refstyle,zref-clever"
literal "true"
\end_inset
@@ -32161,7 +32172,7 @@ refstyle
\change_unchanged
.
-\change_inserted -712698321 1742722131
+\change_inserted -712698321 1742730991
\family sans
Capitalized
@@ -32171,16 +32182,57 @@ Capitalized
refstyle
\series default
,
- and with formatted and textual references using
+ with formatted and textual references using
\series bold
cleveref
\series default
+,
+ and with formatted and
+\begin_inset Quotes eld
+\end_inset
+
+on page
+\begin_inset Quotes erd
+\end_inset
+
+ references with
+\series bold
+ zref-clever
+\series default
+ and
+\series bold
+zref-vario
+\series default
.
-\change_unchanged
+\change_deleted -712698321 1742731074
\begin_inset Newline newline
\end_inset
+
+\change_inserted -712698321 1742731076
+
+\end_layout
+
+\begin_deeper
+\begin_layout Standard
+
+\change_inserted -712698321 1742731072
+For
+\series bold
+ zref-clever
+\series default
+ and
+\series bold
+zref-vario
+\series default
+,
+ you can also insert custom options;
+ for the other packages,
+ this field is disabled.
+\end_layout
+
+\begin_layout Standard
If you activate the option
\family sans
Format cross-references in work area
@@ -32201,6 +32253,7 @@ Theorem 1
rather than just displaying the label.
\end_layout
+\end_deeper
\begin_layout Description
Textual
\begin_inset space ~
@@ -59589,11 +59642,15 @@ status open
\change_inserted -712698321 1742722254
cleveref
+\change_unchanged
+
\end_layout
\end_inset
+\change_unchanged
+
\end_layout
\end_inset
@@ -59610,6 +59667,8 @@ status collapsed
\change_inserted -712698321 1742722259
https://mirrors.ctan.org/macros/latex/contrib/cleveref/cleveref.pdf
+\change_unchanged
+
\end_layout
\end_inset
@@ -60051,6 +60110,76 @@
https://mirrors.ctan.org/macros/latex/contrib/refstyle/refstyle.pdf
\end_inset
+\change_inserted -712698321 1742730694
+
+\end_layout
+
+\begin_layout Bibliography
+
+\change_inserted -712698321 1742730701
+\begin_inset CommandInset bibitem
+LatexCommand bibitem
+key "zref-clever"
+literal "false"
+
+\end_inset
+
+
+\begin_inset CommandInset href
+LatexCommand href
+name "Documentation"
+target
"https://mirrors.ctan.org/macros/latex/contrib/zref-clever//zref-clever.pdf"
+literal "false"
+
+\end_inset
+
+ of the \SpecialChar LaTeX
+ package zref-clever
+\begin_inset Index idx
+range none
+pageformat default
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1742730695
+\SpecialChar LaTeX
+ packages
+\begin_inset IndexMacro subentry
+status open
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1742730730
+zref-clever
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+
+:
+\begin_inset Newline newline
+\end_inset
+
+
+\begin_inset Flex URL
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1742730723
+https://mirrors.ctan.org/macros/latex/contrib/refstyle//zref-clever.pdf
+\end_layout
+
+\end_inset
+
+
+\change_unchanged
+
\end_layout
\begin_layout Bibliography
diff --git a/lib/doc/de/UserGuide.lyx b/lib/doc/de/UserGuide.lyx
index db98488a7f..2266f5cf74 100644
--- a/lib/doc/de/UserGuide.lyx
+++ b/lib/doc/de/UserGuide.lyx
@@ -30802,7 +30802,7 @@ Dokumentklasse
\series bold
refstyle
\series default
- ist die Voreinstellung und bevorzugt.
+ ist die Voreinstellung.
Beachten Sie,
dass
\series bold
@@ -30825,7 +30825,14 @@ crefname|
\backslash
crefname
\series default
- (cleveref) oder
+ (cleveref)
+\series bold
+,
+
+\backslash
+zcRefTypeSetup
+\series default
+ (zref-clever) oder
\series bold
\backslash
@@ -30912,7 +30919,7 @@ Für weitere Informationen zur Definition formatierter
Querverweise konsultieren
\begin_inset CommandInset citation
LatexCommand cite
-key "cleveref,prettyref,refstyle"
+key "cleveref,prettyref,refstyle,zref-clever"
literal "true"
\end_inset
@@ -30941,18 +30948,50 @@ Großschreibung
\family default
ist bei formatierten Querverweisen mit
\series bold
-refstyle
+refstyle,
+
\series default
- und
+
\series bold
cleveref
+\series default
+ und
+\series bold
+zref-clever
\series default
aktiviert,
bei
\series bold
cleveref
\series default
- außerdem auch bei Textverweisen.
+ außerdem auch bei Textverweisen,
+ bei
+\series bold
+zref-clever\SpecialChar breakableslash
+zref-vario
+\series default
+ bei
+\begin_inset Quotes gld
+\end_inset
+
+auf Seite
+\begin_inset Quotes grd
+\end_inset
+
+-Verweisen.
+\begin_inset Newline newline
+\end_inset
+
+Für
+\series bold
+zref-clever
+\series default
+ und
+\series bold
+zref-vario
+\series default
+ können Sie auch benutzerdefinierte Optionen eingeben,
+ für die andere Pakete ist dies deaktiviert.
\begin_inset Newline newline
\end_inset
@@ -56871,6 +56910,68 @@ literal "true"
\end_inset
+\begin_inset CommandInset href
+LatexCommand href
+name "Dokumentation"
+target
"https://mirrors.ctan.org/macros/latex/contrib/zref-clever/zref-clever.pdf"
+literal "false"
+
+\end_inset
+
+ des \SpecialChar LaTeX
+-Pakets
+\series bold
+zref-clever
+\series default
+
+\begin_inset Index idx
+range none
+pageformat default
+status open
+
+\begin_layout Plain Layout
+\SpecialChar LaTeX
+-Paket
+\begin_inset IndexMacro subentry
+status open
+
+\begin_layout Plain Layout
+zref-clever
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+
+:
+\begin_inset Newline newline
+\end_inset
+
+
+\begin_inset Flex URL
+status collapsed
+
+\begin_layout Plain Layout
+https://mirrors.ctan.org/macros/latex/contrib/zref-clever/zref-clever.pdf
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Bibliography
+\begin_inset CommandInset bibitem
+LatexCommand bibitem
+key "zref-clever"
+literal "false"
+
+\end_inset
+
+
\begin_inset CommandInset href
LatexCommand href
name "Dokumentation"
diff --git a/lib/lyx2lyx/lyx_2_5.py b/lib/lyx2lyx/lyx_2_5.py
index d1b4a17287..afc069598f 100644
--- a/lib/lyx2lyx/lyx_2_5.py
+++ b/lib/lyx2lyx/lyx_2_5.py
@@ -2585,7 +2585,96 @@ def revert_cleveref(document):
document,
["\\usepackage{cleveref}"]
)
-
+
+
+def revert_zref(document):
+ "Reverts zref-clever and zref-vario commands to ERT"
+
+ use_zref = True
+ i = find_token(document.header, "\\crossref_package zref", 0)
+ if i == -1:
+ use_zref = False
+
+ if use_zref:
+ # Reset header
+ document.header[i] = "\\crossref_package prettyref"
+
+ # Check and revert insets
+ i = 0
+ need_zref_clever = False
+ need_zref_vario = False
+ while True:
+ i = find_token(document.body, "\\begin_inset CommandInset ref", i)
+ if i == -1:
+ break
+ j = find_end_of_inset(document.body, i)
+ if j == -1:
+ document.warning("Can't find end of reference inset at line %d!!"
% (i))
+ i += 1
+ continue
+
+ if not use_zref:
+ # only need to remove the options
+ del_token(document.body, "options", i, j)
+ i += 1
+ continue
+
+ vref = False
+ vpageref = False
+ k = find_token(document.body, "LatexCommand formatted", i, j)
+ if k == -1:
+ k = find_token(document.body, "LatexCommand vref", i, j)
+ if k == -1:
+ k = find_token(document.body, "LatexCommand vpageref", i, j)
+ if k == -1:
+ i += 1
+ continue
+ vpageref = True
+ else:
+ vref = True
+
+ caps = get_bool_value(document.body, "caps", i, j, False)
+ nolink = get_bool_value(document.body, "nolink", i, j, False)
+ label = get_quoted_value(document.body, "reference", i, j)
+ options = get_quoted_value(document.body, "options", i, j)
+
+ cmd = ""
+ if vref:
+ cmd = "\\zvref"
+ elif vpageref:
+ cmd = "\\zvpageref"
+ else:
+ cmd = "\\zcref"
+ if nolink:
+ cmd += "*"
+ opts = ""
+ if caps:
+ opts = "S"
+ if options != "":
+ opts += "," + options
+ elif options != "":
+ opts = options
+ if opts != "":
+ cmd += "[" + opts + "]"
+ cmd += "{" + label + "}"
+ document.body[i : j + 1] = put_cmd_in_ert([cmd])
+ if vref or vpageref:
+ need_zref_vario = True
+ else:
+ need_zref_clever = True
+ i += 1
+
+ # preamble
+ if need_zref_clever:
+ add_to_preamble(
+ document,
+ ["\\usepackage{zref-clever}"]
+ )
+ if need_zref_vario:
+ add_to_preamble(
+ document,
+ ["\\usepackage{zref-vario}"]
+ )
##
# Conversion hub
@@ -2613,7 +2702,7 @@ convert = [
revert = [
- [635, [revert_cleveref]],
+ [635, [revert_cleveref, revert_zref]],
[634, [revert_crossref_package]],
[633, [revert_colortbl]],
[632, [revert_doc_colors, revert_colorbox]],
diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp
index b40b3304d1..e7b7d16144 100644
--- a/src/LaTeXFeatures.cpp
+++ b/src/LaTeXFeatures.cpp
@@ -1072,6 +1072,8 @@ char const * simplefeatures[] = {
"varioref",
"prettyref",
"refstyle",
+ "zref-clever",
+ "zref-vario",
/*For a successful cooperation of the `wrapfig' package with the
`float' package you should load the `wrapfig' package *after*
the `float' package. See the caption package documentation
diff --git a/src/frontends/qt/GuiDocument.cpp b/src/frontends/qt/GuiDocument.cpp
index b39482f7a9..f3688a4a67 100644
--- a/src/frontends/qt/GuiDocument.cpp
+++ b/src/frontends/qt/GuiDocument.cpp
@@ -1675,6 +1675,7 @@ GuiDocument::GuiDocument(GuiView & lv)
latexModule->xrefPackageCO->addItem(qt_("Cleveref and varioref"),
toqstr("cleveref"));
latexModule->xrefPackageCO->addItem(qt_("Prettyref and varioref"),
toqstr("prettyref"));
latexModule->xrefPackageCO->addItem(qt_("Refstyle and varioref"),
toqstr("refstyle"));
+ latexModule->xrefPackageCO->addItem(qt_("Zref-clever and zref-vario"),
toqstr("zref"));
// postscript drivers
for (int n = 0; tex_graphics[n][0]; ++n) {
diff --git a/src/frontends/qt/GuiRef.cpp b/src/frontends/qt/GuiRef.cpp
index c4c5f486e0..78820cfdbf 100644
--- a/src/frontends/qt/GuiRef.cpp
+++ b/src/frontends/qt/GuiRef.cpp
@@ -109,6 +109,8 @@ GuiRef::GuiRef(GuiView & lv)
this, SLOT(changed_adaptor()));
connect(nolinkCB, SIGNAL(clicked()),
this, SLOT(changed_adaptor()));
+ connect(refOptionsLE, SIGNAL(textChanged(QString)),
+ this, SLOT(changed_adaptor()));
enableBoxes();
@@ -140,20 +142,25 @@ void GuiRef::enableBoxes()
typeCO->itemData(typeCO->currentIndex()).toString();
bool const use_refstyle = buffer().params().xref_package == "refstyle";
bool const use_cleveref = buffer().params().xref_package == "cleveref";
+ bool const use_zref = buffer().params().xref_package == "zref";
bool const isFormatted = (reftype == "formatted");
bool const isLabelOnly = (reftype == "labelonly");
bool const hyper_on = buffer().params().pdfoptions().use_hyperref;
bool const cleveref_nameref = use_cleveref && reftype == "nameref"
&& (!hyper_on || nolinkCB->isChecked());
+ bool const zref_clever = use_zref && (reftype == "vref" || reftype ==
"vpageref");
bool const allow_plural = use_refstyle || cleveref_nameref;
- bool const allow_caps = use_refstyle || use_cleveref;
- bool const allow_nohyper = !isLabelOnly && (!isFormatted ||
use_cleveref);
+ bool const allow_caps = use_refstyle || use_cleveref || use_zref;
+ bool const allow_nohyper = !isLabelOnly && (!isFormatted ||
use_cleveref || use_zref);
bool const intext = bufferview()->cursor().inTexted();
pluralCB->setEnabled(intext && (isFormatted || cleveref_nameref) &&
allow_plural);
- capsCB->setEnabled(intext && (isFormatted || cleveref_nameref) &&
allow_caps);
+ capsCB->setEnabled(intext && (isFormatted || cleveref_nameref ||
zref_clever) && allow_caps);
noprefixCB->setEnabled(intext && isLabelOnly);
// disabling of hyperlinks not supported by formatted references
nolinkCB->setEnabled(hyper_on && intext && allow_nohyper);
+ // options only supported by zref currently
+ refOptionsLE->setEnabled(use_zref && (isFormatted || zref_clever));
+ refOptionsLA->setEnabled(use_zref && (isFormatted || zref_clever));
}
@@ -348,6 +355,7 @@ void GuiRef::updateContents()
capsCB->setChecked(params_["caps"] == "true");
noprefixCB->setChecked(params_["noprefix"] == "true");
nolinkCB->setChecked(params_["nolink"] == "true");
+ refOptionsLE->setText(toqstr(params_["options"]));
// insert buffer list
bufferCO->clear();
@@ -392,6 +400,7 @@ void GuiRef::applyView()
from_ascii("true") : from_ascii("false");
params_["nolink"] = nolinkCB->isChecked() ?
from_ascii("true") : from_ascii("false");
+ params_["options"] = qstring_to_ucs4(refOptionsLE->text());
restored_buffer_ = bufferCO->currentIndex();
}
diff --git a/src/frontends/qt/ui/RefUi.ui b/src/frontends/qt/ui/RefUi.ui
index dac7d7f4b7..73d3241397 100644
--- a/src/frontends/qt/ui/RefUi.ui
+++ b/src/frontends/qt/ui/RefUi.ui
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>435</width>
- <height>539</height>
+ <height>592</height>
</rect>
</property>
<property name="windowTitle">
@@ -16,33 +16,7 @@
<property name="sizeGripEnabled">
<bool>true</bool>
</property>
- <layout class="QGridLayout" name="gridLayout_2">
- <item row="2" column="0">
- <widget class="QTreeWidget" name="refsTW">
- <property name="columnCount">
- <number>2</number>
- </property>
- <attribute name="headerDefaultSectionSize">
- <number>200</number>
- </attribute>
- <attribute name="headerStretchLastSection">
- <bool>true</bool>
- </attribute>
- <column>
- <property name="text">
- <string>Label</string>
- </property>
- </column>
- <column>
- <property name="text">
- <string>Reference counter value</string>
- </property>
- </column>
- </widget>
- </item>
- <item row="7" column="0">
- <layout class="QHBoxLayout" name="horizontalLayout_4"/>
- </item>
+ <layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
@@ -111,6 +85,39 @@
</item>
</layout>
</item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Available &Labels:</string>
+ </property>
+ <property name="buddy">
+ <cstring>refsTW</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QTreeWidget" name="refsTW">
+ <property name="columnCount">
+ <number>2</number>
+ </property>
+ <attribute name="headerDefaultSectionSize">
+ <number>200</number>
+ </attribute>
+ <attribute name="headerStretchLastSection">
+ <bool>true</bool>
+ </attribute>
+ <column>
+ <property name="text">
+ <string>Label</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Reference counter value</string>
+ </property>
+ </column>
+ </widget>
+ </item>
<item row="3" column="0">
<layout class="QHBoxLayout">
<property name="spacing">
@@ -170,16 +177,6 @@
</item>
</layout>
</item>
- <item row="1" column="0">
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Available &Labels:</string>
- </property>
- <property name="buddy">
- <cstring>refsTW</cstring>
- </property>
- </widget>
- </item>
<item row="4" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
@@ -290,7 +287,83 @@
</item>
</layout>
</item>
- <item row="8" column="0">
+ <item row="6" column="0">
+ <widget class="QGroupBox" name="refOptionsGB">
+ <property name="title">
+ <string>Options</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_2">
+ <item row="0" column="0" colspan="2">
+ <layout class="QHBoxLayout" name="horizontalLayout9">
+ <item>
+ <widget class="QCheckBox" name="pluralCB">
+ <property name="toolTip">
+ <string>Use plural form of formatted reference. (Works only for
formatted references, and only if you are using refstyle.)</string>
+ </property>
+ <property name="text">
+ <string>&Plural</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="capsCB">
+ <property name="toolTip">
+ <string>Use capitalized form of formatted reference. (Works only
for formatted references, and only if you are using refstyle.)</string>
+ </property>
+ <property name="text">
+ <string>&Capitalized</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="noprefixCB">
+ <property name="toolTip">
+ <string>Do not output part of label before ":"</string>
+ </property>
+ <property name="text">
+ <string>No Prefi&x</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="nolinkCB">
+ <property name="text">
+ <string>No H&yperlink</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="refOptionsLA">
+ <property name="text">
+ <string>&Custom:</string>
+ </property>
+ <property name="buddy">
+ <cstring>refOptionsLE</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLineEdit" name="refOptionsLE"/>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="7" column="0">
<layout class="QHBoxLayout">
<property name="spacing">
<number>6</number>
@@ -316,60 +389,6 @@
</item>
</layout>
</item>
- <item row="6" column="0">
- <layout class="QHBoxLayout" name="horizontalLayout9">
- <item>
- <widget class="QCheckBox" name="pluralCB">
- <property name="toolTip">
- <string>Use plural form of formatted reference. (Works only for
formatted references, and only if you are using refstyle.)</string>
- </property>
- <property name="text">
- <string>Plural</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QCheckBox" name="capsCB">
- <property name="toolTip">
- <string>Use capitalized form of formatted reference. (Works only for
formatted references, and only if you are using refstyle.)</string>
- </property>
- <property name="text">
- <string>Capitalized</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QCheckBox" name="noprefixCB">
- <property name="toolTip">
- <string>Do not output part of label before ":"</string>
- </property>
- <property name="text">
- <string>No Prefix</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QCheckBox" name="nolinkCB">
- <property name="text">
- <string>No Hyperlink</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="horizontalSpacer_2">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
</layout>
</widget>
<tabstops>
diff --git a/src/insets/InsetRef.cpp b/src/insets/InsetRef.cpp
index 9cd0ddabf6..3233be0c3f 100644
--- a/src/insets/InsetRef.cpp
+++ b/src/insets/InsetRef.cpp
@@ -78,6 +78,7 @@ ParamInfo const & InsetRef::findInfo(string const & /*
cmdName */)
param_info_.add("caps", ParamInfo::LYX_INTERNAL);
param_info_.add("noprefix", ParamInfo::LYX_INTERNAL);
param_info_.add("nolink", ParamInfo::LYX_INTERNAL);
+ param_info_.add("options", ParamInfo::LYX_INTERNAL);
}
return param_info_;
}
@@ -205,10 +206,16 @@ docstring InsetRef::getFormattedCmd(docstring const & ref,
docstring & label, docstring & prefix, string const xref_package,
bool use_caps)
{
- bool const use_cleveref = xref_package == "cleveref";
- docstring const crefcmd = use_caps ? from_ascii("\\Cref") :
from_ascii("\\cref");
- static docstring const defcmd = use_cleveref ? crefcmd :
from_ascii("\\ref");
- static docstring const prtcmd = use_cleveref ? crefcmd :
from_ascii("\\prettyref");
+ docstring defcmd = from_ascii("\\ref");
+ docstring prtcmd = from_ascii("\\prettyref");
+ if (xref_package == "cleveref") {
+ docstring const crefcmd = use_caps ? from_ascii("\\Cref") :
from_ascii("\\cref");
+ defcmd = crefcmd;
+ prtcmd = crefcmd;
+ } else if (xref_package == "zref") {
+ defcmd = from_ascii("\\zcref");
+ prtcmd = from_ascii("\\zcref");
+ }
label = split(ref, prefix, ':');
@@ -267,7 +274,10 @@ void InsetRef::latex(otexstream & os, OutputParams const &
rp) const
docstring const & data = getEscapedLabel(rp);
bool const hyper_on = buffer().masterParams().pdfoptions().use_hyperref;
bool const use_nolink = hyper_on && getParam("nolink") == "true";
+ bool const use_caps = getParam("caps") == "true";
+ bool const use_plural = getParam("plural") == "true";
bool const use_cleveref = buffer().masterParams().xref_package ==
"cleveref";
+ bool const use_zref = buffer().masterParams().xref_package == "zref";
if (rp.inulemcmd > 0)
os << "\\mbox{";
@@ -284,15 +294,23 @@ void InsetRef::latex(otexstream & os, OutputParams const
& rp) const
} else if (cmd == "formatted") {
docstring label;
docstring prefix;
- bool const use_caps = getParam("caps") == "true";
- bool const use_plural = getParam("plural") == "true";
docstring const fcmd =
getFormattedCmd(data, label, prefix,
buffer().masterParams().xref_package, use_caps);
os << fcmd;
- if (use_cleveref && use_nolink)
+ if ((use_cleveref || use_zref) && use_nolink)
os << "*";
if (buffer().masterParams().xref_package == "refstyle" &&
use_plural)
os << "[s]";
+ else if (use_zref) {
+ docstring opts = getParam("options");
+ if (use_caps) {
+ if (!opts.empty())
+ opts +=", ";
+ opts += "S";
+ }
+ if (!opts.empty())
+ os << "[" << opts << "]";
+ }
if (contains(label, ' '))
// refstyle bug: labels with blanks need to be grouped
// otherwise the blanks will be gobbled
@@ -300,8 +318,6 @@ void InsetRef::latex(otexstream & os, OutputParams const &
rp) const
else
os << '{' << label << '}';
} else if (cmd == "nameref" && use_cleveref && (use_nolink ||
!hyper_on)) {
- bool const use_caps = getParam("caps") == "true";
- bool const use_plural = getParam("plural") == "true";
docstring const crefcmd = use_caps ? from_ascii("Cref") :
from_ascii("cref");
os << "\\name" << crefcmd;
if (use_plural)
@@ -321,6 +337,19 @@ void InsetRef::latex(otexstream & os, OutputParams const &
rp) const
os << suffix;
}
}
+ } else if ((cmd == "vref" || cmd == "vpageref") && use_zref) {
+ os << "\\z" << cmd;
+ if (use_nolink)
+ os << "*";
+ docstring opts = getParam("options");
+ if (use_caps) {
+ if (!opts.empty())
+ opts +=", ";
+ opts += "S";
+ }
+ if (!opts.empty())
+ os << "[" << opts << "]";
+ os << '{' << data << '}';
} else {
InsetCommandParams p(REF_CODE, cmd);
bool const use_nolink = hyper_on && getParam("nolink") ==
"true";
@@ -609,9 +638,12 @@ void InsetRef::addToToc(DocIterator const & cpit, bool
output_active,
void InsetRef::validate(LaTeXFeatures & features) const
{
string const & cmd = getCmdName();
- if (cmd == "vref" || cmd == "vpageref")
- features.require("varioref");
- else if (cmd == "formatted") {
+ if (cmd == "vref" || cmd == "vpageref") {
+ if (buffer().masterParams().xref_package == "zref")
+ features.require("zref-vario");
+ else
+ features.require("varioref");
+ } else if (cmd == "formatted") {
docstring const data = getEscapedLabel(features.runparams());
docstring label;
docstring prefix;
@@ -629,6 +661,8 @@ void InsetRef::validate(LaTeXFeatures & features) const
}
} else if (buffer().masterParams().xref_package == "cleveref") {
features.require("cleveref");
+ } else if (buffer().masterParams().xref_package == "zref") {
+ features.require("zref-clever");
} else {
features.require("prettyref");
// prettyref uses "cha" for chapters, so we provide a
kind of
--
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs