From 0ae337014ec6cfbe7bb884c4f70b8e66764c22c8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Uwe=20St=C3=B6hr?= Date: Wed, 18 Nov 2015 02:36:49 +0100 Subject: [PATCH] theorems-ams: add solution environment fixes bug #6363 now completely --- lib/layouts/theorems-ams-bytype.inc | 22 ++++++++++++++++++++ lib/layouts/theorems-ams-bytype.module | 2 ++ lib/layouts/theorems-ams.inc | 18 ++++++++++++++++ lib/layouts/theorems-order.inc | 6 ++++++ lib/layouts/theorems-refprefix.inc | 4 ++++ lib/layouts/theorems-starred-equivalents.inc | 7 +++++++ lib/layouts/theorems-starred.inc | 18 ++++++++++++++++ lib/lyx2lyx/lyx_2_2.py | 7 ++++--- 8 files changed, 81 insertions(+), 3 deletions(-) diff --git a/lib/layouts/theorems-ams-bytype.inc b/lib/layouts/theorems-ams-bytype.inc index 986257216b..be61359dc0 100644 --- a/lib/layouts/theorems-ams-bytype.inc +++ b/lib/layouts/theorems-ams-bytype.inc @@ -16,6 +16,7 @@ # - Example # - Problem # - Exercise +# - Solution # - Remark # - Claim # - Case (by inclusion) @@ -42,6 +43,8 @@ Counter problem End Counter exercise End +Counter solution +End Counter remark End Counter claim @@ -264,6 +267,25 @@ Style Exercise End +Style Solution + CopyStyle Definition + LatexName sol + LabelString "Solution \thesolution." + Preamble + \theoremstyle{definition} + \newtheorem{sol}{\protect\solutionname} + EndPreamble + Requires amsthm + LangPreamble + \providecommand{\solutionname}{_(Solution)} + EndLangPreamble + BabelPreamble + \addto\captions$$lang{\renewcommand{\solutionname}{_(Solution)}} + EndBabelPreamble + LabelCounter solution +End + + Style Remark CopyStyle Theorem LatexName rem diff --git a/lib/layouts/theorems-ams-bytype.module b/lib/layouts/theorems-ams-bytype.module index 25388a5a43..1f407555d4 100644 --- a/lib/layouts/theorems-ams-bytype.module +++ b/lib/layouts/theorems-ams-bytype.module @@ -38,6 +38,8 @@ Counter definition End Counter example End +Counter solution +End Counter problem End Counter exercise diff --git a/lib/layouts/theorems-ams.inc b/lib/layouts/theorems-ams.inc index 85eb2b6c46..55e946671f 100644 --- a/lib/layouts/theorems-ams.inc +++ b/lib/layouts/theorems-ams.inc @@ -14,6 +14,7 @@ # - Example # - Problem # - Exercise +# - Solution # - Remark # - Claim # - Proof @@ -232,6 +233,23 @@ Style Exercise End +Style Solution + CopyStyle Definition + LatexName sol + LabelString "Solution \thetheorem." + Preamble + \theoremstyle{definition} + \newtheorem{sol}[thm]{\protect\solutionname} + EndPreamble + LangPreamble + \providecommand{\solutionname}{_(Solution)} + EndLangPreamble + BabelPreamble + \addto\captions$$lang{\renewcommand{\solutionname}{_(Solution)}} + EndBabelPreamble +End + + Style Remark CopyStyle Theorem DependsOn Theorem diff --git a/lib/layouts/theorems-order.inc b/lib/layouts/theorems-order.inc index 754fa7f4dc..d44fdb5811 100644 --- a/lib/layouts/theorems-order.inc +++ b/lib/layouts/theorems-order.inc @@ -58,6 +58,12 @@ End Style Exercise* End +Style Solution +End + +Style Solution* +End + Style Remark End diff --git a/lib/layouts/theorems-refprefix.inc b/lib/layouts/theorems-refprefix.inc index 6c0104fed2..5d453e51bb 100644 --- a/lib/layouts/theorems-refprefix.inc +++ b/lib/layouts/theorems-refprefix.inc @@ -38,6 +38,10 @@ IfStyle Exercise RefPrefix exer End +IfStyle Solution + RefPrefix solu +End + IfStyle Remark RefPrefix rem End diff --git a/lib/layouts/theorems-starred-equivalents.inc b/lib/layouts/theorems-starred-equivalents.inc index 2e9c550324..a2e6788a04 100644 --- a/lib/layouts/theorems-starred-equivalents.inc +++ b/lib/layouts/theorems-starred-equivalents.inc @@ -52,6 +52,13 @@ Style Example EndPreamble End +Style Solution + CopyStyle Solution* + DependsOn Solution* + Preamble + EndPreamble +End + Style Problem CopyStyle Problem* DependsOn Problem* diff --git a/lib/layouts/theorems-starred.inc b/lib/layouts/theorems-starred.inc index a1d57df08c..6946d8c356 100644 --- a/lib/layouts/theorems-starred.inc +++ b/lib/layouts/theorems-starred.inc @@ -14,6 +14,7 @@ # - Example # - Problem # - Exercise +# - Solution # - Remark # - Claim # - Proof @@ -225,6 +226,23 @@ Style Exercise* End +Style Solution* + CopyStyle Definition* + LatexName sol* + LabelString "Solution." + Preamble + \theoremstyle{definition} + \newtheorem*{sol*}{\protect\solutionname} + EndPreamble + LangPreamble + \providecommand{\solutionname}{_(Solution)} + EndLangPreamble + BabelPreamble + \addto\captions$$lang{\renewcommand{\solutionname}{_(Solution)}} + EndBabelPreamble +End + + Style Remark* CopyStyle Theorem* LatexName rem* diff --git a/lib/lyx2lyx/lyx_2_2.py b/lib/lyx2lyx/lyx_2_2.py index e041a6bfd9..e4d5387d66 100644 --- a/lib/lyx2lyx/lyx_2_2.py +++ b/lib/lyx2lyx/lyx_2_2.py @@ -2118,7 +2118,8 @@ def revert_solution(document): have_mod = False mods = document.get_module_list() for mod in mods: - if mod == "theorems-std" or mod == "theorems-bytype": + if mod == "theorems-std" or mod == "theorems-bytype" \ + or mod == "theorems-ams" or mod == "theorems-ams-bytype": have_mod = True continue if not have_mod: @@ -2146,10 +2147,10 @@ def revert_solution(document): document.body[j : j + 1] = put_cmd_in_ert("\\end{sol}") + ["\\end_layout"] document.body[i : i + 1] = ["\\begin_layout Standard", ""] + begcmd add_to_preamble(document, "\\providecommand{\solutionname}{Solution}") - if mod == "theorems-std": + if mod == "theorems-std" or mod == "theorems-ams": add_to_preamble(document, "\\theoremstyle{plain}\n" \ "\\newtheorem{sol}[thm]{\\protect\\solutionname}") - if mod == "theorems-bytype": + if mod == "theorems-bytype" or mod == "theorems-ams-bytype": add_to_preamble(document, "\\theoremstyle{definition}\n" \ "\\newtheorem{sol}{\\protect\\solutionname}") i = j -- 2.39.2