commit a66660da7799588b2d921ef4955c3cfe5aaf7907 Author: Juergen Spitzmueller <sp...@lyx.org> Date: Sat Mar 22 12:06:51 2025 +0100
Rename buffer param \use_refstyle to \crossref_package that takes a string ("prettyref" or "refstyle") rather than a boolean value. This is in preparation for additional options. --- development/FORMAT | 5 + lib/doc/UserGuide.lyx | 132 ++++++++++++++++- lib/doc/de/UserGuide.lyx | 309 +++++++++++++++++++++++---------------- lib/lyx2lyx/lyx_2_5.py | 28 +++- src/BufferParams.cpp | 8 +- src/BufferParams.h | 4 +- src/frontends/qt/GuiDocument.cpp | 11 +- src/frontends/qt/GuiRef.cpp | 2 +- src/frontends/qt/ui/LaTeXUi.ui | 267 ++++++++++++++++++--------------- src/insets/InsetRef.cpp | 16 +- src/mathed/InsetMathRef.cpp | 4 +- src/tex2lyx/Preamble.cpp | 10 +- src/tex2lyx/Preamble.h | 4 +- src/tex2lyx/text.cpp | 6 +- src/version.h | 4 +- 15 files changed, 530 insertions(+), 280 deletions(-) diff --git a/development/FORMAT b/development/FORMAT index 0285b0b946..0bbfc014b0 100644 --- a/development/FORMAT +++ b/development/FORMAT @@ -7,6 +7,11 @@ changes happened in particular if possible. A good example would be ----------------------- +2025-03-22 Jürgen Spitzmüller <sp...@lyx.org> + * Format incremented to 635: Rename buffer param \use_refstyle to \crossref_package + that takes a string ("prettyref" or "refstyle") rather than a boolean value. + This is in preparation for additional options. + 2025-02-28 Jürgen Spitzmüller <sp...@lyx.org> * Format incremented to 634: Support for colortbl 1. New buffer parmams: diff --git a/lib/doc/UserGuide.lyx b/lib/doc/UserGuide.lyx index cae05b1675..0656266e6c 100644 --- a/lib/doc/UserGuide.lyx +++ b/lib/doc/UserGuide.lyx @@ -1,5 +1,5 @@ #LyX 2.5 created this file. For more info see https://www.lyx.org/ -\lyxformat 634 +\lyxformat 635 \begin_document \begin_header \save_transient_properties true @@ -117,7 +117,7 @@ logicalmkup \paperorientation portrait \suppress_date false \justification true -\use_refstyle 1 +\crossref_package prettyref \use_formatted_ref 0 \use_minted 0 \use_lineno 0 @@ -51121,10 +51121,134 @@ Embedded Objects \emph default manual. +\change_inserted -712698321 1742640894 + +\end_layout + +\begin_layout Standard + +\change_inserted -712698321 1742641130 +In the +\family sans +Formatted cross-references +\family default + section, + you can specify which \SpecialChar LaTeX + packages should be used to produce formatted cross-references (e. +\begin_inset space \thinspace{} +\end_inset + +g, + +\series bold +refstyle, + +\series default + +\series bold +prettyref, + varioref +\series default + +\begin_inset Index idx +range none +pageformat default +status collapsed + +\begin_layout Plain Layout + +\change_inserted -712698321 1742640894 +\SpecialChar LaTeX + packages +\begin_inset IndexMacro subentry +status open + +\begin_layout Plain Layout + +\change_inserted -712698321 1742640894 +prettyref +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Index idx +range none +pageformat default +status collapsed + +\begin_layout Plain Layout + +\change_inserted -712698321 1742640894 +\SpecialChar LaTeX + packages +\begin_inset IndexMacro subentry +status open + +\begin_layout Plain Layout + +\change_inserted -712698321 1742640894 +refstyle +\end_layout + +\end_inset + + +\end_layout + +\end_inset + +; + see section +\begin_inset space ~ +\end_inset + + +\begin_inset CommandInset ref +LatexCommand ref +reference "sec:Cross-References" +nolink "false" + +\end_inset + +). + Also you can select whether cross-references should be rendered in formatted form or not in the \SpecialChar LyX + workarea. +\change_unchanged + \end_layout \begin_layout Standard -There is also an option to suppress the date and one to use the \SpecialChar LaTeX + +\change_inserted -712698321 1742641143 +Finally, + +\change_deleted -712698321 1742641143 +T +\change_inserted -712698321 1742641143 +t +\change_unchanged +here is +\change_deleted -712698321 1742641151 +also +\change_unchanged +an option to suppress the +\change_inserted -712698321 1742641171 +(otherwise automatically inserted) +\change_unchanged +date +\change_inserted -712698321 1742641157 + in the title. + +\change_unchanged + +\change_deleted -712698321 1742640892 +and one to use the \SpecialChar LaTeX -package \series bold refstyle @@ -51193,6 +51317,8 @@ nolink "false" \end_inset . +\change_unchanged + \end_layout \begin_layout Section diff --git a/lib/doc/de/UserGuide.lyx b/lib/doc/de/UserGuide.lyx index 650dee1183..fb95319d28 100644 --- a/lib/doc/de/UserGuide.lyx +++ b/lib/doc/de/UserGuide.lyx @@ -1,5 +1,5 @@ -#LyX 2.4 created this file. For more info see https://www.lyx.org/ -\lyxformat 620 +#LyX 2.5 created this file. For more info see https://www.lyx.org/ +\lyxformat 635 \begin_document \begin_header \save_transient_properties true @@ -124,11 +124,19 @@ logicalmkup \paperorientation portrait \suppress_date false \justification true -\use_refstyle 1 +\crossref_package prettyref \use_formatted_ref 0 \use_minted 0 \use_lineno 0 -\notefontcolor #0000ff +\customcolor lyxnotefontcolor 0000ff +\backgroundcolor none +\fontcolor none +\notefontcolor lyxnotefontcolor +\boxbgcolor red +\table_border_color default +\table_odd_row_color default +\table_even_row_color default +\table_alt_row_colors_start 1 \branch Frage \selected 1 \filename_suffix 0 @@ -164,6 +172,7 @@ logicalmkup \html_be_strict false \docbook_table_output 0 \docbook_mathml_prefix 1 +\docbook_mathml_version 0 \end_header \begin_body @@ -3116,11 +3125,22 @@ Runter Tabulator \family default -\begin_inset CommandInset nomenclature -LatexCommand nomenclature -symbol "Tab" -description "Tabulator key" -literal "false" +\begin_inset Nomenclature +status open + +\begin_layout Plain Layout +Tab +\begin_inset Argument post:1 +status open + +\begin_layout Plain Layout +Tabulator key +\end_layout + +\end_inset + + +\end_layout \end_inset @@ -3187,11 +3207,22 @@ In \SpecialChar LyX Esc \family default -\begin_inset CommandInset nomenclature -LatexCommand nomenclature -symbol "Esc" -description "Escape key" -literal "false" +\begin_inset Nomenclature +status open + +\begin_layout Plain Layout +Esc +\begin_inset Argument post:1 +status open + +\begin_layout Plain Layout +Escape key +\end_layout + +\end_inset + + +\end_layout \end_inset @@ -3242,11 +3273,22 @@ Strg \end_inset -\begin_inset CommandInset nomenclature -LatexCommand nomenclature -symbol "Strg" -description "Steuerung-Taste" -literal "false" +\begin_inset Nomenclature +status open + +\begin_layout Plain Layout +Strg +\begin_inset Argument post:1 +status open + +\begin_layout Plain Layout +Steuerung-Taste +\end_layout + +\end_inset + + +\end_layout \end_inset @@ -3315,11 +3357,22 @@ Umschalt \end_inset -\begin_inset CommandInset nomenclature -LatexCommand nomenclature -symbol "Umschalt" -description "Umschalt-Taste" -literal "false" +\begin_inset Nomenclature +status open + +\begin_layout Plain Layout +Umschalt +\begin_inset Argument post:1 +status open + +\begin_layout Plain Layout +Umschalt-Taste +\end_layout + +\end_inset + + +\end_layout \end_inset @@ -3334,11 +3387,22 @@ literal "false" Alt \family default (in der Dokumentation als „Alt“ -\begin_inset CommandInset nomenclature -LatexCommand nomenclature -symbol "Alt" -description "Alt oder Meta-Taste" -literal "false" +\begin_inset Nomenclature +status open + +\begin_layout Plain Layout +Alt +\begin_inset Argument post:1 +status open + +\begin_layout Plain Layout +Alt oder Meta-Taste +\end_layout + +\end_inset + + +\end_layout \end_inset @@ -3714,7 +3778,6 @@ Broadway Layout zum Schreiben von Theaterstücken. status open \begin_layout Plain Layout - "= \end_layout @@ -3772,7 +3835,6 @@ Hollywood für spezielle Filmskripte der US-Filmindustrie. status collapsed \begin_layout Plain Layout - "= \end_layout @@ -8909,7 +8971,6 @@ nolink "false" status collapsed \begin_layout Plain Layout - "= \end_layout @@ -19160,7 +19221,6 @@ status collapsed \begin_layout Plain Layout - \backslash nobreakdash \end_layout @@ -19569,7 +19629,6 @@ nolink "false" status collapsed \begin_layout Plain Layout - \begin_inset Quotes gld \end_inset @@ -20059,7 +20118,6 @@ status collapsed status collapsed \begin_layout Plain Layout - "= \end_layout @@ -22543,7 +22601,6 @@ literal "false" status collapsed \begin_layout Plain Layout - "= \end_layout @@ -31310,7 +31367,6 @@ URL status open \begin_layout Plain Layout - https://www.lyx.org \end_layout @@ -32045,10 +32101,7 @@ literal "false" status open \begin_layout Plain Layout - -https://de.wikipedia.org/wiki/American_Standard_Code_for_Information_Interchange -\backslash -#ASCII-Tabelle +https://de.wikipedia.org/wiki/American_Standard_Code_for_Information_Interchange#ASCII-Tabelle \end_layout \end_inset @@ -32410,7 +32463,6 @@ literal "true" status collapsed \begin_layout Plain Layout - https://wiki.lyx.org/BibTeX/Programs \end_layout @@ -34929,7 +34981,6 @@ Modul \end_layout \begin_layout Verbatim - (markup-locref :open " \backslash IndexDef{" :close "}" :attr "IndexDef") @@ -35006,7 +35057,6 @@ literal "true" status collapsed \begin_layout Plain Layout - https://www.ctan.org/topic/index \end_layout @@ -35047,7 +35097,6 @@ status collapsed \begin_layout Plain Layout - \backslash - \end_layout @@ -35060,7 +35109,6 @@ status collapsed \begin_layout Plain Layout - \backslash - \end_layout @@ -35073,7 +35121,6 @@ status collapsed \begin_layout Plain Layout - \backslash - \end_layout @@ -35086,7 +35133,6 @@ status collapsed \begin_layout Plain Layout - \backslash - \end_layout @@ -35972,11 +36018,22 @@ Nehmen wir an, Sie hätten zwei Nomenklatureinträge für die Symbole \emph on a -\begin_inset CommandInset nomenclature -LatexCommand nomenclature -symbol "a" -description "Sinnsloseintrag für das Zeichen ,,a``" -literal "false" +\begin_inset Nomenclature +status open + +\begin_layout Plain Layout +a +\begin_inset Argument post:1 +status open + +\begin_layout Plain Layout +Sinnsloseintrag für das Zeichen ,,a`` +\end_layout + +\end_inset + + +\end_layout \end_inset @@ -35987,12 +36044,56 @@ literal "false" \end_inset -\begin_inset CommandInset nomenclature -LatexCommand nomenclature -prefix "sigma" -symbol "$\\sigma$" -description "Sinnsloseintrag für das Zeichen \\textsf{sigma}" -literal "true" +\begin_inset Nomenclature +status open + +\begin_layout Plain Layout +\begin_inset Argument 1 +status open + +\begin_layout Plain Layout +sigma +\end_layout + +\end_inset + + +\begin_inset ERT +status collapsed + +\begin_layout Plain Layout +$ +\backslash +sigma$ +\end_layout + +\end_inset + + +\begin_inset Argument post:1 +status open + +\begin_layout Plain Layout +\begin_inset ERT +status collapsed + +\begin_layout Plain Layout +Sinnsloseintrag f +\backslash +"{u}r das Zeichen +\backslash +textsf{sigma} +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + +\end_layout \end_inset @@ -37023,7 +37124,6 @@ status open \begin_layout Plain Layout - \backslash newcommand{ \backslash @@ -37032,7 +37132,6 @@ Frage}[1]{#1} \begin_layout Plain Layout - \backslash newcommand{ \backslash @@ -37060,7 +37159,6 @@ status open \begin_layout Plain Layout - \backslash newcommand{ \backslash @@ -37069,7 +37167,6 @@ Frage}[1]{} \begin_layout Plain Layout - \backslash newcommand{ \backslash @@ -37728,7 +37825,6 @@ status collapsed \begin_layout Plain Layout - \backslash fbox{ \end_layout @@ -37740,7 +37836,6 @@ eingerahmten status collapsed \begin_layout Plain Layout - } \end_layout @@ -38022,7 +38117,6 @@ status collapsed \begin_layout Plain Layout - \backslash pagestyle{fancy} \end_layout @@ -38058,7 +38152,6 @@ status collapsed \begin_layout Plain Layout - \backslash rightmark \end_layout @@ -38101,7 +38194,6 @@ status collapsed \begin_layout Plain Layout - \backslash leftmark \end_layout @@ -38126,7 +38218,6 @@ status collapsed \begin_layout Plain Layout - \backslash thepage \end_layout @@ -38183,7 +38274,6 @@ status collapsed \begin_layout Plain Layout - \backslash Roman{page} \end_layout @@ -39013,7 +39103,6 @@ status open \begin_layout Plain Layout - \backslash pagestyle{headings} \end_layout @@ -39354,7 +39443,6 @@ status collapsed \begin_layout Plain Layout - \backslash rotatebox[origin=r]{-60}{ \end_layout @@ -39391,7 +39479,6 @@ mit rotiertem status collapsed \begin_layout Plain Layout - } \end_layout @@ -39404,7 +39491,6 @@ status collapsed \begin_layout Plain Layout - \backslash rotatebox[origin=lb]{60}{ \end_layout @@ -39420,7 +39506,6 @@ rotatebox[origin=lb]{60}{ status collapsed \begin_layout Plain Layout - } \end_layout @@ -39484,7 +39569,6 @@ status collapsed \begin_layout Plain Layout - \backslash fboxrule 1mm \backslash @@ -39499,7 +39583,6 @@ status collapsed \begin_layout Plain Layout - \backslash fcolorbox{cyan}{magenta}{ \end_layout @@ -39512,7 +39595,6 @@ Dies ist Text in einer farbigen, status collapsed \begin_layout Plain Layout - } \end_layout @@ -40345,7 +40427,6 @@ Alle von \SpecialChar LyX status open \begin_layout Plain Layout - https://www.lyx.org/trac/export/HEAD/dictionaries/dicts/ \end_layout @@ -40710,7 +40791,6 @@ LibreOffice-<Version> status collapsed \begin_layout Plain Layout - "" \end_layout @@ -40754,7 +40834,6 @@ weitere Wörterbücher installieren möchten, status open \begin_layout Plain Layout - https://www.lyx.org/trac/browser/dictionaries/thes/ \end_layout @@ -46331,7 +46410,6 @@ status collapsed \begin_layout Plain Layout - \backslash setlength{ \backslash @@ -48625,16 +48703,22 @@ Objekte \end_layout \begin_layout Standard -Es gibt zudem noch eine Option, - um die Ausgabe des Datums zu unterdrücken und eine weitere, - um das \SpecialChar LaTeX --Paket +Im Abschnitt +\family sans +Formattierte Querverweise +\family default + können Sie auswählen, + welche \SpecialChar LaTeX +-Pakete zur Erstellung formatierter Querverweise verwendet werden (bspw. + \series bold -refstyle +refstyle, + \series default - anstelle von + \series bold -prettyref +prettyref, + varioref \series default \begin_inset Index idx @@ -48682,7 +48766,7 @@ refstyle \end_inset - für Querverweise zu verwenden, +; siehe Abschnitt \begin_inset space ~ \end_inset @@ -48695,7 +48779,15 @@ nolink "false" \end_inset -. +). + Außerdem können Sie festlegen, + ob formatierte Querverweise auch im \SpecialChar LyX +-Arbeitsbereich formattiert dargestellt werden sollen oder nicht. +\end_layout + +\begin_layout Standard +Schließlich gibt es noch die Möglichkeit, + die Ausgabe des (ansonsten automatisch eingefügten) Datums im Titel zu unterdrücken. \end_layout \begin_layout Section @@ -54348,10 +54440,7 @@ dvips status collapsed \begin_layout Plain Layout - -https://www.tug.org/texinfohtml/dvips.html -\backslash -#Option-details +https://www.tug.org/texinfohtml/dvips.html#Option-details \end_layout \end_inset @@ -55659,7 +55748,6 @@ literal "false" status collapsed \begin_layout Plain Layout - https://www.lyx.org/Credits \end_layout @@ -55798,7 +55886,6 @@ Der \SpecialChar TeX status collapsed \begin_layout Plain Layout - https://www.ctan.org/topic \end_layout @@ -55825,7 +55912,6 @@ The \SpecialChar LaTeX status collapsed \begin_layout Plain Layout - https://texfaq.org/ \end_layout @@ -55865,7 +55951,6 @@ Bib\SpecialChar TeX status collapsed \begin_layout Plain Layout - https://mirrors.ctan.org/biblio/bibtex/contrib/doc/btxdoc.pdf \end_layout @@ -55905,7 +55990,6 @@ Bib\SpecialChar TeX status collapsed \begin_layout Plain Layout - https://mirrors.ctan.org/info/bibtex/tamethebeast/ttb_en.pdf \end_layout @@ -55968,7 +56052,6 @@ biblatex status collapsed \begin_layout Plain Layout - https://mirrors.ctan.org/macros/latex/contrib/biblatex/doc/biblatex.pdf \end_layout @@ -56031,7 +56114,6 @@ biber status collapsed \begin_layout Plain Layout - https://mirrors.ctan.org/biblio/biber/base/documentation/biber.pdf \end_layout @@ -56070,7 +56152,6 @@ makeindex status collapsed \begin_layout Plain Layout - https://mirrors.ctan.org/indexing/makeindex/doc/makeindex.pdf \end_layout @@ -56109,7 +56190,6 @@ makeindex status collapsed \begin_layout Plain Layout - https://mirrors.ctan.org/indexing/makeindex/doc/manpages.dvi \end_layout @@ -56148,7 +56228,6 @@ xindex status collapsed \begin_layout Plain Layout - https://mirrors.ctan.org/indexing/xindex/doc/xindex-doc.pdf \end_layout @@ -56187,7 +56266,6 @@ xindy status collapsed \begin_layout Plain Layout - http://www.xindy.org/documentation.html \end_layout @@ -56223,7 +56301,6 @@ literal "false" status collapsed \begin_layout Plain Layout - https://www.ams.org/publications/authors/tex/amslatex \end_layout @@ -56286,7 +56363,6 @@ caption status collapsed \begin_layout Plain Layout - https://mirrors.ctan.org/macros/latex/contrib/caption/caption.pdf \end_layout @@ -56349,7 +56425,6 @@ enumitem status collapsed \begin_layout Plain Layout - https://mirrors.ctan.org/macros/latex/contrib/enumitem/enumitem.pdf \end_layout @@ -56412,7 +56487,6 @@ fancyhdr status collapsed \begin_layout Plain Layout - https://mirrors.ctan.org/macros/latex/contrib/fancyhdr/fancyhdr.pdf \end_layout @@ -56475,7 +56549,6 @@ hyperref status collapsed \begin_layout Plain Layout - https://mirrors.ctan.org/macros/latex/contrib/hyperref/doc/hyperref-doc.pdf \end_layout @@ -56538,7 +56611,6 @@ microtype status collapsed \begin_layout Plain Layout - https://mirrors.ctan.org/macros/latex/contrib/microtype/microtype.pdf \end_layout @@ -56601,7 +56673,6 @@ nomencl status collapsed \begin_layout Plain Layout - https://mirrors.ctan.org/macros/latex/contrib/nomencl/nomencl.pdf \end_layout @@ -56664,7 +56735,6 @@ prettyref status collapsed \begin_layout Plain Layout - https://mirrors.ctan.org/macros/latex/contrib/prettyref/prettyref.pdf \end_layout @@ -56727,7 +56797,6 @@ refstyle status collapsed \begin_layout Plain Layout - https://mirrors.ctan.org/macros/latex/contrib/refstyle/refstyle.pdf \end_layout @@ -56763,7 +56832,6 @@ literal "false" status collapsed \begin_layout Plain Layout - https://wiki.lyx.org/Windows/Arabic \end_layout @@ -56799,7 +56867,6 @@ literal "false" status collapsed \begin_layout Plain Layout - https://wiki.lyx.org/Windows/Armenian \end_layout @@ -56835,7 +56902,6 @@ literal "false" status collapsed \begin_layout Plain Layout - https://wiki.lyx.org/Windows/Cyrillic \end_layout @@ -56871,7 +56937,6 @@ literal "false" status collapsed \begin_layout Plain Layout - https://wiki.lyx.org/Windows/Farsi \end_layout @@ -56907,7 +56972,6 @@ literal "false" status collapsed \begin_layout Plain Layout - https://wiki.lyx.org/Windows/Hebrew \end_layout @@ -56943,7 +57007,6 @@ literal "false" status collapsed \begin_layout Plain Layout - https://wiki.lyx.org/Windows/Japanese \end_layout @@ -56965,7 +57028,6 @@ status collapsed \begin_layout Plain Layout - \backslash let \backslash @@ -56976,7 +57038,6 @@ bibname \begin_layout Plain Layout - \backslash renewcommand{ \backslash @@ -57035,7 +57096,6 @@ status collapsed \begin_layout Plain Layout - \backslash renewcommand*{ \backslash @@ -57043,7 +57103,6 @@ pagedeclaration}[1]{ \end_layout \begin_layout Plain Layout - \backslash unskip, diff --git a/lib/lyx2lyx/lyx_2_5.py b/lib/lyx2lyx/lyx_2_5.py index 6b94ae0875..f0d3f6801d 100644 --- a/lib/lyx2lyx/lyx_2_5.py +++ b/lib/lyx2lyx/lyx_2_5.py @@ -2500,6 +2500,30 @@ def revert_colortbl(document): add_to_preamble(document, preamble) +def convert_crossref_package(document): + "Converts \\use_refstyle to \\crossref_package" + + i = find_token(document.header, "\\use_refstyle", 0) + if i != -1: + value = get_value(document.header, "\\use_refstyle", i) + if value == 1: + document.header[i] = "\\crossref_package refstyle" + else: + document.header[i] = "\\crossref_package prettyref" + + +def revert_crossref_package(document): + "Reverts \\crossref_package to \\use_refstyle" + + i = find_token(document.header, "\\crossref_package", 0) + if i != -1: + value = get_value(document.header, "\\crossref_package", i) + if value == "prettyref": + document.header[i] = "\\use_refstyle 0" + else: + document.header[i] = "\\use_refstyle 1" + + ## # Conversion hub # @@ -2519,11 +2543,13 @@ convert = [ [631, [convert_mathml_version]], [632, []], [633, [convert_doc_colors]], - [634, []] + [634, []], + [635, [convert_crossref_package]] ] revert = [ + [634, [revert_crossref_package]], [633, [revert_colortbl]], [632, [revert_doc_colors, revert_colorbox]], [631, [revert_textcolor, revert_custom_colors]], diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index 09d5a1a7b4..d083a31dbb 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -490,7 +490,7 @@ BufferParams::BufferParams() shell_escape = false; output_sync = false; - use_refstyle = true; + xref_package = "refstyle"; use_formatted_ref = false; use_minted = false; use_lineno = false; @@ -1512,8 +1512,8 @@ string BufferParams::readToken(Lexer & lex, string const & token, lex >> output_sync_macro; break; } - if (token == "\\use_refstyle") { - lex >> use_refstyle; + if (token == "\\crossref_package") { + lex >> xref_package; break; } if (token == "\\use_formatted_ref") { @@ -1768,7 +1768,7 @@ void BufferParams::writeFile(ostream & os, Buffer const * buf) const << "\n\\paperorientation " << string_orientation[orientation] << "\n\\suppress_date " << convert<string>(suppress_date) << "\n\\justification " << convert<string>(justification) - << "\n\\use_refstyle " << use_refstyle + << "\n\\crossref_package " << xref_package << "\n\\use_formatted_ref " << use_formatted_ref << "\n\\use_minted " << use_minted << "\n\\use_lineno " << use_lineno diff --git a/src/BufferParams.h b/src/BufferParams.h index 75df5da350..ee98e49957 100644 --- a/src/BufferParams.h +++ b/src/BufferParams.h @@ -641,8 +641,8 @@ public: bool output_sync; /// custom LaTeX macro from user instead our own std::string output_sync_macro; - /// use refstyle? or prettyref? - bool use_refstyle; + /// crossref package + std::string xref_package; /// use formatted references in the workarea? bool use_formatted_ref; /// use minted? or listings? diff --git a/src/frontends/qt/GuiDocument.cpp b/src/frontends/qt/GuiDocument.cpp index e129637447..b5d9bac16d 100644 --- a/src/frontends/qt/GuiDocument.cpp +++ b/src/frontends/qt/GuiDocument.cpp @@ -1662,7 +1662,7 @@ GuiDocument::GuiDocument(GuiView & lv) this, SLOT(browseMaster())); connect(latexModule->suppressDateCB, SIGNAL(clicked()), this, SLOT(change_adaptor())); - connect(latexModule->refstyleCB, SIGNAL(clicked()), + connect(latexModule->xrefPackageCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); connect(latexModule->refFormattedCB, SIGNAL(clicked()), this, SLOT(change_adaptor())); @@ -1672,6 +1672,9 @@ GuiDocument::GuiDocument(GuiView & lv) latexModule->childDocLE->setValidator(new NoNewLineValidator( latexModule->childDocLE)); + latexModule->xrefPackageCO->addItem(qt_("Prettyref and varioref"), toqstr("prettyref")); + latexModule->xrefPackageCO->addItem(qt_("Refstyle and varioref"), toqstr("refstyle")); + // postscript drivers for (int n = 0; tex_graphics[n][0]; ++n) { QString enc = qt_(tex_graphics_gui[n]); @@ -3612,7 +3615,8 @@ void GuiDocument::applyView() // date bp_.suppress_date = latexModule->suppressDateCB->isChecked(); - bp_.use_refstyle = latexModule->refstyleCB->isChecked(); + bp_.xref_package = fromqstr(latexModule->xrefPackageCO->itemData( + latexModule->xrefPackageCO->currentIndex()).toString()); bp_.use_formatted_ref = latexModule->refFormattedCB->isChecked(); // biblio @@ -4161,7 +4165,8 @@ void GuiDocument::paramsToDialog() // date latexModule->suppressDateCB->setChecked(bp_.suppress_date); - latexModule->refstyleCB->setChecked(bp_.use_refstyle); + latexModule->xrefPackageCO->setCurrentIndex( + latexModule->xrefPackageCO->findData(toqstr(bp_.xref_package))); latexModule->refFormattedCB->setChecked(bp_.use_formatted_ref); // biblio diff --git a/src/frontends/qt/GuiRef.cpp b/src/frontends/qt/GuiRef.cpp index 6a2446a5a6..9b52733224 100644 --- a/src/frontends/qt/GuiRef.cpp +++ b/src/frontends/qt/GuiRef.cpp @@ -140,7 +140,7 @@ void GuiRef::enableBoxes() typeCO->itemData(typeCO->currentIndex()).toString(); bool const isFormatted = (reftype == "formatted"); bool const isLabelOnly = (reftype == "labelonly"); - bool const usingRefStyle = buffer().params().use_refstyle; + bool const usingRefStyle = buffer().params().xref_package == "refstyle"; bool const intext = bufferview()->cursor().inTexted(); bool const hyper_on = buffer().params().pdfoptions().use_hyperref; pluralCB->setEnabled(intext && isFormatted && usingRefStyle); diff --git a/src/frontends/qt/ui/LaTeXUi.ui b/src/frontends/qt/ui/LaTeXUi.ui index c45475edb8..1e1dbd717d 100644 --- a/src/frontends/qt/ui/LaTeXUi.ui +++ b/src/frontends/qt/ui/LaTeXUi.ui @@ -6,84 +6,15 @@ <rect> <x>0</x> <y>0</y> - <width>446</width> - <height>431</height> + <width>550</width> + <height>522</height> </rect> </property> <property name="windowTitle"> <string/> </property> <layout class="QGridLayout" name="gridLayout_2"> - <item row="2" column="0"> - <widget class="QLabel" name="psdriverL"> - <property name="text"> - <string>&Graphics driver:</string> - </property> - <property name="buddy"> - <cstring>psdriverCO</cstring> - </property> - </widget> - </item> - <item row="2" column="2"> - <widget class="QComboBox" name="psdriverCO"> - <property name="inputMethodHints"> - <set>Qt::ImhDigitsOnly|Qt::ImhLatinOnly</set> - </property> - <property name="duplicatesEnabled"> - <bool>false</bool> - </property> - </widget> - </item> - <item row="5" column="0" colspan="4"> - <widget class="QCheckBox" name="refstyleCB"> - <property name="text"> - <string>&Use refstyle (not prettyref) for cross-references</string> - </property> - </widget> - </item> - <item row="7" column="1"> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>2</height> - </size> - </property> - </spacer> - </item> - <item row="4" column="0" colspan="4"> - <widget class="QCheckBox" name="suppressDateCB"> - <property name="enabled"> - <bool>true</bool> - </property> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>&Suppress default date on front page</string> - </property> - </widget> - </item> - <item row="2" column="3"> - <spacer name="horizontalSpacer_1"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>261</width> - <height>22</height> - </size> - </property> - </spacer> - </item> - <item row="0" column="0" colspan="4"> + <item row="0" column="0" colspan="3"> <widget class="QGroupBox" name="groupBox"> <property name="title"> <string>Document &Class</string> @@ -121,7 +52,92 @@ </layout> </widget> </item> - <item row="3" column="0" colspan="4"> + <item row="1" column="0" colspan="3"> + <widget class="QGroupBox" name="optionsGB"> + <property name="title"> + <string>Class Options</string> + </property> + <property name="flat"> + <bool>true</bool> + </property> + <layout class="QGridLayout" name="gridLayout_1"> + <item row="0" column="0"> + <widget class="QCheckBox" name="defaultOptionsCB"> + <property name="toolTip"> + <string>Enable to use the options that are predefined in the layout file</string> + </property> + <property name="text"> + <string>&Predefined:</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLineEdit" name="defaultOptionsLE"> + <property name="toolTip"> + <string>The options that are predefined in the layout file. Click to the left to select/deselect.</string> + </property> + <property name="inputMethodHints"> + <set>Qt::ImhPreferLatin</set> + </property> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="optionsL"> + <property name="text"> + <string>Cus&tom:</string> + </property> + <property name="buddy"> + <cstring>optionsLE</cstring> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLineEdit" name="optionsLE"> + <property name="inputMethodHints"> + <set>Qt::ImhPreferLatin</set> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="psdriverL"> + <property name="text"> + <string>&Graphics driver:</string> + </property> + <property name="buddy"> + <cstring>psdriverCO</cstring> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QComboBox" name="psdriverCO"> + <property name="inputMethodHints"> + <set>Qt::ImhDigitsOnly|Qt::ImhLatinOnly</set> + </property> + <property name="duplicatesEnabled"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="2" column="2"> + <spacer name="horizontalSpacer_1"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>261</width> + <height>22</height> + </size> + </property> + </spacer> + </item> + <item row="3" column="0" colspan="3"> <widget class="QGroupBox" name="childDocGB"> <property name="toolTip"> <string>Select if the current document is included to a master file</string> @@ -166,68 +182,84 @@ </layout> </widget> </item> - <item row="1" column="0" colspan="4"> - <widget class="QGroupBox" name="optionsGB"> + <item row="4" column="0" colspan="3"> + <widget class="QGroupBox" name="xrefGB"> <property name="title"> - <string>Class Options</string> + <string>Formatted cross-references</string> </property> - <property name="flat"> - <bool>true</bool> - </property> - <layout class="QGridLayout" name="gridLayout_1"> + <layout class="QGridLayout" name="gridLayout_3"> <item row="0" column="0"> - <widget class="QCheckBox" name="defaultOptionsCB"> - <property name="toolTip"> - <string>Enable to use the options that are predefined in the layout file</string> - </property> - <property name="text"> - <string>&Predefined:</string> - </property> - </widget> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QLabel" name="xrefPackageLA"> + <property name="text"> + <string>&Format packages:</string> + </property> + <property name="buddy"> + <cstring>xrefPackageCO</cstring> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="xrefPackageCO"/> + </item> + <item> + <spacer name="horizontalSpacer"> + <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="0" column="1"> - <widget class="QLineEdit" name="defaultOptionsLE"> + <item row="1" column="0"> + <widget class="QCheckBox" name="refFormattedCB"> <property name="toolTip"> - <string>The options that are predefined in the layout file. Click to the left to select/deselect.</string> - </property> - <property name="inputMethodHints"> - <set>Qt::ImhPreferLatin</set> - </property> - <property name="readOnly"> - <bool>true</bool> + <string>Attempt to display formatted cross-references as they would appear in the output, e.g., as "Theorem 1" rather than just as the label.</string> </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="optionsL"> <property name="text"> - <string>Cus&tom:</string> - </property> - <property name="buddy"> - <cstring>optionsLE</cstring> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QLineEdit" name="optionsLE"> - <property name="inputMethodHints"> - <set>Qt::ImhPreferLatin</set> + <string>Format cross-references in the &work area</string> </property> </widget> </item> </layout> </widget> </item> - <item row="6" column="0" colspan="4"> - <widget class="QCheckBox" name="refFormattedCB"> - <property name="toolTip"> - <string>Attempt to display formatted cross-references as they would appear in the output, e.g., as "Theorem 1" rather than just as the label.</string> + <item row="5" column="0" colspan="2"> + <widget class="QCheckBox" name="suppressDateCB"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> </property> <property name="text"> - <string>Format cross-references in the &work area</string> + <string>&Suppress default date on front page</string> </property> </widget> </item> + <item row="6" column="0"> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>2</height> + </size> + </property> + </spacer> + </item> </layout> </widget> <customwidgets> @@ -248,7 +280,6 @@ <tabstop>childDocLE</tabstop> <tabstop>childDocPB</tabstop> <tabstop>suppressDateCB</tabstop> - <tabstop>refstyleCB</tabstop> </tabstops> <includes> <include location="local">qt_i18n.h</include> diff --git a/src/insets/InsetRef.cpp b/src/insets/InsetRef.cpp index 0486e509d5..8588c1e051 100644 --- a/src/insets/InsetRef.cpp +++ b/src/insets/InsetRef.cpp @@ -164,7 +164,7 @@ bool InsetRef::getStatus(Cursor & cur, FuncRequest const & cmd, else if (arg == "toggle-caps") pstring = "caps"; if (!pstring.empty()) { - status.setEnabled(buffer().params().use_refstyle && + status.setEnabled(buffer().params().xref_package == "refstyle" && params().getCmdName() == "formatted"); bool const isSet = (getParam(pstring) == "true"); status.setOnOff(isSet); @@ -267,7 +267,7 @@ void InsetRef::latex(otexstream & os, OutputParams const & rp) const if (rp.inulemcmd > 0) os << "\\mbox{"; - if (buffer().masterParams().use_refstyle && cmd == "eqref") { + if (buffer().masterParams().xref_package == "refstyle" && cmd == "eqref") { // we advertise this as printing "(n)", so we'll do that, at least // for refstyle, since refstlye's own \eqref prints, by default, // "equation n". if one wants \eqref, one can get it by using a @@ -283,7 +283,7 @@ void InsetRef::latex(otexstream & os, OutputParams const & rp) const docstring prefix; bool const use_caps = getParam("caps") == "true"; bool const use_plural = getParam("plural") == "true"; - bool const use_refstyle = buffer().masterParams().use_refstyle; + bool const use_refstyle = buffer().masterParams().xref_package == "refstyle"; docstring const fcmd = getFormattedCmd(data, label, prefix, use_refstyle, use_caps); os << fcmd; @@ -366,9 +366,9 @@ void InsetRef::docbook(XMLStream & xs, OutputParams const &) const if (cmd == "formatted") { // A formatted reference may have many parameters. Generate all of them as roles, the only // way arbitrary parameters can be passed into DocBook. - if (buffer().params().use_refstyle && getParam("caps") == "true") + if (buffer().params().xref_package == "refstyle" && getParam("caps") == "true") role += " refstyle-caps"; - if (buffer().params().use_refstyle && getParam("plural") == "true") + if (buffer().params().xref_package == "refstyle" && getParam("plural") == "true") role += " refstyle-plural"; } } else if (cmd == "eqref") { @@ -411,7 +411,7 @@ docstring InsetRef::displayString(docstring const & ref, string const & cmd, display_string = '(' + value + ')'; else if (cmd == "formatted") { display_string = il->formattedCounter(); - if (buffer().params().use_refstyle && getParam("caps") == "true") + if (buffer().params().xref_package == "refstyle" && getParam("caps") == "true") capitalize(display_string); // it is hard to see what to do about plurals... } @@ -605,7 +605,7 @@ void InsetRef::validate(LaTeXFeatures & features) const docstring const data = getEscapedLabel(features.runparams()); docstring label; docstring prefix; - bool const use_refstyle = buffer().masterParams().use_refstyle; + bool const use_refstyle = buffer().masterParams().xref_package == "refstyle"; bool const use_caps = getParam("caps") == "true"; docstring const fcmd = getFormattedCmd(data, label, prefix, use_refstyle, use_caps); @@ -625,7 +625,7 @@ void InsetRef::validate(LaTeXFeatures & features) const if (prefix == "chap") features.addPreambleSnippet(from_ascii("\\let\\pr@chap=\\pr@cha")); } - } else if (cmd == "eqref" && !buffer().params().use_refstyle) + } else if (cmd == "eqref" && buffer().params().xref_package != "refstyle") // with refstyle, we simply output "(\ref{label})" features.require("amsmath"); else if (cmd == "nameref") diff --git a/src/mathed/InsetMathRef.cpp b/src/mathed/InsetMathRef.cpp index e6d246fbb0..078d0b23e8 100644 --- a/src/mathed/InsetMathRef.cpp +++ b/src/mathed/InsetMathRef.cpp @@ -209,7 +209,7 @@ void InsetMathRef::validate(LaTeXFeatures & features) const LYXERR0("LaTeX output may be wrong!"); } bool const use_refstyle = - buffer_ && buffer().params().use_refstyle; + buffer_ && buffer().params().xref_package == "refstyle"; if (commandname() == "vref" || commandname() == "vpageref") features.require("varioref"); @@ -302,7 +302,7 @@ void InsetMathRef::write(TeXMathStream & os) const return; } bool const use_refstyle = - buffer_ && buffer().params().use_refstyle; + buffer_ && buffer().params().xref_package == "refstyle"; bool special_case = cmd == "formatted" || cmd == "labelonly" || (cmd == "eqref" && use_refstyle); diff --git a/src/tex2lyx/Preamble.cpp b/src/tex2lyx/Preamble.cpp index 7f672062dc..24e106d9af 100644 --- a/src/tex2lyx/Preamble.cpp +++ b/src/tex2lyx/Preamble.cpp @@ -1013,7 +1013,7 @@ Preamble::Preamble() : one_language(true), explicit_babel(false), h_use_hyperref = "false"; h_use_microtype = "false"; h_use_lineno = "false"; - h_use_refstyle = false; + h_crossref_package = "prettyref"; h_use_minted = false; h_use_xcolor_svgnames = false; h_use_packages["amsmath"] = "1"; @@ -2163,10 +2163,8 @@ void Preamble::handle_package(Parser &p, string const & name, h_use_indices = "true"; else if (name == "minted") h_use_minted = true; - else if (name == "refstyle") - h_use_refstyle = true; - else if (name == "prettyref") - h_use_refstyle = false; + else if (name == "refstyle" || name == "prettyref") + h_crossref_package = name; if (!in_lyx_preamble) { h_preamble << package_beg_sep << name @@ -2527,7 +2525,7 @@ bool Preamble::writeLyXHeader(ostream & os, bool subdoc, string const & outfiled << "\\paperorientation " << h_paperorientation << '\n' << "\\suppress_date " << h_suppress_date << '\n' << "\\justification " << h_justification << '\n' - << "\\use_refstyle " << h_use_refstyle << '\n' + << "\\crossref_package " << h_crossref_package << '\n' << "\\use_minted " << h_use_minted << '\n' << "\\use_lineno " << h_use_lineno << '\n'; if (!h_lineno_options.empty()) diff --git a/src/tex2lyx/Preamble.h b/src/tex2lyx/Preamble.h index fbd3973fa4..74f77c6eaa 100644 --- a/src/tex2lyx/Preamble.h +++ b/src/tex2lyx/Preamble.h @@ -41,7 +41,7 @@ public: /// std::string notefontcolor() const { return h_notefontcolor; } /// - bool refstyle() const { return h_use_refstyle; } + std::string crossrefPackage() const { return h_crossref_package; } /// bool fontCJKSet() const { return h_font_cjk_set; } /// @@ -265,7 +265,7 @@ private: std::string h_use_default_options; std::string h_use_hyperref; std::vector<std::string> h_includeonlys; - bool h_use_refstyle; + std::string h_crossref_package; bool h_use_minted; std::string h_nomencl_options; bool h_use_xcolor_svgnames; diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp index 0fd2c91127..e614c24fe6 100644 --- a/src/tex2lyx/text.cpp +++ b/src/tex2lyx/text.cpp @@ -4545,7 +4545,7 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer, // We uncapitalize the input in order to catch capitalized commands // such as \Eqref. if ((where = is_known(uncapitalize(t.cs()), known_refstyle_commands)) - && preamble.refstyle()) { + && preamble.crossrefPackage() == "refstyle") { string const cap = isCapitalized(t.cs()) ? "true" : "false"; string plural = "false"; // Catch the plural option [s] @@ -4583,8 +4583,8 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer, // if refstyle is used, we must not convert \prettyref to a // formatted reference, since that would result in a refstyle command. if ((where = is_known(t.cs(), known_ref_commands)) - && (t.cs() != "prettyref" || !preamble.refstyle()) - && (p.next_token().asInput() != "*" || is_known(t.cs(), known_starref_commands))) { + && (t.cs() != "prettyref" || preamble.crossrefPackage() == "prettyref") + && (p.next_token().asInput() != "*" || is_known(t.cs(), known_starref_commands))) { bool starred = false; if (p.next_token().asInput() == "*") { starred = true; diff --git a/src/version.h b/src/version.h index 51db0ba209..d32f196b6d 100644 --- a/src/version.h +++ b/src/version.h @@ -32,8 +32,8 @@ extern char const * const lyx_version_info; // Do not remove the comment below, so we get merge conflict in // independent branches. Instead add your own. -#define LYX_FORMAT_LYX 634 // spitz: colortbl support -#define LYX_FORMAT_TEX2LYX 634 +#define LYX_FORMAT_LYX 635 // spitz: \\crossref_package +#define LYX_FORMAT_TEX2LYX 635 #if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX #ifndef _MSC_VER -- lyx-cvs mailing list lyx-cvs@lists.lyx.org https://lists.lyx.org/mailman/listinfo/lyx-cvs