Add Question and Question* theorem types (bug #9015)

File format change.
This commit is contained in:
Juergen Spitzmueller 2015-01-09 11:24:45 +01:00
parent 4e1e01361f
commit 706960eba4
6 changed files with 122 additions and 4 deletions

View File

@ -11,6 +11,11 @@ adjustments are made to tex2lyx and bugs are fixed in lyx2lyx.
-----------------------
2015-01-09 Jürgen Spitzmüller <spitz@lyx.org>
* Format incremented to 480:
Add self-defined Question* and Question lemma types to
theorems-ams-extended-bytype module.
2014-08-31 Jürgen Spitzmüller <spitz@lyx.org>
* Format incremented to 479
Support for beamer lemma environment.

View File

@ -33,6 +33,7 @@ Requires amsmath
# - Acknowledgement
# - Conclusion
# - Assumption
# - Question
# We need separate counters for each theorem-like style.
Counter criterion
@ -55,6 +56,8 @@ Counter conclusion
End
Counter assumption
End
Counter question
End
Style Criterion
@ -405,4 +408,38 @@ Style Assumption*
EndBabelPreamble
End
Style Question
CopyStyle Theorem
DependsOn Theorem
LatexName question
LabelString "Question \thequestion."
Preamble
\theoremstyle{plain}
\newtheorem{question}{\protect\questionname}
EndPreamble
LangPreamble
\providecommand{\questionname}{_(Question)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\questionname}{_(Question)}}
EndBabelPreamble
LabelCounter question
End
Style Question*
CopyStyle Theorem*
LatexName question*
LabelString "Question."
Preamble
\theoremstyle{plain}
\newtheorem*{question*}{\protect\questionname}
EndPreamble
LangPreamble
\providecommand{\questionname}{_(Question)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\questionname}{_(Question)}}
EndBabelPreamble
End
Input theorems-refprefix.inc

View File

@ -89,3 +89,8 @@ End
IfStyle Assumption
RefPrefix assu
End
IfStyle Question
RefPrefix que
End

View File

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

View File

@ -412,6 +412,75 @@ def revert_beamer_lemma(document):
i = j
def revert_question_env(document):
"""
Reverts question and question* environments of
theorems-ams-extended-bytype module to ERT
"""
# Do we use theorems-ams-extended-bytype module?
have_mod = False
mods = document.get_module_list()
for mod in mods:
if mod == "theorems-ams-extended-bytype":
have_mod = True
continue
if not have_mod:
return
consecutive = False
i = 0
while True:
i = find_token(document.body, "\\begin_layout Question", i)
if i == -1:
return
starred = document.body[i] == "\\begin_layout Question*"
j = find_end_of_layout(document.body, i)
if j == -1:
document.warning("Malformed LyX document: Can't find end of Question layout")
i += 1
continue
# if this is not a consecutive env, add start command
begcmd = []
if not consecutive:
if starred:
begcmd = put_cmd_in_ert("\\begin{question*}")
else:
begcmd = put_cmd_in_ert("\\begin{question}")
# has this a consecutive theorem of same type?
consecutive = False
if starred:
consecutive = document.body[j + 2] == "\\begin_layout Question*"
else:
consecutive = document.body[j + 2] == "\\begin_layout Question"
# if this is not followed by a consecutive env, add end command
if not consecutive:
if starred:
document.body[j : j + 1] = put_cmd_in_ert("\\end{question*}") + ["\\end_layout"]
else:
document.body[j : j + 1] = put_cmd_in_ert("\\end{question}") + ["\\end_layout"]
document.body[i : i + 1] = ["\\begin_layout Standard", ""] + begcmd
add_to_preamble(document, "\\providecommand{\questionname}{Question}")
if starred:
add_to_preamble(document, "\\theoremstyle{plain}\n" \
"\\newtheorem*{question*}{\\protect\\questionname}")
else:
add_to_preamble(document, "\\theoremstyle{plain}\n" \
"\\newtheorem{question}{\\protect\\questionname}")
i = j
##
# Conversion hub
#
@ -425,10 +494,12 @@ convert = [
[476, []],
[477, []],
[478, []],
[479, []]
[479, []],
[480, []]
]
revert = [
[479, [revert_question_env]],
[478, [revert_beamer_lemma]],
[477, [revert_xarrow]],
[476, [revert_swissgerman]],

View File

@ -36,8 +36,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 479 // spitz: beamer Lemma layout
#define LYX_FORMAT_TEX2LYX 479
#define LYX_FORMAT_LYX 480 // spitz: question and question* environments
#define LYX_FORMAT_TEX2LYX 480
#if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
#ifndef _MSC_VER