Add support for the enotez package

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.
This commit is contained in:
Juergen Spitzmueller 2019-08-13 07:30:20 +02:00
parent 28796bcb63
commit 8abe7b25e8
12 changed files with 316 additions and 11 deletions

View 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

View 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 \

View File

@ -337,6 +337,7 @@
\TestPackage[koi8-r.def]{cyrillic}
\TestPackage{dvipost}
\TestPackage{endnotes}
\TestPackage{enotez}
\TestPackage{enumitem}
\TestPackage{environ} % required by tcolorbox
\TestPackage{esint}

View 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

View 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

40
lib/layouts/enotez.module Normal file
View File

@ -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

View 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

View File

@ -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

View 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]],

View 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

View File

@ -978,6 +978,7 @@ char const * simplefeatures[] = {
"csquotes",
"enumitem",
"endnotes",
"enotez",
"hhline",
"ifthen",
// listings is handled in BufferParams.cpp

View 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);