mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 10:58:52 +00:00
theorems.inc: add environment "solution"
fileformat change, fixes bug #6363
This commit is contained in:
parent
017c957a9c
commit
cc6c86ff3b
@ -16,6 +16,7 @@
|
||||
# - Example
|
||||
# - Problem
|
||||
# - Exercise
|
||||
# - Solution
|
||||
# - Remark
|
||||
# - Claim
|
||||
# - Proof
|
||||
@ -240,6 +241,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
|
||||
|
@ -34,6 +34,8 @@ Counter problem
|
||||
End
|
||||
Counter exercise
|
||||
End
|
||||
Counter solution
|
||||
End
|
||||
Counter remark
|
||||
End
|
||||
Counter claim
|
||||
|
@ -15,6 +15,7 @@
|
||||
# - Example
|
||||
# - Problem
|
||||
# - Exercise
|
||||
# - Solution
|
||||
# - Remark
|
||||
# - Claim
|
||||
# - Case (by inclusion)
|
||||
@ -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
|
||||
|
@ -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)),
|
||||
("2_0", list(range(346,414)), minor_versions("2.0" , 8)),
|
||||
("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))
|
||||
]
|
||||
|
||||
####################################################################
|
||||
|
@ -2111,6 +2111,50 @@ def revert_fontsettings(document):
|
||||
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
|
||||
#
|
||||
@ -2146,10 +2190,12 @@ convert = [
|
||||
[498, []],
|
||||
[499, [convert_moderncv]],
|
||||
[500, []],
|
||||
[501, [convert_fontsettings]]
|
||||
[501, [convert_fontsettings]],
|
||||
[502, []]
|
||||
]
|
||||
|
||||
revert = [
|
||||
[501, [revert_solution]],
|
||||
[500, [revert_fontsettings]],
|
||||
[499, [revert_achemso]],
|
||||
[498, [revert_moderncv_1, revert_moderncv_2]],
|
||||
|
@ -1,5 +1,5 @@
|
||||
#LyX file created by tex2lyx 2.2
|
||||
\lyxformat 501
|
||||
\lyxformat 502
|
||||
\begin_document
|
||||
\begin_header
|
||||
\origin roundtrip
|
||||
|
@ -1,5 +1,5 @@
|
||||
#LyX file created by tex2lyx 2.2
|
||||
\lyxformat 501
|
||||
\lyxformat 502
|
||||
\begin_document
|
||||
\begin_header
|
||||
\origin roundtrip
|
||||
|
@ -1,5 +1,5 @@
|
||||
#LyX file created by tex2lyx 2.2
|
||||
\lyxformat 501
|
||||
\lyxformat 502
|
||||
\begin_document
|
||||
\begin_header
|
||||
\origin roundtrip
|
||||
|
@ -1,5 +1,5 @@
|
||||
#LyX file created by tex2lyx 2.2
|
||||
\lyxformat 501
|
||||
\lyxformat 502
|
||||
\begin_document
|
||||
\begin_header
|
||||
\origin roundtrip
|
||||
|
@ -1,5 +1,5 @@
|
||||
#LyX file created by tex2lyx 2.2
|
||||
\lyxformat 501
|
||||
\lyxformat 502
|
||||
\begin_document
|
||||
\begin_header
|
||||
\origin roundtrip
|
||||
|
@ -1,5 +1,5 @@
|
||||
#LyX file created by tex2lyx 2.2
|
||||
\lyxformat 501
|
||||
\lyxformat 502
|
||||
\begin_document
|
||||
\begin_header
|
||||
\origin roundtrip
|
||||
|
@ -1,5 +1,5 @@
|
||||
#LyX file created by tex2lyx 2.2
|
||||
\lyxformat 501
|
||||
\lyxformat 502
|
||||
\begin_document
|
||||
\begin_header
|
||||
\origin roundtrip
|
||||
|
@ -1,5 +1,5 @@
|
||||
#LyX file created by tex2lyx 2.2
|
||||
\lyxformat 501
|
||||
\lyxformat 502
|
||||
\begin_document
|
||||
\begin_header
|
||||
\origin roundtrip
|
||||
|
@ -1,5 +1,5 @@
|
||||
#LyX file created by tex2lyx 2.2
|
||||
\lyxformat 501
|
||||
\lyxformat 502
|
||||
\begin_document
|
||||
\begin_header
|
||||
\origin roundtrip
|
||||
|
@ -1,5 +1,5 @@
|
||||
#LyX file created by tex2lyx 2.2
|
||||
\lyxformat 501
|
||||
\lyxformat 502
|
||||
\begin_document
|
||||
\begin_header
|
||||
\origin roundtrip
|
||||
|
@ -1,5 +1,5 @@
|
||||
#LyX file created by tex2lyx 2.2
|
||||
\lyxformat 501
|
||||
\lyxformat 502
|
||||
\begin_document
|
||||
\begin_header
|
||||
\origin roundtrip
|
||||
|
@ -1,5 +1,5 @@
|
||||
#LyX file created by tex2lyx 2.2
|
||||
\lyxformat 501
|
||||
\lyxformat 502
|
||||
\begin_document
|
||||
\begin_header
|
||||
\origin roundtrip
|
||||
|
@ -1,5 +1,5 @@
|
||||
#LyX file created by tex2lyx 2.2
|
||||
\lyxformat 501
|
||||
\lyxformat 502
|
||||
\begin_document
|
||||
\begin_header
|
||||
\origin roundtrip
|
||||
|
@ -1,5 +1,5 @@
|
||||
#LyX file created by tex2lyx 2.2
|
||||
\lyxformat 501
|
||||
\lyxformat 502
|
||||
\begin_document
|
||||
\begin_header
|
||||
\origin roundtrip
|
||||
|
@ -1,5 +1,5 @@
|
||||
#LyX file created by tex2lyx 2.2
|
||||
\lyxformat 501
|
||||
\lyxformat 502
|
||||
\begin_document
|
||||
\begin_header
|
||||
\origin roundtrip
|
||||
|
@ -1,5 +1,5 @@
|
||||
#LyX file created by tex2lyx 2.2
|
||||
\lyxformat 501
|
||||
\lyxformat 502
|
||||
\begin_document
|
||||
\begin_header
|
||||
\origin roundtrip
|
||||
|
@ -32,8 +32,8 @@ extern char const * const lyx_version_info;
|
||||
|
||||
// Do not remove the comment below, so we get merge conflict in
|
||||
// independent branches. Instead add your own.
|
||||
#define LYX_FORMAT_LYX 501 // gb: store both TeX and non-TeX font selections
|
||||
#define LYX_FORMAT_TEX2LYX 501
|
||||
#define LYX_FORMAT_LYX 502 // uwestoehr: new environment "solution" in theorems
|
||||
#define LYX_FORMAT_TEX2LYX 502
|
||||
|
||||
#if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
|
||||
#ifndef _MSC_VER
|
||||
|
Loading…
Reference in New Issue
Block a user