File: floatflt.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 (110 lines) | stat: -rw-r--r-- 4,472 bytes parent folder | download | duplicates (3)
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
# -*- mode: Perl -*-
# /=====================================================================\ #
# |  floatflt                                                           | #
# | 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.     | #
# |---------------------------------------------------------------------| #
# | Thanks to the arXMLiv group for initial implementation              | #
# |    http://arxmliv.kwarc.info/                                       | #
# | Released to the Public Domain                                       | #
# |---------------------------------------------------------------------| #
# | 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;

#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# \begin{floatingfigure}[pos]{width} ... \end{figure}
# pos = rflt to the right, lflt to the left, v to the outer edge, p to the inner
# Since we know nothing about pages, we'll treat v=r, p=l...

AssignValue(floatfltpos => 'v');
DeclareOption('rflt', sub { AssignValue(floatfltpos => 'r'); });
DeclareOption('lflt', sub { AssignValue(floatfltpos => 'l'); });
DeclareOption('pflt', sub { AssignValue(floatfltpos => 'p'); });
DeclareOption('vflt', sub { AssignValue(floatfltpos => 'v'); });

DefEnvironment('{floatingfigure}[]{Dimension}',
  "<ltx:figure xml:id='#id' inlist='#inlist' float='#float' width='#pctwidth'>"
    . "#tags"
    . "#body"
    . "</ltx:figure>",
  beforeDigest => sub { beforeFloat('figure'); },
  afterDigest  => sub { afterFloat($_[1]); },
  properties   => sub {
    (float => (ToString($_[1] || LookupValue('floatfltpos')) =~ /^(v|r)/ ? 'right' : 'left'),
      pctwidth => toPercent($_[2])); });

DefEnvironment('{floatingtable}[]{Dimension}',
  "<ltx:table xml:id='#id' inlist='#inlist' float='#float' width='#pctwidth'>"
    . "#tags"
    . "#body"
    . "</ltx:table>",
  beforeDigest => sub { beforeFloat('table'); },
  afterDigest  => sub { afterFloat($_[1]); },
  properties   => sub {
    (float => (ToString($_[1] || LookupValue('floatfltpos')) =~ /^(v|r)/ ? 'right' : 'left'),
      pctwidth => toPercent($_[2])); });

sub toPercent {
  my ($dimen) = @_;
  return int(100 * $dimen->valueOf / LookupValue('\textwidth')->valueOf) . '%'; }

DefMacro('\fltitem[]{}',    '\item {#2}');
DefMacro('\fltditem[]{}{}', '\item[#2] {#3}');

DefMacro('\initfloatingfigs', '');    # ?????
#======================================================================
DefMacro('\dofigtest', '');
DefMacro('\dotabtest', '');
DefMacro('\tryfig',    '');
DefMacro('\trytab',    '');
DefMacro('\figinsert', '');
DefMacro('\tabinsert', '');
DefMacro('\dohang',    '');
DefMacro('\dohangt',   '');

DefRegister('\figbox'  => Box());
DefRegister('\tabbox'  => Box());
DefRegister('\pagebox' => Box());

DefRegister('\ffigcount' => Number(0));
DefRegister('\ftabcount' => Number(0));
DefRegister('\fftest'    => Number(0));
DefRegister('\hangcount' => Number(0));

DefRegister('\nosuccesstryfig' => Number(0));
DefRegister('\nosuccesstrytab' => Number(0));

DefRegister('\figgutter' => Dimension('1pc'));
DefRegister('\tabgutter' => Dimension('1pc'));

DefRegister('\htdone'      => Number(0));
DefRegister('\pageht'      => Dimension('0pt'));
DefRegister('\startpageht' => Dimension('0pt'));

DefRegister('\tabbredd'      => Dimension('0pt'));
DefRegister('\floatfltwidth' => Dimension('0pt'));
DefRegister('\fltitemwidth'  => Dimension('0pt'));
DefRegister('\outputpretest' => Tokens());

RawTeX(<<'EoTeX');
\newif\iftryingfig     \tryingfigfalse
\newif\iftryingtab     \tryingtabfalse
\newif\ifdoingfig      \doingfigfalse
\newif\ifdoingtab      \doingtabfalse
\newif\iffigprocessing \figprocessingfalse
\newif\iftabprocessing \tabprocessingfalse
\newif\ifpageafterfig  \pageafterfigfalse
\newif\ifpageaftertab  \pageaftertabfalse
\newif\ifoddpages
\newif\ifoutput
EoTeX
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1;