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