From 515708f6eb7279e70117e661dd6ba0460a7a2c90 Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Tue, 13 Dec 2011 19:50:36 +0000 Subject: [PATCH] Backport fix for #7611. Repairs to case environment, from Paul Rubin. Modified by RGH to use enumitem, since we already have a module for that, and there will be conflicts between enumerate.sty and enumitem.sty. A side effect of this, however, is that we will load enumitem.sty whenver we use case environments. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40492 a592a061-630c-0410-9148-cb99ea01b6c8 (cherry picked from commit 4663e5ec881cf30fe12eeff2122d0b4fa2574671) Conflicts: lib/layouts/theorems.inc --- lib/Makefile.am | 1 + lib/layouts/theorems-ams-bytype.inc | 48 ++---------------------- lib/layouts/theorems-ams.inc | 49 ++----------------------- lib/layouts/theorems-bytype.inc | 40 ++------------------ lib/layouts/theorems-case.inc | 57 +++++++++++++++++++++++++++++ lib/layouts/theorems.inc | 41 ++------------------- 6 files changed, 70 insertions(+), 166 deletions(-) create mode 100644 lib/layouts/theorems-case.inc diff --git a/lib/Makefile.am b/lib/Makefile.am index 54ad1379c4..d89882ad5c 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -1476,6 +1476,7 @@ dist_layouts_DATA =\ layouts/theorems-ams-bytype.module \ layouts/theorems-ams-extended.module \ layouts/theorems-ams-extended-bytype.module \ + layouts/theorems-case.inc \ layouts/theorems-chap.module \ layouts/theorems.inc \ layouts/theorems-bytype.inc \ diff --git a/lib/layouts/theorems-ams-bytype.inc b/lib/layouts/theorems-ams-bytype.inc index a88560c94c..2dc13ebcb2 100644 --- a/lib/layouts/theorems-ams-bytype.inc +++ b/lib/layouts/theorems-ams-bytype.inc @@ -5,7 +5,7 @@ # Modularized Jan 08 by Richard Heck # Hacked June '09 by Paul Rubin to use separate counters -# The environnements defined are : +# The environments defined are : # - Theorem # - Corollary # - Lemma @@ -18,7 +18,7 @@ # - Exercise # - Remark # - Claim -# - Case (regular only -- defined as an enumeration) +# - Case (by inclusion) # We need separate counters for each theorem-like style. Format 35 @@ -304,46 +304,4 @@ Style Claim LabelCounter claim End - -# Define Case as an enumeration environment -Style Case - Category Theorem - Margin Static - LatexType Item_Environment - LatexName caseenv - LabelType Itemize - NextNoIndent 1 - LeftMargin "Case ###." - ParSkip 0.0 - ItemSep 0.2 - TopSep 0.7 - BottomSep 0.7 - ParSep 0.3 - Align Block - AlignPossible Block, Left - LabelSep xx - LabelString "Case #." - LabelFont - Series Medium - Shape Italic - EndFont - Preamble - \newcounter{casectr} - \newenvironment{caseenv} - {\begin{list}{{\itshape\ \protect\casename} \arabic{casectr}.}{% - \setlength{\leftmargin}{\labelwidth} - \addtolength{\leftmargin}{\parskip} - \setlength{\itemindent}{\listparindent} - \setlength{\itemsep}{\medskipamount} - \setlength{\topsep}{\itemsep}} - \setcounter{casectr}{0} - \usecounter{casectr}} - {\end{list}} - EndPreamble - LangPreamble - \providecommand{\casename}{_(Case)} - EndLangPreamble - BabelPreamble - \addto\captions$$lang{\renewcommand{\casename}{_(Case)}} - EndBabelPreamble -End +Input theorems-case.inc diff --git a/lib/layouts/theorems-ams.inc b/lib/layouts/theorems-ams.inc index 8da4b7b657..78a2693fcc 100644 --- a/lib/layouts/theorems-ams.inc +++ b/lib/layouts/theorems-ams.inc @@ -4,7 +4,7 @@ # Tinkered with Sep. '07 by Paul Rubin # Modularized Jan 08 by Richard Heck -# The environnements defined are : +# The environments defined are : # - Theorem # - Corollary # - Lemma @@ -17,7 +17,7 @@ # - Remark # - Claim # - Proof -# - Case (regular only -- defined as an enumeration) +# - Case (by inclusion) Format 35 @@ -270,48 +270,5 @@ Style Claim EndBabelPreamble End - -# Define Case as an enumeration environment -Style Case - Category Theorem - Margin Static - LatexType Item_Environment - LatexName caseenv - LabelType Static - NextNoIndent 1 - LeftMargin "Case ###." - ParSkip 0.0 - ItemSep 0.2 - TopSep 0.7 - BottomSep 0.7 - ParSep 0.3 - Align Block - AlignPossible Block, Left - LabelSep xx - LabelString "Case #." - LabelFont - Series Medium - Shape Italic - EndFont - Preamble - \newcounter{casectr} - \newenvironment{caseenv} - {\begin{list}{{\itshape\ \protect\casename} \arabic{casectr}.}{% - \setlength{\leftmargin}{\labelwidth} - \addtolength{\leftmargin}{\parskip} - \setlength{\itemindent}{\listparindent} - \setlength{\itemsep}{\medskipamount} - \setlength{\topsep}{\itemsep}} - \setcounter{casectr}{0} - \usecounter{casectr}} - {\end{list}} - EndPreamble - LangPreamble - \providecommand{\casename}{_(Case)} - EndLangPreamble - BabelPreamble - \addto\captions$$lang{\renewcommand{\casename}{_(Case)}} - EndBabelPreamble -End - +Input theorems-case.inc Input theorems-refprefix.inc diff --git a/lib/layouts/theorems-bytype.inc b/lib/layouts/theorems-bytype.inc index 1814e16ddc..47f28c5901 100644 --- a/lib/layouts/theorems-bytype.inc +++ b/lib/layouts/theorems-bytype.inc @@ -5,7 +5,7 @@ # Modularized Jan 08 by Richard Heck # Hacked June '09 by Paul Rubin to use separate counters -# The environnements defined are : +# The environments defined are : # - Theorem # - Corollary # - Lemma @@ -19,7 +19,7 @@ # - Remark # - Claim # - Proof -# - Case (regular only -- defined as an enumeration) +# - Case (by inclusion) Format 35 @@ -280,39 +280,5 @@ Style Claim LabelCounter claim End - -# Define Case as an enumeration environment -Style Case - Category Theorem - CopyStyle Enumerate - LatexName caseenv - LabelType Static - LeftMargin "Case ###." - LabelString "Case #." - LabelFont - Series Medium - Shape Italic - EndFont - Preamble - \newcounter{casectr} - \newenvironment{caseenv} - {\begin{list}{{\itshape\ \protect\casename} \arabic{casectr}.}{% - \setlength{\leftmargin}{\labelwidth} - \addtolength{\leftmargin}{\parskip} - \setlength{\itemindent}{\listparindent} - \setlength{\itemsep}{\medskipamount} - \setlength{\topsep}{\itemsep}} - \setcounter{casectr}{0} - \usecounter{casectr}} - {\end{list}} - EndPreamble - LangPreamble - \providecommand{\casename}{_(Case)} - EndLangPreamble - BabelPreamble - \addto\captions$$lang{\renewcommand{\casename}{_(Case)}} - EndBabelPreamble - RefPrefix OFF -End - +Input theorems-case.inc Input theorems-refprefix.inc diff --git a/lib/layouts/theorems-case.inc b/lib/layouts/theorems-case.inc new file mode 100644 index 0000000000..9a29ed5d41 --- /dev/null +++ b/lib/layouts/theorems-case.inc @@ -0,0 +1,57 @@ +# Original Author : Paul Rubin +# Modified by Richard Heck to use enumitem + +# Definition of case environment as an enumeration + +# Define Case as an enumeration environment +# with its own counters + +Format 35 + +Counter casei + LabelString "Case \arabic{casei}." +End +Counter caseii + Within casei + LabelString "Case \roman{caseii}." +End +Counter caseiii + Within caseii + LabelString "Case \alph{caseiii}." +End +Counter caseiv + Within caseiii + LabelString "Case \arabic{caseiv}." +End + +Style Case + Category Theorem + CopyStyle Enumerate + LatexName casenv + LabelType Enumerate + LeftMargin "Case ###." + LabelCounter case + LabelFont + Series Medium + Shape Italic + EndFont + Requires enumitem + # It'd be easier to use \setlist[caseenv] here, but that causes problems + # if you nest an ordinary list inside a case environment. See discussion + # at bug #7611. + Preamble + \newlist{casenv}{enumerate}{4} + \setlist[casenv]{leftmargin=*,align=left,widest={iiii}} + \setlist[casenv,1]{label={{\itshape\ \casename} \arabic*.},ref=\arabic*} + \setlist[casenv,2]{label={{\itshape\ \casename} \roman*.},ref=\roman*} + \setlist[casenv,3]{label={{\itshape\ \casename\ \alph*.}},ref=\alph*} + \setlist[casenv,4]{label={{\itshape\ \casename} \arabic*.},ref=\arabic*} + EndPreamble + LangPreamble + \providecommand{\casename}{_(Case)} + EndLangPreamble + BabelPreamble + \addto\captions$$lang{\renewcommand{\casename}{_(Case)}} + EndBabelPreamble + RefPrefix OFF +End diff --git a/lib/layouts/theorems.inc b/lib/layouts/theorems.inc index fd0738bb8b..82ebd5f250 100644 --- a/lib/layouts/theorems.inc +++ b/lib/layouts/theorems.inc @@ -4,7 +4,7 @@ # Tinkered with Sep. '07 by Paul Rubin # Modularized Jan 08 by Richard Heck -# The environnements defined are : +# The environments defined are : # - Theorem # - Corollary # - Lemma @@ -16,8 +16,7 @@ # - Exercise # - Remark # - Claim -# - Proof -# - Case (regular only -- defined as an enumeration) +# - Case (by inclusion) Format 35 @@ -270,39 +269,5 @@ Style Claim EndBabelPreamble End - -# Define Case as an enumeration environment -Style Case - Category Theorem - CopyStyle Enumerate - LatexName caseenv - LabelType Static - LeftMargin "Case ###." - LabelString "Case #." - LabelFont - Series Medium - Shape Italic - EndFont - Preamble - \newcounter{casectr} - \newenvironment{caseenv} - {\begin{list}{{\itshape\ \protect\casename} \arabic{casectr}.}{% - \setlength{\leftmargin}{\labelwidth} - \addtolength{\leftmargin}{\parskip} - \setlength{\itemindent}{\listparindent} - \setlength{\itemsep}{\medskipamount} - \setlength{\topsep}{\itemsep}} - \setcounter{casectr}{0} - \usecounter{casectr}} - {\end{list}} - EndPreamble - LangPreamble - \providecommand{\casename}{_(Case)} - EndLangPreamble - BabelPreamble - \addto\captions$$lang{\renewcommand{\casename}{_(Case)}} - EndBabelPreamble - RefPrefix OFF -End - +Input theorems-case.inc Input theorems-refprefix.inc -- 2.39.5