From: Juergen Spitzmueller Date: Tue, 13 Aug 2019 08:38:26 +0000 (+0200) Subject: Support memoir's builtin endnotes X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=bf39f1e2fd8f177dcdd66252701afc04c3dba6cc;p=features.git Support memoir's builtin endnotes --- 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]],