]> git.lyx.org Git - lyx.git/blob - lib/layouts/theorems-chap.module
New Theorems Module. Contributed by Udicoudco <udifoglle@gmail.com> on the mailing...
[lyx.git] / lib / layouts / theorems-chap.module
1 #\DeclareLyXModule{Standard Theorems (Numbered by Chapter)}
2 #\DeclareCategory{Maths}
3 #DescriptionBegin
4 #Numbers theorems and the like by chapter (i.e., the counter is reset at
5 #each chapter start). Use this module only with document classes that provide a chapter
6 #environment.
7 #DescriptionEnd
8 #Requires: theorems-std
9 #Excludes: theorems-sec
10
11 # Author: Richard Kimberly Heck <rikiheck@lyx.org>
12 # Edited sep '22 by Udi Fogiel <udifoglle@gmail.com>
13
14 Format 99
15
16 Counter theorem
17         GuiName Theorem
18         Within chapter
19         LaTeXName thm
20 End
21
22 Style Theorem
23         Preamble
24                 \def\lyx@reverse@two#1#2{#2#1}
25                 \def\lyx@plain{plain}
26                 \def\lyx@definition{definition}
27                 \def\lyx@remark{remark}
28                 \newcommand\theoremstyle[1]{%
29                         \def\lyx@style{#1}%
30                         \ifx\lyx@style\lyx@plain
31                                 \def\lyx@headfont{\bfseries}%
32                                 \def\lyx@bodyfont{\itshape}%
33                         \else
34                                 \ifx\lyx@style\lyx@definition
35                                         \def\lyx@headfont{\bfseries}%
36                                         \def\lyx@bodyfont{\upshape}%
37                                 \else
38                                         \ifx\lyx@style\lyx@remark
39                                                 \def\lyx@headfont{\itshape}%
40                                                 \def\lyx@bodyfont{\upshape}%
41                                         \fi
42                                 \fi
43                         \fi
44                 }
45                 \def\@xthm#1#2{%
46                         \@begintheorem{\normalfont\csname lyx@\@firstoftwo#2@headfont\endcsname \@secondoftwo#2}{\begingroup\upshape\csname the#1\endcsname\endgroup.}\normalfont\csname lyx@\@firstoftwo#2@bodyfont\endcsname\ignorespaces
47                 }
48                 \def\@ythm#1#2[#3]{%
49                         \@opargbegintheorem{\normalfont{\csname lyx@\@firstoftwo#2@headfont\endcsname \@secondoftwo#2}}{\begingroup\csname lyx@\@firstoftwo#2@headfont\endcsname\upshape\csname the#1\endcsname\endgroup}{#3\lyx@reverse@two{\begingroup\normalfont\csname lyx@\@firstoftwo#2@headfont\endcsname.\endgroup}}\normalfont\csname lyx@\@firstoftwo#2@bodyfont\endcsname\ignorespaces
50                 }
51                 \def\lyx@othm#1[#2]#3{\@othm{#1}[#2]{{#1}{#3}}}
52                 \def\lyx@nthm#1#2{\@ifnextchar[{\@xnthm{#1}{{#1}{#2}}}{\@ynthm{#1}{{#1}{#2}}}}
53                 \renewcommand\newtheorem[1]{%
54                         \expandafter\let\csname lyx@#1@headfont\expandafter\endcsname\lyx@headfont
55                         \expandafter\let\csname lyx@#1@bodyfont\expandafter\endcsname\lyx@bodyfont
56                         \@ifnextchar[{\lyx@othm{#1}}{\lyx@nthm{#1}}}
57                 \newcommand\lyx@starred@newtheorem[2]{\newtheorem{#1}{#2}\expandafter\def\csname the#1\endcsname{\unskip}}
58                 \newcommand\lyx@reg@newtheorem[2]{\newtheorem{#1}[thm]{#2}}
59                 \newcommand\lyx@newtheorem{\@ifstar{\lyx@starred@newtheorem}{\lyx@reg@newtheorem}}
60                 \theoremstyle{plain}
61                 \ifcsname c@chapter\endcsname
62                         \ifx\c@chapter\relax
63                                 \newtheorem{thm}{\protect\theoremname}
64                         \else
65                                 \newtheorem{thm}{\protect\theoremname}[chapter]
66                         \fi
67                 \else
68                         \newtheorem{thm}{\protect\theoremname}
69                 \fi
70         EndPreamble
71 End