From 4663e5ec881cf30fe12eeff2122d0b4fa2574671 Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Tue, 13 Dec 2011 19:50:36 +0000 Subject: [PATCH] Repairs to case environment, from Paul Rubin. Modified by me to use enumitem, since we already have a module for that, and I am a bit worried about 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 --- 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 | 40 ++------------------ 6 files changed, 70 insertions(+), 165 deletions(-) create mode 100644 lib/layouts/theorems-case.inc diff --git a/lib/Makefile.am b/lib/Makefile.am index b20b62f33d..ade50ffb96 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -1473,6 +1473,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 e6af1d29f2..ab81a75ffd 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 36 @@ -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 651565a91b..54f7a351db 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 36 @@ -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 0fffbd973e..66effc7258 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 36 @@ -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 bf657c985b..6a578029c7 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 @@ -17,7 +17,7 @@ # - Exercise # - Remark # - Claim -# - Case (regular only -- defined as an enumeration) +# - Case (by inclusion) Format 36 @@ -270,39 +270,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