theorems-ams: add solution environment

fixes bug #6363 now completely
This commit is contained in:
Uwe Stöhr 2015-11-18 02:36:49 +01:00
parent 029cd69df7
commit 0ae337014e
8 changed files with 81 additions and 3 deletions

View File

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

View File

@ -38,6 +38,8 @@ Counter definition
End
Counter example
End
Counter solution
End
Counter problem
End
Counter exercise

View File

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

View File

@ -58,6 +58,12 @@ End
Style Exercise*
End
Style Solution
End
Style Solution*
End
Style Remark
End

View File

@ -38,6 +38,10 @@ IfStyle Exercise
RefPrefix exer
End
IfStyle Solution
RefPrefix solu
End
IfStyle Remark
RefPrefix rem
End

View File

@ -52,6 +52,13 @@ Style Example
EndPreamble
End
Style Solution
CopyStyle Solution*
DependsOn Solution*
Preamble
EndPreamble
End
Style Problem
CopyStyle Problem*
DependsOn Problem*

View File

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

View File

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