Better fix for bug 1476 (following an idea by Jean-Marc).

Don't go into an endless loop if layout2layout cannot produce the desired file format.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@28529 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Georg Baum 2009-02-17 20:25:56 +00:00
parent ce09b10450
commit 9aad4bc27f
17 changed files with 771 additions and 166 deletions

View File

@ -108,9 +108,9 @@ End
\papercolumns 1
\papersides 2
\paperpagestyle headings
\tracking_changes false
\tracking_changes true
\output_changes false
\author ""
\author "Georg Baum,,,"
\author ""
\end_header
@ -6881,7 +6881,23 @@ int
] This tag was introduced with LyX 1.4.0 (layout files of LyX 1.3.x and earlier
don't have an explicit file format).
The file format that is documented here is format 12.
The file format that is documented here is format 1
\change_deleted 0 1234611237
2
\change_inserted 0 1234611237
4
\change_unchanged
.
\change_inserted 0 1234613411
\end_layout
\begin_layout Description
\change_inserted 0 1234613417
FIXME: Format 13 is missing!
\change_unchanged
\end_layout
\begin_layout Subsection
@ -8906,7 +8922,13 @@ FreeSpacing
status collapsed
\begin_layout Plain Layout
I18NPreamble
\change_inserted 0 1234613251
Babel
\change_deleted 0 1234611266
I18N
\change_unchanged
Preamble
\end_layout
\end_inset
@ -8918,7 +8940,13 @@ I18NPreamble
status collapsed
\begin_layout Plain Layout
I18NPreamble
\change_inserted 0 1234613436
Babel
\change_deleted 0 1234611275
I18N
\change_unchanged
Preamble
\end_layout
\end_inset
@ -8933,7 +8961,13 @@ I18NPreamble
status collapsed
\begin_layout Plain Layout
EndI18NPreamble
End
\change_deleted 0 1234611280
I18N
\change_inserted 0 1234613262
Babel
\change_unchanged
Preamble
\end_layout
\end_inset
@ -8983,8 +9017,72 @@ _()
replaces its argument by the translation of the argument to the current
language.
\change_inserted 0 1234611470
\end_layout
\begin_layout Standard
\change_inserted 0 1234615134
This preamble snippet will only be used if the document contains more than
one language and the babel package is used.
\change_unchanged
\end_layout
\end_deeper
\begin_layout Description
\change_inserted 0 1234614203
\begin_inset Flex CharStyle:Code
status collapsed
\begin_layout Plain Layout
\change_inserted 0 1234614202
LangPreamble
\end_layout
\end_inset
Like
\begin_inset Flex CharStyle:Code
status collapsed
\begin_layout Plain Layout
\change_inserted 0 1234614202
BabelPreamble
\end_layout
\end_inset
, but this preamble snippet occurs independently from the babel package,
and only for the document language.
Must end with
\begin_inset Quotes eld
\end_inset
\begin_inset Flex CharStyle:Code
status collapsed
\begin_layout Plain Layout
\change_inserted 0 1234614202
EndLangPreamble
\end_layout
\end_inset
\begin_inset Quotes erd
\end_inset
.
\end_layout
\begin_deeper
\begin_layout Standard
If the style defines text that appears in the typeset document, it may use
@ -8992,12 +9090,38 @@ If the style defines text that appears in the typeset document, it may use
status collapsed
\begin_layout Plain Layout
I18NPreamble
\change_inserted 0 1234611302
Lang
\change_deleted 0 1234611306
I18N
\change_unchanged
Preamble
\end_layout
\end_inset
to support non-english and even multilanguage documents correctly.
\change_inserted 0 1234611823
and
\change_unchanged
\change_inserted 0 1234611832
\begin_inset Flex CharStyle:Code
status collapsed
\begin_layout Plain Layout
\change_inserted 0 1234611838
BabelPreamble
\end_layout
\end_inset
\change_unchanged
to support non-english and even multilanguage documents correctly.
The following excerpt (from the
\begin_inset Flex CharStyle:Code
status collapsed
@ -9017,6 +9141,8 @@ Preamble
\begin_layout LyX-Code
\change_deleted 0 1234612061
\backslash
providecommand{
\backslash
@ -9044,11 +9170,47 @@ EndPreamble
\end_layout
\begin_layout LyX-Code
I18nPreamble
\change_inserted 0 1234612037
LangPreamble
\end_layout
\begin_layout LyX-Code
\change_inserted 0 1234612045
\backslash
providecommand{
\backslash
claimname}{_(Claim)}
\end_layout
\begin_layout LyX-Code
\change_inserted 0 1234611897
\end_layout
\begin_layout LyX-Code
\change_inserted 0 1234612050
EndLangPreamble
\end_layout
\begin_layout LyX-Code
\change_inserted 0 1234611892
Babel
\change_deleted 0 1234611847
I18n
\change_unchanged
Preamble
\end_layout
\begin_layout LyX-Code
\change_deleted 0 1234612079
\backslash
AtBeginDocument{
\backslash
@ -9072,17 +9234,29 @@ captions$$lang{
\backslash
renewcommand{
\backslash
claimname}{_(Claim)}}%
claimname}{_(Claim)}}
\change_deleted 0 1234612086
%
\end_layout
\begin_layout LyX-Code
\change_deleted 0 1234612089
\backslash
fi}
\change_unchanged
\end_layout
\begin_layout LyX-Code
EndI18nPreamble
End
\change_inserted 0 1234611859
Babel
\change_deleted 0 1234611856
I18n
\change_unchanged
Preamble
\end_layout
\begin_layout Standard
@ -9099,14 +9273,26 @@ claimname
\end_inset
in the standard preamble.
in the
\change_inserted 0 1234612144
language
\change_deleted 0 1234612146
standard
\change_unchanged
preamble.
This command holds the name of the theorem that will appear in the output.
The
\begin_inset Flex CharStyle:Code
status collapsed
\begin_layout Plain Layout
I18NPreamble
\change_inserted 0 1234612157
Babel
\change_deleted 0 1234612155
I18N
\change_unchanged
Preamble
\end_layout
\end_inset
@ -9123,7 +9309,13 @@ claimname
\end_inset
for each used language.
for each used language
\change_inserted 0 1234622073
in multilanguage documents
\change_unchanged
.
\change_deleted 0 1234612171
The
\begin_inset Flex CharStyle:Code
status collapsed
@ -9153,6 +9345,8 @@ AtBeginDocument
\end_inset
.
\change_unchanged
\end_layout
\end_deeper

View File

@ -14,7 +14,7 @@
# Tinkered with Sep. '07 by Paul Rubin <rubin@msu.edu>
# Modularized Jan 08 by Richard Heck <rgheck@comcast.net>
Format 11
Format 14
Requires amsmath
@ -39,8 +39,14 @@ Style Criterion
LabelString "Criterion \thetheorem."
Preamble
\theoremstyle{plain}
\newtheorem{criterion}[thm]{Criterion}
\newtheorem{criterion}[thm]{\protect\criterionname}
EndPreamble
LangPreamble
\providecommand{\criterionname}{_(Criterion)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\criterionname}{_(Criterion)}}
EndBabelPreamble
End
Style Criterion*
@ -49,8 +55,14 @@ Style Criterion*
LabelString "Criterion."
Preamble
\theoremstyle{plain}
\newtheorem*{criterion*}{Criterion}
\newtheorem*{criterion*}{\protect\criterionname}
EndPreamble
LangPreamble
\providecommand{\criterionname}{_(Criterion)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\criterionname}{_(Criterion)}}
EndBabelPreamble
End
@ -61,8 +73,14 @@ Style Algorithm
LabelString "Algorithm \thetheorem."
Preamble
\theoremstyle{plain}
\newtheorem{algorithm}[thm]{Algorithm}
\newtheorem{algorithm}[thm]{\protect\algorithmname}
EndPreamble
LangPreamble
\providecommand{\algorithmname}{_(Algorithm)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\algorithmname}{_(Algorithm)}}
EndBabelPreamble
End
@ -72,8 +90,14 @@ Style Algorithm*
LabelString "Algorithm."
Preamble
\theoremstyle{plain}
\newtheorem*{algorithm*}{Algorithm}
\newtheorem*{algorithm*}{\protect\algorithmname}
EndPreamble
LangPreamble
\providecommand{\algorithmname}{_(Algorithm)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\algorithmname}{_(Algorithm)}}
EndBabelPreamble
End
@ -84,8 +108,14 @@ Style Axiom
LabelString "Axiom \thetheorem."
Preamble
\theoremstyle{plain}
\newtheorem{ax}[thm]{Axiom}
\newtheorem{ax}[thm]{\protect\axiomname}
EndPreamble
LangPreamble
\providecommand{\axiomname}{_(Axiom)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\axiomname}{_(Axiom)}}
EndBabelPreamble
End
@ -95,8 +125,14 @@ Style Axiom*
LabelString "Axiom."
Preamble
\theoremstyle{plain}
\newtheorem*{ax*}{Axiom}
\newtheorem*{ax*}{\protect\axiomname}
EndPreamble
LangPreamble
\providecommand{\axiomname}{_(Axiom)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\axiomname}{_(Axiom)}}
EndBabelPreamble
End
@ -106,8 +142,14 @@ Style Condition
LabelString "Condition \thetheorem."
Preamble
\theoremstyle{definition}
\newtheorem{condition}[thm]{Condition}
\newtheorem{condition}[thm]{\protect\conditionname}
EndPreamble
LangPreamble
\providecommand{\conditionname}{_(Condition)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\conditionname}{_(Condition)}}
EndBabelPreamble
End
@ -117,8 +159,14 @@ Style Condition*
LabelString "Condition."
Preamble
\theoremstyle{definition}
\newtheorem*{condition*}{Condition}
\newtheorem*{condition*}{\protect\conditionname}
EndPreamble
LangPreamble
\providecommand{\conditionname}{_(Condition)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\conditionname}{_(Condition)}}
EndBabelPreamble
End
@ -128,8 +176,14 @@ Style Note
LabelString "Note \thetheorem."
Preamble
\theoremstyle{remark}
\newtheorem{note}[thm]{Note}
\newtheorem{note}[thm]{\protect\notename}
EndPreamble
LangPreamble
\providecommand{\notename}{_(Note)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\notename}{_(Note)}}
EndBabelPreamble
End
@ -139,8 +193,14 @@ Style Note*
LabelString "Note."
Preamble
\theoremstyle{remark}
\newtheorem*{note*}{Note}
\newtheorem*{note*}{\protect\notename}
EndPreamble
LangPreamble
\providecommand{\notename}{_(Note)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\notename}{_(Note)}}
EndBabelPreamble
End
@ -150,8 +210,14 @@ Style Notation
LabelString "Notation \thetheorem."
Preamble
\theoremstyle{remark}
\newtheorem{notation}[thm]{Notation}
\newtheorem{notation}[thm]{\protect\notationname}
EndPreamble
LangPreamble
\providecommand{\notationname}{_(Notation)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\notationname}{_(Notation)}}
EndBabelPreamble
End
@ -161,8 +227,14 @@ Style Notation*
LabelString "Notation."
Preamble
\theoremstyle{remark}
\newtheorem*{notation*}{Notation}
\newtheorem*{notation*}{\protect\notationname}
EndPreamble
LangPreamble
\providecommand{\notationname}{_(Notation)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\notationname}{_(Notation)}}
EndBabelPreamble
End
@ -172,8 +244,14 @@ Style Summary
LabelString "Summary \thetheorem."
Preamble
\theoremstyle{remark}
\newtheorem{summary}[thm]{Summary}
\newtheorem{summary}[thm]{\protect\summaryname}
EndPreamble
LangPreamble
\providecommand{\summaryname}{_(Summary)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\summaryname}{_(Summary)}}
EndBabelPreamble
End
@ -183,8 +261,14 @@ Style Summary*
LabelString "Summary."
Preamble
\theoremstyle{remark}
\newtheorem*{summary*}{Summary}
\newtheorem*{summary*}{\protect\summaryname}
EndPreamble
LangPreamble
\providecommand{\summaryname}{_(Summary)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\summaryname}{_(Summary)}}
EndBabelPreamble
End
@ -194,8 +278,14 @@ Style Acknowledgement
LabelString "Acknowledgement \thetheorem."
Preamble
\theoremstyle{remark}
\newtheorem{acknowledgement}[thm]{Acknowledgement}
\newtheorem{acknowledgement}[thm]{\protect\acknowledgementname}
EndPreamble
LangPreamble
\providecommand{\acknowledgementname}{_(Acknowledgement)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\acknowledgementname}{_(Acknowledgement)}}
EndBabelPreamble
End
@ -205,8 +295,14 @@ Style Acknowledgement*
LabelString "Acknowledgement."
Preamble
\theoremstyle{remark}
\newtheorem*{acknowledgement*}{Acknowledgement}
\newtheorem*{acknowledgement*}{\protect\acknowledgementname}
EndPreamble
LangPreamble
\providecommand{\acknowledgementname}{_(Acknowledgement)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\acknowledgementname}{_(Acknowledgement)}}
EndBabelPreamble
End
@ -216,8 +312,14 @@ Style Conclusion
LabelString "Conclusion \thetheorem."
Preamble
\theoremstyle{remark}
\newtheorem{conclusion}[thm]{Conclusion}
\newtheorem{conclusion}[thm]{\protect\conclusionname}
EndPreamble
LangPreamble
\providecommand{\conclusionname}{_(Conclusion)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\conclusionname}{_(Conclusion)}}
EndBabelPreamble
End
@ -227,8 +329,14 @@ Style Conclusion*
LabelString "Conclusion."
Preamble
\theoremstyle{remark}
\newtheorem*{conclusion*}{Conclusion}
\newtheorem*{conclusion*}{\protect\conclusionname}
EndPreamble
LangPreamble
\providecommand{\conclusionname}{_(Conclusion)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\conclusionname}{_(Conclusion)}}
EndBabelPreamble
End
@ -239,8 +347,14 @@ Style Assumption
LabelString "Assumption \thetheorem."
Preamble
\theoremstyle{plain}
\newtheorem{assumption}[thm]{Assumption}
\newtheorem{assumption}[thm]{\protect\assumptionname}
EndPreamble
LangPreamble
\providecommand{\assumptionname}{_(Assumption)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\assumptionname}{_(Assumption)}}
EndBabelPreamble
End
@ -250,8 +364,14 @@ Style Assumption*
LabelString "Assumption."
Preamble
\theoremstyle{plain}
\newtheorem*{assumption*}{Assumption}
\newtheorem*{assumption*}{\protect\assumptionname}
EndPreamble
LangPreamble
\providecommand{\assumptionname}{_(Assumption)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\assumptionname}{_(Assumption)}}
EndBabelPreamble
End
Style Question
@ -261,8 +381,14 @@ Style Question
LabelString "Question \thetheorem."
Preamble
\theoremstyle{plain}
\newtheorem{question}[thm]{Question}
\newtheorem{question}[thm]{\protect\questionname}
EndPreamble
LangPreamble
\providecommand{\questionname}{_(Question)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\questionname}{_(Question)}}
EndBabelPreamble
End
Style Question*
@ -271,6 +397,12 @@ Style Question*
LabelString "Question."
Preamble
\theoremstyle{plain}
\newtheorem*{question*}{Question}
\newtheorem*{question*}{\protect\questionname}
EndPreamble
LangPreamble
\providecommand{\questionname}{_(Question)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\questionname}{_(Question)}}
EndBabelPreamble
End

View File

@ -19,7 +19,7 @@
# - Proof
# - Case (regular only -- defined as an enumeration)
Format 12
Format 14
Style Theorem
Category Theorem
@ -49,13 +49,15 @@ Style Theorem
Series Bold
EndFont
Preamble
\providecommand{\theoremname}{Theorem}
\theoremstyle{plain}
\newtheorem{thm}{\protect\theoremname}
EndPreamble
I18nPreamble
\AtBeginDocument{\ifx\LdfInit\undefined\relax\else\addto\captions$$lang{\renewcommand{\theoremname}{_(Theorem)}}\fi}
EndI18nPreamble
LangPreamble
\providecommand{\theoremname}{_(Theorem)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\theoremname}{_(Theorem)}}
EndBabelPreamble
Requires amsthm
End
@ -66,13 +68,15 @@ Style Corollary
LatexName cor
LabelString "Corollary \thetheorem."
Preamble
\providecommand{\corollaryname}{Corollary}
\theoremstyle{plain}
\newtheorem{cor}[thm]{\protect\corollaryname}
EndPreamble
I18nPreamble
\AtBeginDocument{\ifx\LdfInit\undefined\relax\else\addto\captions$$lang{\renewcommand{\corollaryname}{_(Corollary)}}\fi}
EndI18nPreamble
LangPreamble
\providecommand{\corollaryname}{_(Corollary)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\corollaryname}{_(Corollary)}}
EndBabelPreamble
End
@ -82,13 +86,15 @@ Style Lemma
LatexName lem
LabelString "Lemma \thetheorem."
Preamble
\providecommand{\lemmaname}{Lemma}
\theoremstyle{plain}
\newtheorem{lem}[thm]{\protect\lemmaname}
EndPreamble
I18nPreamble
\AtBeginDocument{\ifx\LdfInit\undefined\relax\else\addto\captions$$lang{\renewcommand{\lemmaname}{_(Lemma)}}\fi}
EndI18nPreamble
LangPreamble
\providecommand{\lemmaname}{_(Lemma)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\lemmaname}{_(Lemma)}}
EndBabelPreamble
End
@ -98,13 +104,15 @@ Style Proposition
LatexName prop
LabelString "Proposition \thetheorem."
Preamble
\providecommand{\propositionname}{Proposition}
\theoremstyle{plain}
\newtheorem{prop}[thm]{\protect\propositionname}
EndPreamble
I18nPreamble
\AtBeginDocument{\ifx\LdfInit\undefined\relax\else\addto\captions$$lang{\renewcommand{\propositionname}{_(Proposition)}}\fi}
EndI18nPreamble
LangPreamble
\providecommand{\propositionname}{_(Proposition)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\propositionname}{_(Proposition)}}
EndBabelPreamble
End
@ -114,13 +122,15 @@ Style Conjecture
LatexName conjecture
LabelString "Conjecture \thetheorem."
Preamble
\providecommand{\conjecturename}{Conjecture}
\theoremstyle{plain}
\newtheorem{conjecture}[thm]{\protect\conjecturename}
EndPreamble
I18nPreamble
\AtBeginDocument{\ifx\LdfInit\undefined\relax\else\addto\captions$$lang{\renewcommand{\conjecturename}{_(Conjecture)}}\fi}
EndI18nPreamble
LangPreamble
\providecommand{\conjecturename}{_(Conjecture)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\conjecturename}{_(Conjecture)}}
EndBabelPreamble
End
@ -130,13 +140,15 @@ Style Fact
LatexName fact
LabelString "Fact \thetheorem."
Preamble
\providecommand{\factname}{Fact}
\theoremstyle{plain}
\newtheorem{fact}[thm]{\protect\factname}
EndPreamble
I18nPreamble
\AtBeginDocument{\ifx\LdfInit\undefined\relax\else\addto\captions$$lang{\renewcommand{\factname}{_(Fact)}}\fi}
EndI18nPreamble
LangPreamble
\providecommand{\factname}{_(Fact)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\factname}{_(Fact)}}
EndBabelPreamble
End
@ -153,13 +165,15 @@ Style Definition
Series Bold
EndFont
Preamble
\providecommand{\definitionname}{Definition}
\theoremstyle{definition}
\newtheorem{defn}[thm]{\protect\definitionname}
EndPreamble
I18nPreamble
\AtBeginDocument{\ifx\LdfInit\undefined\relax\else\addto\captions$$lang{\renewcommand{\definitionname}{_(Definition)}}\fi}
EndI18nPreamble
LangPreamble
\providecommand{\definitionname}{_(Definition)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\definitionname}{_(Definition)}}
EndBabelPreamble
End
@ -168,13 +182,15 @@ Style Example
LatexName example
LabelString "Example \thetheorem."
Preamble
\providecommand{\examplename}{Example}
\theoremstyle{definition}
\newtheorem{example}[thm]{\protect\examplename}
EndPreamble
I18nPreamble
\AtBeginDocument{\ifx\LdfInit\undefined\relax\else\addto\captions$$lang{\renewcommand{\examplename}{_(Example)}}\fi}
EndI18nPreamble
LangPreamble
\providecommand{\examplename}{_(Example)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\examplename}{_(Example)}}
EndBabelPreamble
End
@ -183,13 +199,15 @@ Style Problem
LatexName problem
LabelString "Problem \thetheorem."
Preamble
\providecommand{\problemname}{Problem}
\theoremstyle{definition}
\newtheorem{problem}[thm]{\protect\problemname}
EndPreamble
I18nPreamble
\AtBeginDocument{\ifx\LdfInit\undefined\relax\else\addto\captions$$lang{\renewcommand{\problemname}{_(Problem)}}\fi}
EndI18nPreamble
LangPreamble
\providecommand{\problemname}{_(Problem)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\problemname}{_(Problem)}}
EndBabelPreamble
End
@ -198,13 +216,15 @@ Style Exercise
LatexName xca
LabelString "Exercise \thetheorem."
Preamble
\providecommand{\exercisename}{Exercise}
\theoremstyle{definition}
\newtheorem{xca}[thm]{\protect\exercisename}
EndPreamble
I18nPreamble
\AtBeginDocument{\ifx\LdfInit\undefined\relax\else\addto\captions$$lang{\renewcommand{\exercisename}{_(Exercise)}}\fi}
EndI18nPreamble
LangPreamble
\providecommand{\exercisename}{_(Exercise)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\exercisename}{_(Exercise)}}
EndBabelPreamble
End
@ -222,13 +242,15 @@ Style Remark
Shape Italic
EndFont
Preamble
\providecommand{\remarkname}{Remark}
\theoremstyle{remark}
\newtheorem{rem}[thm]{\protect\remarkname}
EndPreamble
I18nPreamble
\AtBeginDocument{\ifx\LdfInit\undefined\relax\else\addto\captions$$lang{\renewcommand{\remarkname}{_(Remark)}}\fi}
EndI18nPreamble
LangPreamble
\providecommand{\remarkname}{_(Remark)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\remarkname}{_(Remark)}}
EndBabelPreamble
End
@ -237,13 +259,15 @@ Style Claim
LatexName claim
LabelString "Claim \thetheorem."
Preamble
\providecommand{\claimname}{Claim}
\theoremstyle{remark}
\newtheorem{claim}[thm]{\protect\claimname}
EndPreamble
I18nPreamble
\AtBeginDocument{\ifx\LdfInit\undefined\relax\else\addto\captions$$lang{\renewcommand{\claimname}{_(Claim)}}\fi}
EndI18nPreamble
LangPreamble
\providecommand{\claimname}{_(Claim)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\claimname}{_(Claim)}}
EndBabelPreamble
End
@ -270,7 +294,6 @@ Style Case
Shape Italic
EndFont
Preamble
\providecommand{\casename}{Case}
\newcounter{casectr}
\newenvironment{caseenv}
{\begin{list}{{\itshape\ \protect\casename} \arabic{casectr}.}{%
@ -283,7 +306,10 @@ Style Case
\usecounter{casectr}}
{\end{list}}
EndPreamble
I18nPreamble
\AtBeginDocument{\ifx\LdfInit\undefined\relax\else\addto\captions$$lang{\renewcommand{\casename}{_(Case)}}\fi}
EndI18nPreamble
LangPreamble
\providecommand{\casename}{_(Case)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\casename}{_(Case)}}
EndBabelPreamble
End

View File

@ -8,7 +8,7 @@
# Author: Richard Heck <rgheck@comcast.net>
Format 11
Format 14
Counter theorem
Within chapter
@ -17,9 +17,15 @@ End
Style Theorem
Preamble
\ifx\thechapter\undefined
\newtheorem{thm}{Theorem}
\newtheorem{thm}{\protect\theoremname}
\else
\newtheorem{thm}{Theorem}[chapter]
\newtheorem{thm}{\protect\theoremname}[chapter]
\fi
EndPreamble
LangPreamble
\providecommand{\theoremname}{_(Theorem)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\theoremname}{_(Theorem)}}
EndBabelPreamble
End

View File

@ -7,7 +7,7 @@
# Author: Richard Heck <rgheck@comcast.net>
Format 11
Format 14
Counter theorem
Within section
@ -15,6 +15,12 @@ End
Style Theorem
Preamble
\newtheorem{thm}{Theorem}[section]
\newtheorem{thm}{\protect\theoremname}[section]
EndPreamble
LangPreamble
\providecommand{\theoremname}{_(Theorem)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\theoremname}{_(Theorem)}}
EndBabelPreamble
End

View File

@ -18,7 +18,7 @@
# - Claim
# - Proof
Format 11
Format 14
Style Theorem*
Category Theorem
@ -48,8 +48,14 @@ Style Theorem*
EndFont
Preamble
\theoremstyle{plain}
\newtheorem*{thm*}{Theorem}
\newtheorem*{thm*}{\protect\theoremname}
EndPreamble
LangPreamble
\providecommand{\theoremname}{_(Theorem)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\theoremname}{_(Theorem)}}
EndBabelPreamble
Requires amsthm
End
@ -60,9 +66,14 @@ Style Corollary*
LabelString "Corollary."
Preamble
\theoremstyle{plain}
\newtheorem*{cor*}{Corollary}
\newtheorem*{cor*}{\protect\corollaryname}
EndPreamble
Requires amsthm
LangPreamble
\providecommand{\corollaryname}{_(Corollary)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\corollaryname}{_(Corollary)}}
EndBabelPreamble
End
@ -72,9 +83,14 @@ Style Lemma*
LabelString "Lemma."
Preamble
\theoremstyle{plain}
\newtheorem*{lem*}{Lemma}
\newtheorem*{lem*}{\protect\lemmaname}
EndPreamble
Requires amsthm
LangPreamble
\providecommand{\lemmaname}{_(Lemma)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\lemmaname}{_(Lemma)}}
EndBabelPreamble
End
@ -84,9 +100,14 @@ Style Proposition*
LabelString "Proposition."
Preamble
\theoremstyle{plain}
\newtheorem*{prop*}{Proposition}
\newtheorem*{prop*}{\protect\propositionname}
EndPreamble
Requires amsthm
LangPreamble
\providecommand{\propositionname}{_(Proposition)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\propositionname}{_(Proposition)}}
EndBabelPreamble
End
@ -96,9 +117,14 @@ Style Conjecture*
LabelString "Conjecture."
Preamble
\theoremstyle{plain}
\newtheorem*{conjecture*}{Conjecture}
\newtheorem*{conjecture*}{\protect\conjecturename}
EndPreamble
Requires amsthm
LangPreamble
\providecommand{\conjecturename}{_(Conjecture)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\conjecturename}{_(Conjecture)}}
EndBabelPreamble
End
@ -108,9 +134,14 @@ Style Fact*
LabelString "Fact."
Preamble
\theoremstyle{plain}
\newtheorem*{fact*}{Fact}
\newtheorem*{fact*}{\protect\factname}
EndPreamble
Requires amsthm
LangPreamble
\providecommand{\factname}{_(Fact)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\factname}{_(Fact)}}
EndBabelPreamble
End
@ -128,9 +159,14 @@ Style Definition*
EndFont
Preamble
\theoremstyle{definition}
\newtheorem*{defn*}{Definition}
\newtheorem*{defn*}{\protect\definitionname}
EndPreamble
Requires amsthm
LangPreamble
\providecommand{\definitionname}{_(Definition)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\definitionname}{_(Definition)}}
EndBabelPreamble
End
@ -140,9 +176,14 @@ Style Example*
LabelString "Example."
Preamble
\theoremstyle{definition}
\newtheorem*{example*}{Example}
\newtheorem*{example*}{\protect\examplename}
EndPreamble
Requires amsthm
LangPreamble
\providecommand{\examplename}{_(Example)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\examplename}{_(Example)}}
EndBabelPreamble
End
@ -152,9 +193,14 @@ Style Problem*
LabelString "Problem."
Preamble
\theoremstyle{definition}
\newtheorem*{problem*}{Problem}
\newtheorem*{problem*}{\protect\problemname}
EndPreamble
Requires amsthm
LangPreamble
\providecommand{\problemname}{_(Problem)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\problemname}{_(Problem)}}
EndBabelPreamble
End
@ -164,9 +210,14 @@ Style Exercise*
LabelString "Exercise."
Preamble
\theoremstyle{definition}
\newtheorem*{xca*}{Exercise}
\newtheorem*{xca*}{\protect\exercisename}
EndPreamble
Requires amsthm
LangPreamble
\providecommand{\exercisename}{_(Exercise)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\exercisename}{_(Exercise)}}
EndBabelPreamble
End
@ -184,9 +235,14 @@ Style Remark*
EndFont
Preamble
\theoremstyle{remark}
\newtheorem*{rem*}{Remark}
\newtheorem*{rem*}{\protect\remarkname}
EndPreamble
Requires amsthm
LangPreamble
\providecommand{\remarkname}{_(Remark)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\remarkname}{_(Remark)}}
EndBabelPreamble
End
@ -196,8 +252,13 @@ Style Claim*
LabelString "Claim."
Preamble
\theoremstyle{remark}
\newtheorem*{claim*}{Claim}
\newtheorem*{claim*}{\protect\claimname}
EndPreamble
Requires amsthm
LangPreamble
\providecommand{\claimname}{_(Claim)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\claimname}{_(Claim)}}
EndBabelPreamble
End

View File

@ -8,7 +8,7 @@
# Author: Richard Heck <rgheck@comcast.net>
Format 11
Format 14
Counter theorem
End
@ -20,7 +20,7 @@ Input theorems-proof.inc
Style Proof
Preamble
\ifx\proof\undefined\
\newenvironment{proof}[1][\proofname]{\par
\newenvironment{proof}[1][\protect\proofname]{\par
\normalfont\topsep6\p@\@plus6\p@\relax
\trivlist
\itemindent\parindent
@ -30,7 +30,12 @@ Style Proof
}{%
\endtrivlist\@endpefalse
}
\providecommand{\proofname}{Proof}
\fi
EndPreamble
LangPreamble
\providecommand{\proofname}{_(Proof)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\proofname}{_(Proof)}}
EndBabelPreamble
End

View File

@ -19,7 +19,7 @@
# - Proof
# - Case (regular only -- defined as an enumeration)
Format 11
Format 14
Style Theorem
Category Theorem
@ -49,8 +49,14 @@ Style Theorem
Series Bold
EndFont
Preamble
\newtheorem{thm}{Theorem}
\newtheorem{thm}{\protect\theoremname}
EndPreamble
LangPreamble
\providecommand{\theoremname}{_(Theorem)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\theoremname}{_(Theorem)}}
EndBabelPreamble
Requires amsthm
End
@ -61,8 +67,14 @@ Style Corollary
LatexName cor
LabelString "Corollary \thetheorem."
Preamble
\newtheorem{cor}[thm]{Corollary}
\newtheorem{cor}[thm]{\protect\corollaryname}
EndPreamble
LangPreamble
\providecommand{\corollaryname}{_(Corollary)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\corollaryname}{_(Corollary)}}
EndBabelPreamble
End
@ -72,8 +84,14 @@ Style Lemma
LatexName lem
LabelString "Lemma \thetheorem."
Preamble
\newtheorem{lem}[thm]{Lemma}
\newtheorem{lem}[thm]{\protect\lemmaname}
EndPreamble
LangPreamble
\providecommand{\lemmaname}{_(Lemma)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\lemmaname}{_(Lemma)}}
EndBabelPreamble
End
@ -83,8 +101,14 @@ Style Proposition
LatexName prop
LabelString "Proposition \thetheorem."
Preamble
\newtheorem{prop}[thm]{Proposition}
\newtheorem{prop}[thm]{\protect\propositionname}
EndPreamble
LangPreamble
\providecommand{\propositionname}{_(Proposition)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\propositionname}{_(Proposition)}}
EndBabelPreamble
End
@ -94,8 +118,14 @@ Style Conjecture
LatexName conjecture
LabelString "Conjecture \thetheorem."
Preamble
\newtheorem{conjecture}[thm]{Conjecture}
\newtheorem{conjecture}[thm]{\protect\conjecturename}
EndPreamble
LangPreamble
\providecommand{\conjecturename}{_(Conjecture)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\conjecturename}{_(Conjecture)}}
EndBabelPreamble
End
@ -105,8 +135,14 @@ Style Fact
LatexName fact
LabelString "Fact \thetheorem."
Preamble
\newtheorem{fact}[thm]{Fact}
\newtheorem{fact}[thm]{\protect\factname}
EndPreamble
LangPreamble
\providecommand{\factname}{_(Fact)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\factname}{_(Fact)}}
EndBabelPreamble
End
@ -124,8 +160,14 @@ Style Definition
EndFont
Preamble
\theoremstyle{definition}
\newtheorem{defn}[thm]{Definition}
\newtheorem{defn}[thm]{\protect\definitionname}
EndPreamble
LangPreamble
\providecommand{\definitionname}{_(Definition)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\definitionname}{_(Definition)}}
EndBabelPreamble
End
@ -135,9 +177,14 @@ Style Example
LabelString "Example \thetheorem."
Preamble
\theoremstyle{definition}
\newtheorem{example}[thm]{Example}
\newtheorem{example}[thm]{\protect\examplename}
EndPreamble
Requires amsthm
LangPreamble
\providecommand{\examplename}{_(Example)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\examplename}{_(Example)}}
EndBabelPreamble
End
@ -147,9 +194,14 @@ Style Problem
LabelString "Problem \thetheorem."
Preamble
\theoremstyle{definition}
\newtheorem{problem}[thm]{Problem}
\newtheorem{problem}[thm]{\protect\problemname}
EndPreamble
Requires amsthm
LangPreamble
\providecommand{\problemname}{_(Problem)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\problemname}{_(Problem)}}
EndBabelPreamble
End
@ -159,9 +211,14 @@ Style Exercise
LabelString "Exercise \thetheorem."
Preamble
\theoremstyle{definition}
\newtheorem{xca}[thm]{Exercise}
\newtheorem{xca}[thm]{\protect\exercisename}
EndPreamble
Requires amsthm
LangPreamble
\providecommand{\exercisename}{_(Exercise)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\exercisename}{_(Exercise)}}
EndBabelPreamble
End
@ -180,8 +237,14 @@ Style Remark
EndFont
Preamble
\theoremstyle{remark}
\newtheorem{rem}[thm]{Remark}
\newtheorem{rem}[thm]{\protect\remarkname}
EndPreamble
LangPreamble
\providecommand{\remarkname}{_(Remark)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\remarkname}{_(Remark)}}
EndBabelPreamble
End
@ -191,9 +254,14 @@ Style Claim
LabelString "Claim \thetheorem."
Preamble
\theoremstyle{remark}
\newtheorem{claim}[thm]{Claim}
\newtheorem{claim}[thm]{\protect\claimname}
EndPreamble
Requires amsthm
LangPreamble
\providecommand{\claimname}{_(Claim)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\claimname}{_(Claim)}}
EndBabelPreamble
End
@ -212,7 +280,7 @@ Style Case
Preamble
\newcounter{casectr}
\newenvironment{caseenv}
{\begin{list}{{\itshape\ Case} \arabic{casectr}.}{%
{\begin{list}{{\itshape\ \protect\casename} \arabic{casectr}.}{%
\setlength{\leftmargin}{\labelwidth}
\addtolength{\leftmargin}{\parskip}
\setlength{\itemindent}{\listparindent}
@ -222,4 +290,10 @@ Style Case
\usecounter{casectr}}
{\end{list}}
EndPreamble
LangPreamble
\providecommand{\casename}{_(Case)}
EndLangPreamble
BabelPreamble
\addto\captions$$lang{\renewcommand{\casename}{_(Case)}}
EndBabelPreamble
End

View File

@ -45,7 +45,10 @@ import os, re, string, sys
# Incremented to format 13, 5 February 2009 by rgh
# Add InToc tag for InsetLayout
currentFormat = 13
# Incremented to format 14, 14 February 2009 by gb
# Rename I18NPreamble to BabelPreamble and add LangPreamble
currentFormat = 14
def usage(prog_name):
@ -112,6 +115,10 @@ def convert(lines):
re_Format = re.compile(r'^(\s*)(Format)(\s+)(\S+)', re.IGNORECASE)
re_Preamble = re.compile(r'^(\s*)Preamble', re.IGNORECASE)
re_EndPreamble = re.compile(r'^(\s*)EndPreamble', re.IGNORECASE)
re_LangPreamble = re.compile(r'^(\s*)LangPreamble', re.IGNORECASE)
re_EndLangPreamble = re.compile(r'^(\s*)EndLangPreamble', re.IGNORECASE)
re_BabelPreamble = re.compile(r'^(\s*)BabelPreamble', re.IGNORECASE)
re_EndBabelPreamble = re.compile(r'^(\s*)EndBabelPreamble', re.IGNORECASE)
re_MaxCounter = re.compile(r'^(\s*)(MaxCounter)(\s+)(\S+)', re.IGNORECASE)
re_LabelType = re.compile(r'^(\s*)(LabelType)(\s+)(\S+)', re.IGNORECASE)
re_LabelString = re.compile(r'^(\s*)(LabelString)(\s+)(("[^"]+")|(\S+))', re.IGNORECASE)
@ -127,6 +134,8 @@ def convert(lines):
re_AMSMathsPlain = re.compile(r'^\s*Input amsmaths-plain.inc\s*')
re_AMSMathsSeq = re.compile(r'^\s*Input amsmaths-seq.inc\s*')
re_TocLevel = re.compile(r'^(\s*)(TocLevel)(\s+)(\S+)', re.IGNORECASE)
re_I18nPreamble = re.compile(r'^(\s*)I18nPreamble', re.IGNORECASE)
re_EndI18nPreamble = re.compile(r'^(\s*)EndI18nPreamble', re.IGNORECASE)
# counters for sectioning styles (hardcoded in 1.3)
counters = {"part" : "\\Roman{part}",
@ -204,6 +213,30 @@ def convert(lines):
while i < len(lines) and not re_EndPreamble.match(lines[i]):
i += 1
continue
if re_LangPreamble.match(lines[i]):
i += 1
while i < len(lines) and not re_EndLangPreamble.match(lines[i]):
i += 1
continue
if re_BabelPreamble.match(lines[i]):
i += 1
while i < len(lines) and not re_EndBabelPreamble.match(lines[i]):
i += 1
continue
# Rename I18NPreamble to BabelPreamble
if format == 13:
match = re_I18nPreamble.match(lines[i])
if match:
lines[i] = match.group(1) + "BabelPreamble"
i += 1
match = re_EndI18nPreamble.match(lines[i])
while i < len(lines) and not match:
i += 1
match = re_EndI18nPreamble.match(lines[i])
lines[i] = match.group(1) + "EndBabelPreamble"
i += 1
continue
# These just involved new features, not any changes to old ones
if format == 11 or format == 12:

View File

@ -84,8 +84,8 @@ def layouts_l10n(input_files, output, base):
InsetLayout = re.compile(r'^InsetLayout\s+(.*)')
DescBegin = re.compile(r'#+\s*DescriptionBegin\s*$')
DescEnd = re.compile(r'#+\s*DescriptionEnd\s*$')
I18nPreamble = re.compile(r'\s*I18nPreamble\s*$')
EndI18nPreamble = re.compile(r'\s*EndI18nPreamble\s*$')
I18nPreamble = re.compile(r'\s*(Lang)|(Babel)Preamble\s*$')
EndI18nPreamble = re.compile(r'\s*End(Lang)|(Babel)Preamble\s*$')
I18nString = re.compile(r'_\(([^\)]+)\)')
for src in input_files:

View File

@ -1419,6 +1419,10 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
lyxpreamble += from_utf8(features.getBabelOptions()) + '\n';
}
docstring const i18npreamble = features.getTClassI18nPreamble(use_babel);
if (!i18npreamble.empty())
lyxpreamble += i18npreamble + '\n';
int const nlines =
int(count(lyxpreamble.begin(), lyxpreamble.end(), '\n'));
for (int j = 0; j != nlines; ++j) {

View File

@ -870,18 +870,42 @@ docstring const LaTeXFeatures::getTClassPreamble() const
tcpreamble << tclass.preamble();
list<docstring>::const_iterator cit = usedLayouts_.begin();
list<docstring>::const_iterator end = usedLayouts_.end();
for (; cit != end; ++cit)
tcpreamble << tclass[*cit].preamble();
return tcpreamble.str();
}
docstring const LaTeXFeatures::getTClassI18nPreamble(bool use_babel) const
{
DocumentClass const & tclass = params_.documentClass();
// collect preamble snippets in a set to prevent multiple identical
// commands (would happen if e.g. both theorem and theorem* are used)
set<docstring> snippets;
typedef LanguageList::const_iterator lang_it;
lang_it const lbeg = UsedLanguages_.begin();
lang_it const lend = UsedLanguages_.end();
list<docstring>::const_iterator cit = usedLayouts_.begin();
list<docstring>::const_iterator end = usedLayouts_.end();
for (; cit != end; ++cit) {
tcpreamble << tclass[*cit].preamble();
tcpreamble << tclass[*cit].i18npreamble(buffer().language());
for (lang_it lit = lbeg; lit != lend; ++lit)
tcpreamble << tclass[*cit].i18npreamble(*lit);
// language dependent commands (once per document)
snippets.insert(tclass[*cit].langpreamble(buffer().language()));
// commands for language changing (for multilanguage documents)
if (use_babel && !UsedLanguages_.empty()) {
snippets.insert(tclass[*cit].babelpreamble(buffer().language()));
for (lang_it lit = lbeg; lit != lend; ++lit)
snippets.insert(tclass[*cit].babelpreamble(*lit));
}
}
odocstringstream tcpreamble;
set<docstring>::const_iterator const send = snippets.end();
set<docstring>::const_iterator it = snippets.begin();
for (; it != send; ++it)
tcpreamble << *it;
return tcpreamble.str();
}

View File

@ -56,6 +56,8 @@ public:
std::string const getBabelOptions() const;
/// The definitions needed by the document's textclass
docstring const getTClassPreamble() const;
/// The language dependent definitions needed by the document's textclass
docstring const getTClassI18nPreamble(bool use_babel) const;
/// The sgml definitions needed by the document (docbook)
docstring const getLyXSGMLEntities() const;
/// The SGML Required to include the files added with includeFile();

View File

@ -56,7 +56,6 @@ enum LayoutTags {
LT_FREE_SPACING,
LT_PASS_THRU,
//LT_HEADINGS,
LT_I18NPREAMBLE,
LT_ITEMSEP,
LT_KEEPEMPTY,
LT_LABEL_BOTTOMSEP,
@ -83,6 +82,8 @@ enum LayoutTags {
LT_PARSKIP,
//LT_PLAIN,
LT_PREAMBLE,
LT_LANGPREAMBLE,
LT_BABELPREAMBLE,
LT_REQUIRES,
LT_RIGHTMARGIN,
LT_SPACING,
@ -138,6 +139,7 @@ bool Layout::read(Lexer & lex, TextClass const & tclass)
LexerKeyword layoutTags[] = {
{ "align", LT_ALIGN },
{ "alignpossible", LT_ALIGNPOSSIBLE },
{ "babelpreamble", LT_BABELPREAMBLE },
{ "bottomsep", LT_BOTTOMSEP },
{ "category", LT_CATEGORY },
{ "commanddepth", LT_COMMANDDEPTH },
@ -150,7 +152,6 @@ bool Layout::read(Lexer & lex, TextClass const & tclass)
{ "fill_top", LT_FILL_TOP },
{ "font", LT_FONT },
{ "freespacing", LT_FREE_SPACING },
{ "i18npreamble", LT_I18NPREAMBLE },
{ "innertag", LT_INNERTAG },
{ "intitle", LT_INTITLE },
{ "itemsep", LT_ITEMSEP },
@ -165,6 +166,7 @@ bool Layout::read(Lexer & lex, TextClass const & tclass)
{ "labelstringappendix", LT_LABELSTRING_APPENDIX },
{ "labeltag", LT_LABELTAG },
{ "labeltype", LT_LABELTYPE },
{ "langpreamble", LT_LANGPREAMBLE },
{ "latexname", LT_LATEXNAME },
{ "latexparam", LT_LATEXPARAM },
{ "latextype", LT_LATEXTYPE },
@ -336,8 +338,12 @@ bool Layout::read(Lexer & lex, TextClass const & tclass)
preamble_ = from_utf8(lex.getLongString("EndPreamble"));
break;
case LT_I18NPREAMBLE:
i18npreamble_ = from_utf8(lex.getLongString("EndI18NPreamble"));
case LT_LANGPREAMBLE:
langpreamble_ = from_utf8(lex.getLongString("EndLangPreamble"));
break;
case LT_BABELPREAMBLE:
babelpreamble_ = from_utf8(lex.getLongString("EndBabelPreamble"));
break;
case LT_LABELTYPE:
@ -774,12 +780,15 @@ docstring const & Layout::depends_on() const
}
docstring const Layout::i18npreamble(Language const * lang) const
namespace {
docstring const i18npreamble(Language const * lang, docstring const & templ)
{
if (i18npreamble_.empty())
return i18npreamble_;
string preamble = subst(to_utf8(i18npreamble_), "$$lang",
lang->babel());
if (templ.empty())
return templ;
string preamble = subst(to_utf8(templ), "$$lang", lang->babel());
#ifdef TEX2LYX
// tex2lyx does not have getMessages()
LASSERT(false, /**/);
@ -805,6 +814,20 @@ docstring const Layout::i18npreamble(Language const * lang) const
return from_utf8(preamble);
}
}
docstring const Layout::langpreamble(Language const * lang) const
{
return i18npreamble(lang, langpreamble_);
}
docstring const Layout::babelpreamble(Language const * lang) const
{
return i18npreamble(lang, babelpreamble_);
}
bool Layout::operator==(Layout const & rhs) const
{

View File

@ -92,7 +92,10 @@ public:
docstring const & preamble() const { return preamble_; }
/// Get language dependent macro definitions needed for this layout
/// for language \p lang
docstring const i18npreamble(Language const * lang) const;
docstring const langpreamble(Language const * lang) const;
/// Get language and babel dependent macro definitions needed for
/// this layout for language \p lang
docstring const babelpreamble(Language const * lang) const;
///
std::set<std::string> const & requires() const { return requires_; }
///
@ -271,7 +274,9 @@ private:
/// Macro definitions needed for this layout
docstring preamble_;
/// Language dependent macro definitions needed for this layout
docstring i18npreamble_;
docstring langpreamble_;
/// Language and babel dependent macro definitions needed for this layout
docstring babelpreamble_;
/// Packages needed for this layout
std::set<std::string> requires_;
};

View File

@ -62,7 +62,7 @@ private:
};
// Keep the changes documented in the Customization manual.
int const FORMAT = 13;
int const FORMAT = 14;
bool layout2layout(FileName const & filename, FileName const & tempfile)
@ -232,17 +232,18 @@ bool TextClass::convertLayoutFormat(support::FileName const & filename, ReadType
FileName const tempfile = FileName::tempName("convert_layout");
bool success = layout2layout(filename, tempfile);
if (success)
success = read(tempfile, rt);
success = readWithoutConv(tempfile, rt) == OK;
tempfile.removeFile();
return success;
}
bool TextClass::read(FileName const & filename, ReadType rt)
TextClass::ReturnValues TextClass::readWithoutConv(FileName const & filename, ReadType rt)
{
if (!filename.isReadableFile()) {
lyxerr << "Cannot read layout file `" << filename << "'."
<< endl;
return false;
return ERROR;
}
LYXERR(Debug::TCLASS, "Reading " + translateRT(rt) + ": " +
@ -261,6 +262,13 @@ bool TextClass::read(FileName const & filename, ReadType rt)
LYXERR(Debug::TCLASS, "Finished reading " + translateRT(rt) + ": " +
to_utf8(makeDisplayPath(filename.absFilename())));
return retval;
}
bool TextClass::read(FileName const & filename, ReadType rt)
{
ReturnValues const retval = readWithoutConv(filename, rt);
if (retval != FORMAT_MISMATCH)
return retval == OK;

View File

@ -298,6 +298,8 @@ private:
bool deleteLayout(docstring const &);
///
bool convertLayoutFormat(support::FileName const &, ReadType);
/// Reads the layout file without running layout2layout.
ReturnValues readWithoutConv(support::FileName const & filename, ReadType rt);
/// \return true for success.
bool readStyle(Lexer &, Layout &) const;
///