1# -*- mode: Perl -*- 2# /=====================================================================\ # 3# | thmtools.sty | # 4# | Implementation for LaTeXML | # 5# |=====================================================================| # 6# | Part of LaTeXML: | # 7# | Public domain software, produced as part of work done by the | # 8# | United States Government & not subject to copyright in the US. | # 9# |---------------------------------------------------------------------| # 10# | Bruce Miller <bruce.miller@nist.gov> #_# | # 11# | http://dlmf.nist.gov/LaTeXML/ (o o) | # 12# \=========================================================ooo==U==ooo=/ # 13package LaTeXML::Package::Pool; 14use strict; 15use warnings; 16use LaTeXML::Package; 17 18#====================================================================== 19# Style options: 20# Handled: 21# headfont 22# headpunct 23# notefont 24# bodyfont 25# Semi-done: 26# headformat : margin, swapnumber OR code containing \NUMBER, \NAME and \NOTE 27# Ignored (should it be ?): 28# spaceabove, spacebelow, postheadspace 29# Not done yet 30# notebraces 31# headindent 32# Theorem options: 33# Handled: 34# title=name=heading 35# numbered : yes, no, unless unique 36# style : name of \newtheoremstyle or \declaretheoremstyle 37# sibling=numberlike=sharenumber 38# parent=numberwithin=within 39# refname, Refname => name used for autoref, cref 40# Ignored (should it be?): 41# postheadspace 42# preheadhook, postheadhook 43# prefoothook, postfoothook 44# thmbox : L,M,S 45# Not done yet: 46# shaded : kv of textwiddth, bgcolor, rulecolor, rulewidth, margin 47# See ntheorem for an idea how to deal with framing, colors, etc? 48setSavableTheoremParameters(qw( 49 \thm@bodyfont \thm@headfont \thm@notefont \thm@bodyfont \thm@headpunct 50 \thm@styling \thm@headstyling)); 51 52# should nu 53sub thmtools_style { 54 my ($name, $kv) = @_; 55 my %parameters = (); 56 if (my $headfont = $kv && $kv->getValue('headfont')) { 57 $parameters{'\thm@headfont'} = $headfont; } 58 if (my $headpunct = $kv && $kv->getValue('headpunct')) { 59 $parameters{'\thm@headpunct'} = $headpunct; } 60 if (my $notefont = $kv && $kv->getValue('notefont')) { 61 $parameters{'\thm@notefont'} = $notefont; } 62 if (my $bodyfont = $kv && $kv->getValue('bodyfont')) { 63 $parameters{'\thm@bodyfont'} = $bodyfont; } 64 if (my $headformat = ToString(($kv && $kv->getValue('headformat')) || '')) { 65 $parameters{'\thm@swap'} = $headformat eq 'swapnumber'; } 66 67 saveTheoremStyle($name, %parameters); 68 return; } 69 70DefPrimitive('\declaretheorem OptionalKeyVals {}', sub { 71 my ($stomach, $kv, $thmset) = @_; 72 # Activate any requested style 73 my $name = ToString($thmset); 74 if (my $style = ToString($kv && $kv->getValue('style')) || 'plain') { 75 useTheoremStyle($style); } 76 thmtools_style($name, $kv); 77 useTheoremStyle($name); 78 my $type = ($kv 79 && ($kv->getValue('title') || $kv->getValue('name') || $kv->getValue('heading'))) 80 || Tokens(T_CS('\MakeUppercase'), $thmset); 81 82 my $numbered = $kv && $kv->getValue('numbered'); 83 my $flag = ToString($numbered) eq 'no'; 84 my $other = $kv 85 && ($kv->getValue('sibling') || $kv->getValue('numberlike') || $kv->getValue('sharenumber')); 86 my $within = $kv 87 && ($kv->getValue('parent') || $kv->getValue('numberwithin') || $kv->getValue('within')); 88 89 if (my $refname = $kv && $kv->getValue('refname')) { 90 my ($s, $p) = map { Tokens(@$_); } SplitTokens($refname, T_OTHER(',')); 91 DefMacroI('\\' . $name . 'autorefname', undef, $s); 92 DefMacroI('\\cref@' . $name . '@name', undef, $s); 93 DefMacroI('\\cref@' . $name . '@name@plural', undef, $p); } 94 if (my $refname = $kv && $kv->getValue('Refname')) { 95 my ($s, $p) = map { Tokens(@$_); } SplitTokens($refname, T_OTHER(',')); 96 DefMacroI('\\Cref@' . $name . '@name', undef, $s); 97 DefMacroI('\\Cref@' . $name . '@name@plural', undef, $p); } 98 99 defineNewTheorem($stomach, $flag, $thmset, $other, $type, $within); 100 return; }); 101 102DefPrimitive('\declaretheoremstyle OptionalKeyVals {}', sub { 103 thmtools_style($_[2], $_[1]); }); 104 105#DefMacro('\enc@theorem 106DefMacroI('\listtheoremname', undef, 'List of Theorems'); 107DefConstructor('\listoftheorems OptionalKeyVals', 108 "<ltx:TOC lists='lot' scope='global'><ltx:title>#name</ltx:title></ltx:TOC>", 109 properties => sub { (name => Digest(T_CS('\listtheoremname'))); }); 110 111#====================================================================== 1121; 113