theorems.inc: add environment "solution"

fileformat change, fixes bug #6363
This commit is contained in:
Uwe Stöhr 2015-11-18 01:14:30 +01:00
parent 017c957a9c
commit cc6c86ff3b
22 changed files with 106 additions and 20 deletions

View File

@ -16,6 +16,7 @@
# - Example # - Example
# - Problem # - Problem
# - Exercise # - Exercise
# - Solution
# - Remark # - Remark
# - Claim # - Claim
# - Proof # - Proof
@ -240,6 +241,25 @@ Style Exercise
End 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 Style Remark
CopyStyle Theorem CopyStyle Theorem
LatexName rem LatexName rem

View File

@ -34,6 +34,8 @@ Counter problem
End End
Counter exercise Counter exercise
End End
Counter solution
End
Counter remark Counter remark
End End
Counter claim Counter claim

View File

@ -15,6 +15,7 @@
# - Example # - Example
# - Problem # - Problem
# - Exercise # - Exercise
# - Solution
# - Remark # - Remark
# - Claim # - Claim
# - Case (by inclusion) # - Case (by inclusion)
@ -232,6 +233,23 @@ Style Exercise
End 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 Style Remark
CopyStyle Theorem CopyStyle Theorem
DependsOn Theorem DependsOn Theorem

View File

@ -85,7 +85,7 @@ format_relation = [("0_06", [200], minor_versions("0.6" , 4)),
("1_6", list(range(277,346)), minor_versions("1.6" , 10)), ("1_6", list(range(277,346)), minor_versions("1.6" , 10)),
("2_0", list(range(346,414)), minor_versions("2.0" , 8)), ("2_0", list(range(346,414)), minor_versions("2.0" , 8)),
("2_1", list(range(414,475)), minor_versions("2.1" , 0)), ("2_1", list(range(414,475)), minor_versions("2.1" , 0)),
("2_2", list(range(475,502)), minor_versions("2.2" , 0)) ("2_2", list(range(475,503)), minor_versions("2.2" , 0))
] ]
#################################################################### ####################################################################

View File

@ -2111,6 +2111,50 @@ def revert_fontsettings(document):
j = j + 1 j = j + 1
def revert_solution(document):
" Reverts the solution environmen of the theorem module to TeX code "
# Do we use theorems-std module?
have_mod = False
mods = document.get_module_list()
for mod in mods:
if mod == "theorems-std" or mod == "theorems-bytype":
have_mod = True
continue
if not have_mod:
return
consecutive = False
i = 0
while True:
i = find_token(document.body, "\\begin_layout Solution", i)
if i == -1:
return
j = find_end_of_layout(document.body, i)
if j == -1:
document.warning("Malformed LyX document: Can't find end of Solution layout")
i += 1
continue
# if this is not a consecutive env, add start command
begcmd = []
if not consecutive:
begcmd = put_cmd_in_ert("\\begin{sol}")
# has this a consecutive theorem of same type?
consecutive = False
consecutive = document.body[j + 2] == "\\begin_layout Solution"
# if this is not followed by a consecutive env, add end command
if not consecutive:
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":
add_to_preamble(document, "\\theoremstyle{plain}\n" \
"\\newtheorem{sol}[thm]{\\protect\\solutionname}")
if mod == "theorems-bytype":
add_to_preamble(document, "\\theoremstyle{definition}\n" \
"\\newtheorem{sol}{\\protect\\solutionname}")
i = j
## ##
# Conversion hub # Conversion hub
# #
@ -2146,10 +2190,12 @@ convert = [
[498, []], [498, []],
[499, [convert_moderncv]], [499, [convert_moderncv]],
[500, []], [500, []],
[501, [convert_fontsettings]] [501, [convert_fontsettings]],
[502, []]
] ]
revert = [ revert = [
[501, [revert_solution]],
[500, [revert_fontsettings]], [500, [revert_fontsettings]],
[499, [revert_achemso]], [499, [revert_achemso]],
[498, [revert_moderncv_1, revert_moderncv_2]], [498, [revert_moderncv_1, revert_moderncv_2]],

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2 #LyX file created by tex2lyx 2.2
\lyxformat 501 \lyxformat 502
\begin_document \begin_document
\begin_header \begin_header
\origin roundtrip \origin roundtrip

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2 #LyX file created by tex2lyx 2.2
\lyxformat 501 \lyxformat 502
\begin_document \begin_document
\begin_header \begin_header
\origin roundtrip \origin roundtrip

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2 #LyX file created by tex2lyx 2.2
\lyxformat 501 \lyxformat 502
\begin_document \begin_document
\begin_header \begin_header
\origin roundtrip \origin roundtrip

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2 #LyX file created by tex2lyx 2.2
\lyxformat 501 \lyxformat 502
\begin_document \begin_document
\begin_header \begin_header
\origin roundtrip \origin roundtrip

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2 #LyX file created by tex2lyx 2.2
\lyxformat 501 \lyxformat 502
\begin_document \begin_document
\begin_header \begin_header
\origin roundtrip \origin roundtrip

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2 #LyX file created by tex2lyx 2.2
\lyxformat 501 \lyxformat 502
\begin_document \begin_document
\begin_header \begin_header
\origin roundtrip \origin roundtrip

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2 #LyX file created by tex2lyx 2.2
\lyxformat 501 \lyxformat 502
\begin_document \begin_document
\begin_header \begin_header
\origin roundtrip \origin roundtrip

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2 #LyX file created by tex2lyx 2.2
\lyxformat 501 \lyxformat 502
\begin_document \begin_document
\begin_header \begin_header
\origin roundtrip \origin roundtrip

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2 #LyX file created by tex2lyx 2.2
\lyxformat 501 \lyxformat 502
\begin_document \begin_document
\begin_header \begin_header
\origin roundtrip \origin roundtrip

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2 #LyX file created by tex2lyx 2.2
\lyxformat 501 \lyxformat 502
\begin_document \begin_document
\begin_header \begin_header
\origin roundtrip \origin roundtrip

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2 #LyX file created by tex2lyx 2.2
\lyxformat 501 \lyxformat 502
\begin_document \begin_document
\begin_header \begin_header
\origin roundtrip \origin roundtrip

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2 #LyX file created by tex2lyx 2.2
\lyxformat 501 \lyxformat 502
\begin_document \begin_document
\begin_header \begin_header
\origin roundtrip \origin roundtrip

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2 #LyX file created by tex2lyx 2.2
\lyxformat 501 \lyxformat 502
\begin_document \begin_document
\begin_header \begin_header
\origin roundtrip \origin roundtrip

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2 #LyX file created by tex2lyx 2.2
\lyxformat 501 \lyxformat 502
\begin_document \begin_document
\begin_header \begin_header
\origin roundtrip \origin roundtrip

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2 #LyX file created by tex2lyx 2.2
\lyxformat 501 \lyxformat 502
\begin_document \begin_document
\begin_header \begin_header
\origin roundtrip \origin roundtrip

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2 #LyX file created by tex2lyx 2.2
\lyxformat 501 \lyxformat 502
\begin_document \begin_document
\begin_header \begin_header
\origin roundtrip \origin roundtrip

View File

@ -32,8 +32,8 @@ extern char const * const lyx_version_info;
// Do not remove the comment below, so we get merge conflict in // Do not remove the comment below, so we get merge conflict in
// independent branches. Instead add your own. // independent branches. Instead add your own.
#define LYX_FORMAT_LYX 501 // gb: store both TeX and non-TeX font selections #define LYX_FORMAT_LYX 502 // uwestoehr: new environment "solution" in theorems
#define LYX_FORMAT_TEX2LYX 501 #define LYX_FORMAT_TEX2LYX 502
#if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX #if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
#ifndef _MSC_VER #ifndef _MSC_VER