From 6e5b3a1e31037501e80c9ac134f8c1bf2a236ed4 Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Sun, 5 Feb 2023 12:07:37 +0100 Subject: [PATCH] Properly fix acknowledgment issue part 2/2 Remove acknowledgment theorem types As we have learned, these shouldn't have been added from the get go. Documents having it get a local layout definition. --- lib/doc/Additional.lyx | 42 +++-- lib/doc/de/Additional.lyx | 21 +-- lib/layouts/AEA.layout | 18 +- .../theorems-ams-extended-bytype.module | 54 +----- .../theorems-ams-extended-chap-bytype.module | 61 +----- lib/layouts/theorems-ams-extended.module | 53 +----- .../theorems-counters-extended-bytype.inc | 3 - lib/layouts/theorems-refprefix.inc | 5 - lib/lyx2lyx/lyx_2_4.py | 174 +++++++++++++++++- 9 files changed, 212 insertions(+), 219 deletions(-) diff --git a/lib/doc/Additional.lyx b/lib/doc/Additional.lyx index 0de82cac52..5457dcac61 100644 --- a/lib/doc/Additional.lyx +++ b/lib/doc/Additional.lyx @@ -1,5 +1,5 @@ #LyX 2.4 created this file. For more info see https://www.lyx.org/ -\lyxformat 614 +\lyxformat 615 \begin_document \begin_header \save_transient_properties true @@ -3856,7 +3856,11 @@ Do we really need to tell you? \end_layout \begin_layout Acknowledgement* + +\change_deleted -712698321 1675595089 Acknowledgement. +\change_unchanged + \end_layout \begin_layout Conclusion* @@ -20735,17 +20739,15 @@ Summary \family default , -\change_deleted -712698321 1674897978 +\change_deleted -712698321 1675594790 \family sans Acknowledgement -\change_inserted -712698321 1674897978 -Acknowledgment -\change_inserted 564990737 1672224959 - \family default , +\change_inserted 564990737 1672224959 + \family sans Conclusion \family default @@ -20828,15 +20830,15 @@ Summary \family default , +\change_deleted -712698321 1675594800 + \family sans -Acknowledg -\change_deleted -712698321 1674898178 -e -\change_inserted 564990737 1672224959 -ment +Acknowledgement \family default , +\change_inserted 564990737 1672224959 + \family sans Conclusion \family default @@ -21055,14 +21057,14 @@ Summary \family default , +\change_deleted -712698321 1675594806 + \family sans -Acknowledg -\change_deleted -712698321 1674898457 -e -\change_inserted 564990737 1672224959 -ment +Acknowledgement \family default , + +\change_inserted 564990737 1672224959 \family sans Conclusion @@ -28322,6 +28324,8 @@ status collapsed \backslash renewcommand +\change_unchanged + \end_layout \end_inset @@ -28404,6 +28408,8 @@ star \end_inset +\change_unchanged + \end_layout \end_inset @@ -28430,6 +28436,8 @@ status collapsed \change_inserted -712698321 1674916288 \SpecialChar TeX Code +\change_unchanged + \end_layout \end_inset @@ -28450,6 +28458,8 @@ status collapsed star \backslash ) +\change_unchanged + \end_layout \end_inset diff --git a/lib/doc/de/Additional.lyx b/lib/doc/de/Additional.lyx index 2d765e6d8c..0ea0526e18 100644 --- a/lib/doc/de/Additional.lyx +++ b/lib/doc/de/Additional.lyx @@ -1,5 +1,5 @@ #LyX 2.4 created this file. For more info see https://www.lyx.org/ -\lyxformat 614 +\lyxformat 615 \begin_document \begin_header \save_transient_properties true @@ -2997,10 +2997,6 @@ Für die Erläuterung der Notationskonventionen. Müssen wir das wirklich erläutern? \end_layout -\begin_layout Acknowledgement* -Nun ja. -\end_layout - \begin_layout Conclusion* Manchmal am Ende einer langen Argumentationskette verwendet. \end_layout @@ -16431,11 +16427,6 @@ Zusammenfassung \family default , -\family sans -Danksagung -\family default -, - \family sans Schlussfolgerung \family default @@ -16505,11 +16496,6 @@ Zusammenfassung \family default , -\family sans -Danksagung -\family default -, - \family sans Schlussfolgerung \family default @@ -16636,11 +16622,6 @@ Zusammenfassung \family default , -\family sans -Danksagung -\family default -, - \family sans Schlussfolgerung \family default diff --git a/lib/layouts/AEA.layout b/lib/layouts/AEA.layout index 0f859f9f4a..499f480a48 100644 --- a/lib/layouts/AEA.layout +++ b/lib/layouts/AEA.layout @@ -32,8 +32,6 @@ NoStyle LyX-Code NoStyle Verse NoStyle Address NoStyle Right_Address -NoStyle Acknowledgement* -NoStyle Acknowledgment*[[theorem]] NoStyle Algorithm* NoStyle Assumption* NoStyle Axiom* @@ -74,7 +72,7 @@ Style Publication_Month DocBookAttr role='month' DocBookTagType paragraph DocBookInInfo maybe - DocBookNoFontInside true + DocBookNoFontInside true End Style Publication_Year @@ -85,7 +83,7 @@ Style Publication_Year DocBookAttr role='year' DocBookTagType paragraph DocBookInInfo maybe - DocBookNoFontInside true + DocBookNoFontInside true End Style Publication_Volume @@ -127,11 +125,15 @@ Style Abstract InTitle 1 End -Style Acknowledgment[[theorem]] +Style Acknowledgments Category FrontMatter - LabelString "Acknowledgment[[theorem]]." - Preamble - EndPreamble + LatexType Environment + Align Left + Margin Dynamic + LabelType Static + LabelSep M + LabelString "Acknowledgments." + LatexName acknowledgement DocBookTag para DocBookAttr "" DocBookWrapperTag acknowledgements diff --git a/lib/layouts/theorems-ams-extended-bytype.module b/lib/layouts/theorems-ams-extended-bytype.module index 914a50ff15..0ca07ca927 100644 --- a/lib/layouts/theorems-ams-extended-bytype.module +++ b/lib/layouts/theorems-ams-extended-bytype.module @@ -3,7 +3,7 @@ #DescriptionBegin #Defines some additional theorem environments for use with the #AMS theorems packages. Includes Criterion, Algorithm, Axiom, -#Condition, Note, Notation, Summary, Acknowledgment[[theorem]], Conclusion, +#Condition, Note, Notation, Summary, Conclusion, #Assumption, and Case, in both numbered and non-numbered forms. #Contrary to the plain AMS-Extended module, the different theorem #types provided here each have a separate counter (e.g., criterion 1, @@ -31,7 +31,6 @@ Requires amsmath # - Note # - Notation # - Summary -# - Acknowledgment (with LaTeX name acknowledgement for compatib.) # - Conclusion # - Assumption # - Question @@ -322,57 +321,6 @@ Style Summary* End -Style Acknowledgment[[theorem]] - CopyStyle Remark - LatexName acknowledgement - LabelString "Acknowledgment[[theorem]] \theacknowledgement." - Preamble - \theoremstyle{remark} - \newtheorem{acknowledgement}{\protect\acknowledgementname} - EndPreamble - LangPreamble - \providecommand{\acknowledgementname}{_(Acknowledgment[[theorem]])} - EndLangPreamble - BabelPreamble - \addto\captions$$lang{\renewcommand{\acknowledgementname}{_(Acknowledgment[[theorem]])}} - EndBabelPreamble - LabelCounter acknowledgement - DocBookTag para - DocBookAttr role='acknowledgement' - DocBookItemTag "" -End - - -Style Acknowledgement - ObsoletedBy Acknowledgment[[theorem]] -End - - -Style Acknowledgment*[[theorem]] - CopyStyle Remark* - LatexName acknowledgement* - LabelString "Acknowledgment[[theorem]]." - Preamble - \theoremstyle{remark} - \newtheorem*{acknowledgement*}{\protect\acknowledgementname} - EndPreamble - LangPreamble - \providecommand{\acknowledgementname}{_(Acknowledgment[[theorem]])} - EndLangPreamble - BabelPreamble - \addto\captions$$lang{\renewcommand{\acknowledgementname}{_(Acknowledgment[[theorem]])}} - EndBabelPreamble - DocBookTag para - DocBookAttr role='acknowledgement' - DocBookItemTag "" -End - - -Style Acknowledgement* - ObsoletedBy Acknowledgment*[[theorem]] -End - - Style Conclusion CopyStyle Remark LatexName conclusion diff --git a/lib/layouts/theorems-ams-extended-chap-bytype.module b/lib/layouts/theorems-ams-extended-chap-bytype.module index 25776f214d..c65890e757 100644 --- a/lib/layouts/theorems-ams-extended-chap-bytype.module +++ b/lib/layouts/theorems-ams-extended-chap-bytype.module @@ -3,7 +3,7 @@ #DescriptionBegin #Defines some additional theorem environments for use with the #AMS theorems packages. Includes Criterion, Algorithm, Axiom, -#Condition, Note, Notation, Summary, Acknowledgment[[theorem]], Conclusion, +#Condition, Note, Notation, Summary, Conclusion, #Assumption, and Case, in both numbered and non-numbered forms. #Contrary to the plain AMS-Extended module, the different theorem #types provided here each have a separate counter, restarted with each @@ -32,7 +32,6 @@ Requires amsmath # - Note # - Notation # - Summary -# - Acknowledgment (with LaTeX name acknowledgement for compatib.) # - Conclusion # - Assumption # - Question @@ -59,9 +58,6 @@ End Counter summary Within chapter End -Counter acknowledgement - Within chapter -End Counter conclusion Within chapter End @@ -389,61 +385,6 @@ Style Summary* End -Style Acknowledgment[[theorem]] - CopyStyle Remark - LatexName acknowledgement - LabelString "Acknowledgment[[theorem]] \theacknowledgement." - Preamble - \theoremstyle{remark} - \ifx\thechapter\undefined - \newtheorem{acknowledgement}{\protect\acknowledgementname} - \else - \newtheorem{acknowledgement}{\protect\acknowledgementname}[chapter] - \fi - EndPreamble - LangPreamble - \providecommand{\acknowledgementname}{_(Acknowledgment[[theorem]])} - EndLangPreamble - BabelPreamble - \addto\captions$$lang{\renewcommand{\acknowledgementname}{_(Acknowledgment[[theorem]])}} - EndBabelPreamble - LabelCounter acknowledgement - DocBookTag para - DocBookAttr role='acknowledgement' - DocBookItemTag "" -End - - -Style Acknowledgement - ObsoletedBy Acknowledgment[[theorem]] -End - - -Style Acknowledgment*[[theorem]] - CopyStyle Remark* - LatexName acknowledgement* - LabelString "Acknowledgment[[theorem]]." - Preamble - \theoremstyle{remark} - \newtheorem*{acknowledgement*}{\protect\acknowledgementname} - EndPreamble - LangPreamble - \providecommand{\acknowledgementname}{_(Acknowledgment[[theorem]])} - EndLangPreamble - BabelPreamble - \addto\captions$$lang{\renewcommand{\acknowledgementname}{_(Acknowledgment[[theorem]])}} - EndBabelPreamble - DocBookTag para - DocBookAttr role='acknowledgement' - DocBookItemTag "" -End - - -Style Acknowledgement* - ObsoletedBy Acknowledgment*[[theorem]] -End - - Style Conclusion CopyStyle Remark LatexName conclusion diff --git a/lib/layouts/theorems-ams-extended.module b/lib/layouts/theorems-ams-extended.module index 1d41f4bec0..f9136f03ce 100644 --- a/lib/layouts/theorems-ams-extended.module +++ b/lib/layouts/theorems-ams-extended.module @@ -3,7 +3,7 @@ #DescriptionBegin #Defines some additional theorem environments for use with the #AMS theorems packages. Includes Criterion, Algorithm, Axiom, -#Condition, Note, Notation, Summary, Acknowledgment[[theorem]], Conclusion, +#Condition, Note, Notation, Summary, Conclusion, #Fact, Assumption, Case, and Question, in both numbered and non-numbered #forms. #DescriptionEnd @@ -27,7 +27,6 @@ Requires amsmath # - Note # - Notation # - Summary -# - Acknowledgment (with LaTeX name acknowledgement for compatib.) # - Conclusion # - Fact # - Assumption @@ -313,56 +312,6 @@ Style Summary* End -Style Acknowledgment[[theorem]] - CopyStyle Remark - LatexName acknowledgement - LabelString "Acknowledgment[[theorem]] \thetheorem." - Preamble - \theoremstyle{remark} - \newtheorem{acknowledgement}[thm]{\protect\acknowledgementname} - EndPreamble - LangPreamble - \providecommand{\acknowledgementname}{_(Acknowledgment[[theorem]])} - EndLangPreamble - BabelPreamble - \addto\captions$$lang{\renewcommand{\acknowledgementname}{_(Acknowledgment[[theorem]])}} - EndBabelPreamble - DocBookTag para - DocBookAttr role='acknowledgement' - DocBookItemTag "" -End - - -Style Acknowledgement - ObsoletedBy Acknowledgment[[theorem]] -End - - -Style Acknowledgment*[[theorem]] - CopyStyle Remark* - LatexName acknowledgement* - LabelString "Acknowledgment[[theorem]]." - Preamble - \theoremstyle{remark} - \newtheorem*{acknowledgement*}{\protect\acknowledgementname} - EndPreamble - LangPreamble - \providecommand{\acknowledgementname}{_(Acknowledgment[[theorem]])} - EndLangPreamble - BabelPreamble - \addto\captions$$lang{\renewcommand{\acknowledgementname}{_(Acknowledgment[[theorem]])}} - EndBabelPreamble - DocBookTag para - DocBookAttr role='acknowledgement' - DocBookItemTag "" -End - - -Style Acknowledgement* - ObsoletedBy Acknowledgment*[[theorem]] -End - - Style Conclusion CopyStyle Remark LatexName conclusion diff --git a/lib/layouts/theorems-counters-extended-bytype.inc b/lib/layouts/theorems-counters-extended-bytype.inc index 9d25fa5589..201b5f68fe 100644 --- a/lib/layouts/theorems-counters-extended-bytype.inc +++ b/lib/layouts/theorems-counters-extended-bytype.inc @@ -24,9 +24,6 @@ End Counter summary GuiName Summary End -Counter acknowledgement - GuiName Acknowledgement[[theorem]] -End Counter conclusion GuiName Conclusion End diff --git a/lib/layouts/theorems-refprefix.inc b/lib/layouts/theorems-refprefix.inc index 7ee46b8ea7..99f46249b4 100644 --- a/lib/layouts/theorems-refprefix.inc +++ b/lib/layouts/theorems-refprefix.inc @@ -82,10 +82,6 @@ ModifyStyle Summary RefPrefix sum End -ModifyStyle Acknowledgment[[theorem]] - RefPrefix ack -End - ModifyStyle Conclusion RefPrefix conc End @@ -94,7 +90,6 @@ ModifyStyle Assumption RefPrefix assu End - ModifyStyle Question RefPrefix que End diff --git a/lib/lyx2lyx/lyx_2_4.py b/lib/lyx2lyx/lyx_2_4.py index 7c119579de..20a19836f9 100644 --- a/lib/lyx2lyx/lyx_2_4.py +++ b/lib/lyx2lyx/lyx_2_4.py @@ -4717,6 +4717,7 @@ ack_layouts_new = { "aastex62" : "Acknowledgments", "achemso" : "Acknowledgments", "acmart" : "Acknowledgments", + "AEA" : "Acknowledgments", "apa" : "Acknowledgments", "copernicus" : "Acknowledgments", "egs" : "Acknowledgments",# + Acknowledgment @@ -4739,6 +4740,7 @@ ack_layouts_old = { "aastex62" : "Acknowledgement", "achemso" : "Acknowledgement", "acmart" : "Acknowledgements", + "AEA" : "Acknowledgement", "apa" : "Acknowledgements", "copernicus" : "Acknowledgements", "egs" : "Acknowledgements",# + Acknowledgement @@ -4799,6 +4801,174 @@ def revert_acknowledgment(document): break document.body[i] = "\\begin_layout Acknowledgement" + +ack_theorem_def = [ + r'### Inserted by lyx2lyx (ams extended theorems) ###', + r'### This requires theorems-ams-extended module to be loaded', + r'Style Acknowledgement', + r' CopyStyle Remark', + r' LatexName acknowledgement', + r' LabelString "Acknowledgement \thetheorem."', + r' Preamble', + r' \theoremstyle{remark}', + r' \newtheorem{acknowledgement}[thm]{\protect\acknowledgementname}', + r' EndPreamble', + r' LangPreamble', + r' \providecommand{\acknowledgementname}{_(Acknowledgement)}', + r' EndLangPreamble', + r' BabelPreamble', + r' \addto\captions$$lang{\renewcommand{\acknowledgementname}{_(Acknowledgement)}}', + r' EndBabelPreamble', + r' DocBookTag para', + r' DocBookAttr role="acknowledgement"', + r' DocBookItemTag ""', + r'End', +] + +ackStar_theorem_def = [ + r'### Inserted by lyx2lyx (ams extended theorems) ###', + r'### This requires a theorems-ams-extended-* module to be loaded', + r'Style Acknowledgement*', + r' CopyStyle Remark*', + r' LatexName acknowledgement*', + r' LabelString "Acknowledgement."', + r' Preamble', + r' \theoremstyle{remark}', + r' \newtheorem*{acknowledgement*}{\protect\acknowledgementname}', + r' EndPreamble', + r' LangPreamble', + r' \providecommand{\acknowledgementname}{_(Acknowledgement)}', + r' EndLangPreamble', + r' BabelPreamble', + r' \addto\captions$$lang{\renewcommand{\acknowledgementname}{_(Acknowledgement)}}', + r' EndBabelPreamble', + r' DocBookTag para', + r' DocBookAttr role="acknowledgement"', + r' DocBookItemTag ""', + r'End', +] + +ack_bytype_theorem_def = [ + r'### Inserted by lyx2lyx (ams extended theorems) ###', + r'### This requires theorems-ams-extended-bytype module to be loaded', + r'Counter acknowledgement', + r' GuiName Acknowledgment', + r'End', + r'Style Acknowledgement', + r' CopyStyle Remark', + r' LatexName acknowledgement', + r' LabelString "Acknowledgement \theacknowledgement."', + r' Preamble', + r' \theoremstyle{remark}', + r' \newtheorem{acknowledgement}{\protect\acknowledgementname}', + r' EndPreamble', + r' LangPreamble', + r' \providecommand{\acknowledgementname}{_(Acknowledgement)}', + r' EndLangPreamble', + r' BabelPreamble', + r' \addto\captions$$lang{\renewcommand{\acknowledgementname}{_(Acknowledgement)}}', + r' EndBabelPreamble', + r' DocBookTag para', + r' DocBookAttr role="acknowledgement"', + r' DocBookItemTag ""', + r'End', +] + +ack_chap_bytype_theorem_def = [ + r'### Inserted by lyx2lyx (ams extended theorems) ###', + r'### This requires theorems-ams-extended-chap-bytype module to be loaded', + r'Counter acknowledgement', + r' GuiName Acknowledgment', + r' Within chapter', + r'End', + r'Style Acknowledgement', + r' CopyStyle Remark', + r' LatexName acknowledgement', + r' LabelString "Acknowledgement \theacknowledgement."', + r' Preamble', + r' \theoremstyle{remark}', + r' \ifx\thechapter\undefined', + r' \newtheorem{acknowledgement}{\protect\acknowledgementname}', + r' \else', + r' \newtheorem{acknowledgement}{\protect\acknowledgementname}[chapter]', + r' \fi', + r' EndPreamble', + r' LangPreamble', + r' \providecommand{\acknowledgementname}{_(Acknowledgement)}', + r' EndLangPreamble', + r' BabelPreamble', + r' \addto\captions$$lang{\renewcommand{\acknowledgementname}{_(Acknowledgement)}}', + r' EndBabelPreamble', + r' DocBookTag para', + r' DocBookAttr role="acknowledgement"', + r' DocBookItemTag ""', + r'End', +] + +def convert_ack_theorems(document): + """Put removed acknowledgement theorems to local layout""" + + haveAck = False + haveStarAck = False + if "theorems-ams-extended-bytype" in document.get_module_list(): + i = 0 + while True: + if haveAck and haveStarAck: + break + i = find_token(document.body, '\\begin_layout Acknowledgement', i) + if i == -1: + break + if document.body[i] == "\\begin_layout Acknowledgement*" and not haveStarAck: + document.append_local_layout(ackStar_theorem_def) + haveStarAck = True + elif not haveAck: + document.append_local_layout(ack_bytype_theorem_def) + haveAck = True + i += 1 + elif "theorems-ams-extended-chap-bytype" in document.get_module_list(): + i = 0 + while True: + if haveAck and haveStarAck: + break + i = find_token(document.body, '\\begin_layout Acknowledgement', i) + if i == -1: + break + if document.body[i] == "\\begin_layout Acknowledgement*" and not haveStarAck: + document.append_local_layout(ackStar_theorem_def) + haveStarAck = True + elif not haveAck: + document.append_local_layout(ack_chap_bytype_theorem_def) + haveAck = True + i += 1 + elif "theorems-ams-extended" in document.get_module_list(): + i = 0 + while True: + if haveAck and haveStarAck: + break + i = find_token(document.body, '\\begin_layout Acknowledgement', i) + if i == -1: + break + if document.body[i] == "\\begin_layout Acknowledgement*" and not haveStarAck: + document.append_local_layout(ackStar_theorem_def) + haveStarAck = True + elif not haveAck: + document.append_local_layout(ack_theorem_def) + haveAck = True + i += 1 + + +def revert_ack_theorems(document): + """Remove acknowledgement theorems from local layout""" + if "theorems-ams-extended-bytype" in document.get_module_list(): + document.del_local_layout(ackStar_theorem_def) + document.del_local_layout(ack_bytype_theorem_def) + elif "theorems-ams-extended-chap-bytype" in document.get_module_list(): + document.del_local_layout(ackStar_theorem_def) + document.del_local_layout(ack_chap_bytype_theorem_def) + elif "theorems-ams-extended" in document.get_module_list(): + document.del_local_layout(ackStar_theorem_def) + document.del_local_layout(ack_theorem_def) + ## # Conversion hub # @@ -4875,10 +5045,10 @@ convert = [ [612, [convert_starred_refs]], [613, []], [614, [convert_hyper_other]], - [615, [convert_acknowledgment]] + [615, [convert_acknowledgment,convert_ack_theorems]] ] -revert = [[614, [revert_acknowledgment]], +revert = [[614, [revert_ack_theorems,revert_acknowledgment]], [613, [revert_hyper_other]], [612, [revert_familydefault]], [611, [revert_starred_refs]], -- 2.39.5