]> git.lyx.org Git - features.git/commitdiff
Add support for the enotez package
authorJuergen Spitzmueller <spitz@lyx.org>
Tue, 13 Aug 2019 05:30:20 +0000 (07:30 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 18 Jun 2020 13:48:43 +0000 (15:48 +0200)
This is a modern implementation of endnotes building on LaTeX3 tools which
gets away with deficiencies of the endnotes package, has some extra features,
is localized, supports hyperref and is better customizable.

As this is a fairly new package requiring l3, we keep the old endnotes
module and provide this as an alternative.

12 files changed:
development/FORMAT
lib/Makefile.am
lib/chkconfig.ltx
lib/doc/LaTeXConfig.lyx
lib/layouts/endnotes.module
lib/layouts/enotez.module [new file with mode: 0644]
lib/layouts/foottoend.module
lib/layouts/foottoenotez.module [new file with mode: 0644]
lib/lyx2lyx/lyx_2_4.py
src/LaTeX.cpp
src/LaTeXFeatures.cpp
src/tex2lyx/text.cpp

index 8bb4a3ae3e311b095c88c6b151565d811018e360..ffecd54693332b84e2d640b0a7888e83e097b7f4 100644 (file)
@@ -8,8 +8,9 @@ changes happened in particular if possible. A good example would be
 -----------------------
 
 2019-08-12 Jürgen Spitzmüller <spitz@lyx.org>
-       * Format incremented to 588: Support \theendnotes of endnotes package via a faked
-          float list.
+       * Format incremented to 588: 
+        - Support \theendnotes of endnotes package via a faked float list.
+        - Support enotez package via enotez and foottoenotez modules.
 
 2019-08-07 Jürgen Spitzmüller <spitz@lyx.org>
        * Format incremented to 587: Use more generic paper names as LyX names
index 4b5e6a7149f592609f0f3e54c5d14aa37fbe156c..d0b0b7b5a1d9759aada3f1da97fb20f39c3864cf 100644 (file)
@@ -2341,6 +2341,7 @@ dist_layouts_DATA =\
        layouts/elsart.layout \
        layouts/elsarticle.layout \
        layouts/endnotes.module \
+       layouts/enotez.module \
        layouts/entcs.layout \
        layouts/enumitem.module \
        layouts/eqs-within-sections.module \
@@ -2356,6 +2357,7 @@ dist_layouts_DATA =\
        layouts/fix-cm.module \
        layouts/foils.layout \
        layouts/foottoend.module \
+       layouts/foottoenotez.module \
        layouts/frletter.layout \
        layouts/g-brief.layout \
        layouts/g-brief2.layout \
index dd015bda8ecb6a958c3c2ec4479f2b7d8a4162ec..069d3a5cecc75de597fd1ee86fdfd5ebc4aa4587 100644 (file)
 \TestPackage[koi8-r.def]{cyrillic}
 \TestPackage{dvipost}
 \TestPackage{endnotes}
+\TestPackage{enotez}
 \TestPackage{enumitem}
 \TestPackage{environ} % required by tcolorbox
 \TestPackage{esint}
index dd6c02e475b583b534d758c75a5b95fb7c3658a9..f98488fae9d33e3d484800202f3cd782c8fa6e4c 100644 (file)
@@ -1,5 +1,5 @@
 #LyX 2.4 created this file. For more info see https://www.lyx.org/
-\lyxformat 583
+\lyxformat 588
 \begin_document
 \begin_header
 \save_transient_properties true
@@ -6480,10 +6480,14 @@ Packages required by modules
 \end_layout
 
 \begin_layout Subsection
+
+\change_deleted -712698321 1565673310
 endnotes
 \end_layout
 
 \begin_layout Description
+
+\change_deleted -712698321 1565673310
 Found: 
 \begin_inset Info
 type  "package"
@@ -6494,18 +6498,24 @@ arg   "endnotes"
 \end_layout
 
 \begin_layout Description
+
+\change_deleted -712698321 1565673310
 CTAN: 
 \family typewriter
 macros/latex/contrib/misc/endnotes.sty
 \end_layout
 
 \begin_layout Description
+
+\change_deleted -712698321 1565673310
 Notes: The package 
 \family sans
 endnotes 
 \family default
 is needed by several modules to place footnotes at the end of sections,
  that are then so called endnotes.
+\change_unchanged
+
 \end_layout
 
 \begin_layout Subsection
@@ -6540,6 +6550,150 @@ braille
 makes it possible to typeset Braille, a character system for blind people.
 \end_layout
 
+\begin_layout Subsection
+
+\change_inserted -712698321 1565673326
+Endnotes (Basic) module
+\end_layout
+
+\begin_layout Subsubsection
+
+\change_inserted -712698321 1565673326
+endnotes
+\end_layout
+
+\begin_layout Description
+
+\change_inserted -712698321 1565673326
+Found: 
+\begin_inset Info
+type  "package"
+arg   "endnotes"
+\end_inset
+
+
+\end_layout
+
+\begin_layout Description
+
+\change_inserted -712698321 1565673326
+CTAN: 
+\family typewriter
+macros/latex/contrib/endnotes/
+\end_layout
+
+\begin_layout Description
+
+\change_inserted -712698321 1565673631
+Notes: The package 
+\family sans
+endnotes 
+\family default
+is needed by the 
+\emph on
+Endnotes (Basic)
+\emph default
+ and 
+\emph on
+Footnotes as Endnotes (Basic)
+\emph default
+ modules to place footnotes at the end of sections, that are then so called
+ endnotes.
+ It is more limited, but also more established, than 
+\family sans
+enotez
+\family default
+ [cf.
+ Endnotes (Extended) module].
+\change_unchanged
+
+\end_layout
+
+\begin_layout Subsection
+
+\change_inserted -712698321 1565673348
+Endnotes (Extended) module
+\end_layout
+
+\begin_layout Subsubsection
+
+\change_inserted -712698321 1565673326
+enotez
+\end_layout
+
+\begin_layout Description
+
+\change_inserted -712698321 1565673326
+Found: 
+\begin_inset Info
+type  "package"
+arg   "enotez"
+\end_inset
+
+
+\end_layout
+
+\begin_layout Description
+
+\change_inserted -712698321 1565673326
+CTAN: 
+\family typewriter
+macros/latex/contrib/enotez/
+\end_layout
+
+\begin_layout Description
+
+\change_inserted -712698321 1565673326
+Notes: The package 
+\family sans
+enotez 
+\family default
+is needed by the 
+\emph on
+Endnotes (Extended)
+\emph default
+ and 
+\emph on
+Footnotes as Endnotes (Extended)
+\emph default
+ modules to produce endnotes; 
+\family sans
+enotez
+\family default
+ is a new implementation of endnotes for \SpecialChar LaTeX2e
+ since the 
+\family sans
+endnotes
+\family default
+ package (used by the 
+\emph on
+Basic
+\emph default
+ endnotes modules) has some deficiencies.
+ As opposed to the latter, 
+\family sans
+enotez
+\family default
+ supports nested endnotes, hyper- and backlinks (
+\family sans
+hyperref
+\family default
+) and a split list of endnotes in which the notes are automatically separated
+ by the sections or chapters they were set in.
+ Several languages are supported, and the output is easier customizable
+ than that of the 
+\family sans
+endnotes
+\family default
+ package.
+ However, 
+\family sans
+enotez
+\family default
+ requires a fairly modern \SpecialChar LaTeX
+ distribution.
+\end_layout
+
 \begin_layout Subsection
 FIXME module
 \end_layout
@@ -6581,6 +6735,38 @@ FIXME
  notes into documents.
 \end_layout
 
+\begin_layout Subsection
+
+\change_inserted -712698321 1565673411
+Footnotes as Endnotes (Basic)
+\end_layout
+
+\begin_layout Standard
+
+\change_inserted -712698321 1565673436
+See 
+\emph on
+Endnotes (Basic)
+\emph default
+.
+\end_layout
+
+\begin_layout Subsection
+
+\change_inserted -712698321 1565673439
+Footnotes as Endnotes (Extended)
+\end_layout
+
+\begin_layout Standard
+
+\change_inserted -712698321 1565673442
+See 
+\emph on
+Endnotes (Extended)
+\emph default
+.
+\end_layout
+
 \begin_layout Subsection
 Hazard and Precautionary Statements module
 \end_layout
index e5ad7a25749af052b17af060065d641eea037c1c..dd3a77c4dc54ca9128ffdec0143de562a7100fce 100644 (file)
@@ -1,10 +1,13 @@
-#\DeclareLyXModule[endnotes.sty]{Endnotes}
+#\DeclareLyXModule[endnotes.sty]{Endnotes (Basic)}
 #\DeclareCategory{Foot- and Endnotes}
 #DescriptionBegin
-#Adds an endnote inset, in addition to footnotes. You will need to add an
-#endnotes list (Insert > List/Contents/References > Endnotes) where you
+#Adds an endnote inset, in addition to footnotes. This uses the endnotes
+#package, which has some limitations but works with older LaTeX distributions
+#as well. You will need to add an endnotes list
+#(Insert > List/Contents/References > Endnotes) where you
 #want the endnotes to appear.
 #DescriptionEnd
+#Excludes: enotez | foottoenotez
 
 Format 80
 
diff --git a/lib/layouts/enotez.module b/lib/layouts/enotez.module
new file mode 100644 (file)
index 0000000..1d3ab30
--- /dev/null
@@ -0,0 +1,40 @@
+#\DeclareLyXModule[enotez.sty]{Endnotes (Extended)}
+#\DeclareCategory{Foot- and Endnotes}
+#DescriptionBegin
+#Adds an endnote inset, in addition to footnotes. This uses the enotez package
+#which is more powerful and customitable than then endnotes package (module 'Endnotes (Basic)'),
+#but requires a fairly modern LaTeX distribution (with LaTeX3).
+#You will need to add an endnotes list (Insert > List/Contents/References > Endnotes)
+#where you want the endnotes to appear.
+#DescriptionEnd
+#Excludes: endnotes | foottoend
+
+Format 80
+
+Counter endnotes
+    PrettyFormat "Endnote ##"
+End
+
+InsetLayout Flex:Endnote
+   LyXType     custom
+   LatexName   endnote
+   LatexType   command
+   Counter     endnotes
+   Decoration  classic
+   Font
+     Size Small
+   EndFont
+   MultiPar    true
+   LabelString endnote
+   Requires    enotez
+End
+
+# We are only interested in the list
+Float
+   Type          endnote
+   ListName      "Endnotes"
+   IsPredefined  true
+   UsesFloatPkg  false
+   ListCommand   printendnotes
+   Requires      enotez
+End
index 1c53c737bd2968815b455e0a15ad71a12c60a3c5..cfa6aa53dda12c4892dddc6823a3325b34c49f9a 100644 (file)
@@ -1,10 +1,13 @@
-#\DeclareLyXModule[endnotes.sty]{Footnotes as Endnotes}
+#\DeclareLyXModule[endnotes.sty]{Footnotes as Endnotes (Basic)}
 #\DeclareCategory{Foot- and Endnotes}
 #DescriptionBegin
-#Sets all footnotes as endnotes. You will need to add an
-#endnotes list (Insert > List/Contents/References > Endnotes) where you
+#Sets all footnotes as endnotes. This uses the endnotes
+#package, which has some limitations but works with older LaTeX distributions
+#as well. You will need to add an endnotes list
+#(Insert > List/Contents/References > Endnotes) where you
 #want the endnotes to appear.
 #DescriptionEnd
+#Excludes: enotez | foottoenotez
 
 Format 80
 
diff --git a/lib/layouts/foottoenotez.module b/lib/layouts/foottoenotez.module
new file mode 100644 (file)
index 0000000..d575f51
--- /dev/null
@@ -0,0 +1,30 @@
+#\DeclareLyXModule[enotez.sty]{Footnotes as Endnotes (Extended)}
+#\DeclareCategory{Foot- and Endnotes}
+#DescriptionBegin
+#Sets all footnotes as endnotes. This uses the enotez package
+#which is more powerful and customitable than then endnotes package
+#(module 'Footnotes as Endnotes (Basic)'), but requires a fairly modern
+#LaTeX distribution (with LaTeX3).You will need to add an
+#endnotes list (Insert > List/Contents/References > Endnotes) where you
+#want the endnotes to appear.
+#DescriptionEnd
+#Excludes: endnotes | foottoend
+
+Format 80
+
+
+InsetLayout Foot
+       LabelString     Endnote
+       LatexName       endnote
+       Requires        enotez
+End
+
+# We are only interested in the list
+Float
+   Type          endnote
+   ListName      "Endnotes"
+   IsPredefined  true
+   UsesFloatPkg  false
+   ListCommand   printendnotes
+   Requires      enotez
+End
index 15d83b81450f5170c2f25a324b0f2994cfaff591..064a07b085459f240afaf3cd952bfacdd7062139 100644 (file)
@@ -3409,6 +3409,37 @@ def revert_theendnotes(document):
             continue
 
         document.body[i : j + 1] = put_cmd_in_ert("\\theendnotes")
+
+
+def revert_enotez(document):
+    " Reverts native support of enotez package to TeX-code "
+
+    if not "enotez" in document.get_module_list() and not "foottoenotez" in document.get_module_list():
+        return
+
+    use = False
+    if find_token(document.body, "\\begin_inset Flex Endnote", 0) != -1:
+        use = True
+
+    revert_flex_inset(document.body, "Endnote", "\\endnote")
+
+    i = 0
+    while True:
+        i = find_token(document.body, "\\begin_inset FloatList endnote", i + 1)
+        if i == -1:
+            break
+        j = find_end_of_inset(document.body, i)
+        if j == -1:
+            document.warning("Malformed LyX document: Can't find end of FloatList inset")
+            continue
+
+        use = True
+        document.body[i : j + 1] = put_cmd_in_ert("\\printendnotes")
+
+    if use:
+        add_to_preamble(document, ["\\usepackage{enotez}"])
+    document.del_module("enotez")
+    document.del_module("foottoenotez")
     
 
 ##
@@ -3463,7 +3494,7 @@ convert = [
            [588, []]
           ]
 
-revert =  [[587, [revert_theendnotes]],
+revert =  [[587, [revert_enotez,revert_theendnotes]],
            [586, [revert_pagesizenames]],
            [585, [revert_dupqualicites]],
            [584, [revert_pagesizes,revert_komafontsizes]],
index e68e07c71f921807ebb1bcee5b5348cb01657cee..4606ed3f4571c05c36c4dcc26d3f6c788af52861 100644 (file)
@@ -799,6 +799,10 @@ int LaTeX::scanLogFile(TeXErrors & terr)
                        } else if (contains(token, "Etaremune labels have changed")) {
                                retval |= ERROR_RERUN;
                                LYXERR(Debug::LATEX, "Force rerun.");
+                       // package enotez
+                       } else if (contains(token, "Endnotes may have changed. Rerun")) {
+                               retval |= RERUN;
+                               LYXERR(Debug::LATEX, "We should rerun.");
                        //"Citation `cit' on page X undefined on input line X."
                        } else if (contains(token, "Citation")
                                   //&& contains(token, "on input line") //often split to newline
index 3b7519ae9f5abda962f8cf374d67447d664de0eb..cd9db0693076fe3d64a07e06d3b4e7989b814da2 100644 (file)
@@ -978,6 +978,7 @@ char const * simplefeatures[] = {
        "csquotes",
        "enumitem",
        "endnotes",
+       "enotez",
        "hhline",
        "ifthen",
        // listings is handled in BufferParams.cpp
index abc25f274fd6adf4fd3bd78f058f5332ce2eeeb6..764cffa9884bd3fd714bc4aa83cc79f291bf521c 100644 (file)
@@ -3931,7 +3931,10 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                        continue;
                }
 
-               if (t.cs() == "theendnotes") {
+               if (t.cs() == "theendnotes"
+                  || (t.cs() == "printendnotes"
+                      && p.next_token().asInput() != "*"
+                      && !p.hasOpt())) {
                        context.check_layout(os);
                        begin_inset(os, "FloatList endnote\n");
                        end_inset(os);