From 0dd5824b43162359b86843d77eb7bdb5331e1dbf Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Tue, 13 Aug 2019 10:38:26 +0200 Subject: [PATCH] Support memoir's builtin endnotes --- lib/layouts/memoir.layout | 47 +++++++++++++++++++++++++++++++++++++++ lib/lyx2lyx/lyx_2_4.py | 32 +++++++++++++++++++++++++- 2 files changed, 78 insertions(+), 1 deletion(-) diff --git a/lib/layouts/memoir.layout b/lib/layouts/memoir.layout index 7a1404aef8..ef4685328d 100644 --- a/lib/layouts/memoir.layout +++ b/lib/layouts/memoir.layout @@ -290,3 +290,50 @@ Style Legend ParSkip 0.4 Align Center End + +# +# Endnotes (called "pagenotes" in memoir) +# + +Counter endnotes + PrettyFormat "Endnote ##" +End + +InsetLayout Flex:Endnote + LyXType custom + LatexName pagenote + LatexType command + Counter endnotes + Decoration classic + Font + Size Small + EndFont + MultiPar true + LabelString endnote + Preamble + \makepagenote + EndPreamble + LangPreamble + \providecommand{\notesname}{_(Notes[[Endnotes]])} + EndLangPreamble + BabelPreamble + \addto\captions$$lang{\renewcommand{\notesname}{_(Notes[[Endnotes]])}} + EndBabelPreamble +End + +# We are only interested in the list +Float + Type pagenote + ListName "Endnotes (all)" + IsPredefined true + UsesFloatPkg false + ListCommand printpagenotes +End + +Float + Type pagenote* + ListName "Endnotes (sectioned)" + IsPredefined true + UsesFloatPkg false + ListCommand printpagenotes* +End diff --git a/lib/lyx2lyx/lyx_2_4.py b/lib/lyx2lyx/lyx_2_4.py index 064a07b085..65b8df5560 100644 --- a/lib/lyx2lyx/lyx_2_4.py +++ b/lib/lyx2lyx/lyx_2_4.py @@ -3440,6 +3440,36 @@ def revert_enotez(document): add_to_preamble(document, ["\\usepackage{enotez}"]) document.del_module("enotez") document.del_module("foottoenotez") + + +def revert_memoir_endnotes(document): + " Reverts native support of memoir endnotes to TeX-code " + + if document.textclass != "memoir": + return + + encommand = "\\pagenote" + modules = document.get_module_list() + if "enotez" in modules or "foottoenotez" in modules or "endnotes" in modules or "foottoend" in modules: + encommand = "\\endnote" + + revert_flex_inset(document.body, "Endnote", encommand) + + i = 0 + while True: + i = find_token(document.body, "\\begin_inset FloatList pagenote", 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 + + if document.body[i] == "\\begin_inset FloatList pagenote*": + document.body[i : j + 1] = put_cmd_in_ert("\\printpagenotes*") + else: + document.body[i : j + 1] = put_cmd_in_ert("\\printpagenotes") + add_to_preamble(document, ["\\makepagenote"]) ## @@ -3494,7 +3524,7 @@ convert = [ [588, []] ] -revert = [[587, [revert_enotez,revert_theendnotes]], +revert = [[587, [revert_memoir_endnotes,revert_enotez,revert_theendnotes]], [586, [revert_pagesizenames]], [585, [revert_dupqualicites]], [584, [revert_pagesizes,revert_komafontsizes]],