File: thmtools.sty.ltxml

package info (click to toggle)
latexml 0.8.8-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 31,920 kB
  • sloc: xml: 109,048; perl: 30,224; sh: 179; javascript: 28; makefile: 13
file content (126 lines) | stat: -rw-r--r-- 5,309 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# -*- mode: Perl -*-
# /=====================================================================\ #
# | thmtools.sty                                                        | #
# | Implementation for LaTeXML                                          | #
# |=====================================================================| #
# | Part of LaTeXML:                                                    | #
# |  Public domain software, produced as part of work done by the       | #
# |  United States Government & not subject to copyright in the US.     | #
# |---------------------------------------------------------------------| #
# | Bruce Miller <bruce.miller@nist.gov>                        #_#     | #
# | http://dlmf.nist.gov/LaTeXML/                              (o o)    | #
# \=========================================================ooo==U==ooo=/ #
package LaTeXML::Package::Pool;
use strict;
use warnings;
use LaTeXML::Package;

#======================================================================
# Style options:
#   Handled:
#     headfont
#     headpunct
#     notefont
#     bodyfont
#   Semi-done:
#     headformat :  margin, swapnumber  OR code containing \NUMBER, \NAME and \NOTE
#   Ignored (should it be ?):
#     spaceabove, spacebelow, postheadspace
#   Not done yet
#     notebraces
#     headindent
# Theorem options:
#   Handled:
#     title=name=heading
#     numbered : yes, no, unless unique
#     style : name of \newtheoremstyle or \declaretheoremstyle
#     sibling=numberlike=sharenumber
#     parent=numberwithin=within
#     refname, Refname => name used for autoref, cref
#   Ignored (should it be?):
#     postheadspace
#     preheadhook, postheadhook
#     prefoothook, postfoothook
#     thmbox : L,M,S
#   Not done yet:
#     shaded : kv of textwiddth, bgcolor, rulecolor, rulewidth, margin
# See ntheorem for an idea how to deal with framing, colors, etc?
setSavableTheoremParameters(qw(
    \thm@bodyfont \thm@headfont \thm@notefont  \thm@bodyfont \thm@headpunct
    \thm@styling \thm@headstyling));

# should nu
sub thmtools_style {
  my ($name, $kv) = @_;
  my %parameters = ();
  if (my $headfont = $kv && $kv->getValue('headfont')) {
    $parameters{'\thm@headfont'} = $headfont; }
  if (my $headpunct = $kv && $kv->getValue('headpunct')) {
    $parameters{'\thm@headpunct'} = $headpunct; }
  if (my $notefont = $kv && $kv->getValue('notefont')) {
    $parameters{'\thm@notefont'} = $notefont; }
  if (my $bodyfont = $kv && $kv->getValue('bodyfont')) {
    $parameters{'\thm@bodyfont'} = $bodyfont; }
  if (my $headformat = ToString(($kv && $kv->getValue('headformat')) || '')) {
    $parameters{'thm@swap'} = $headformat eq 'swapnumber'; }

  saveTheoremStyle($name, %parameters);
  return; }

DefPrimitive('\declaretheorem OptionalKeyVals {}', sub {
    my ($stomach, $kv, $thmset) = @_;
    # Activate any requested style
    my $name  = ToString($thmset);
    my $style = $kv && $kv->getValue('style');
    if ($style) {
      $style = ToString(Digest($style)); }
    useTheoremStyle($style || 'plain');
    thmtools_style($name, $kv);
    useTheoremStyle($name);
    my $type = ($kv
        && ($kv->getValue('title') || $kv->getValue('name') || $kv->getValue('heading')))
      || Tokens(T_CS('\MakeUppercase'), $thmset);

    my $numbered = $kv && $kv->getValue('numbered');
    my $flag     = ToString($numbered) eq 'no';
    my $other    = $kv
      && ($kv->getValue('sibling') || $kv->getValue('numberlike') || $kv->getValue('sharenumber'));
    my $within = $kv
      && ($kv->getValue('parent') || $kv->getValue('numberwithin') || $kv->getValue('within'));

    if (my $refname = $kv && $kv->getValue('refname')) {
      my ($s, $p) = map { Tokens(@$_); } SplitTokens($refname, T_OTHER(','));
      DefMacroI('\\' . $name . 'autorefname',       undef, $s);
      DefMacroI('\\cref@' . $name . '@name',        undef, $s);
      DefMacroI('\\cref@' . $name . '@name@plural', undef, $p); }
    if (my $refname = $kv && $kv->getValue('Refname')) {
      my ($s, $p) = map { Tokens(@$_); } SplitTokens($refname, T_OTHER(','));
      DefMacroI('\\Cref@' . $name . '@name',        undef, $s);
      DefMacroI('\\Cref@' . $name . '@name@plural', undef, $p); }

    defineNewTheorem($stomach, $flag, $thmset, $other, $type, $within);
    return; });

DefPrimitive('\declaretheoremstyle OptionalKeyVals {}', sub {
    thmtools_style($_[2], $_[1]); });

#DefMacro('\enc@theorem
DefMacroI('\listtheoremname', undef, 'List of Theorems');
# Note that the LaTeX version uses the list "loe", rather than "thm"
# Also note (unimplemented) options: onlynamed; we don't track names?
DefConstructor('\listoftheorems OptionalKeyVals',
  "<ltx:TOC lists='#lists' scope='global'><ltx:title>#name</ltx:title></ltx:TOC>",
  properties => sub {
    my ($stomach, $kv) = @_;
    my $title = ($kv && $kv->getValue('title')) || Digest(T_CS('\listtheoremname'));
    my $lists = 'thm';
    if ($kv && $kv->hasKey('ignoreall')) {    # Means we're only including a subset
      $lists = '';
      if (my $names = $kv->getValue('show')) {
        my @names = split(/,\s*/, ToString($names));
        $lists = join(' ', map { 'theorem:' . $_; } @names); } }
    (name => $title,
      lists => $lists); });

#======================================================================
1;