File: float.py

package info (click to toggle)
plastex 3.1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,132 kB
  • sloc: python: 23,341; xml: 18,076; javascript: 7,755; ansic: 46; makefile: 40; sh: 26
file content (45 lines) | stat: -rw-r--r-- 1,361 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
from plasTeX import Command
from plasTeX.Base.LaTeX.Floats import Float, Caption

class newfloat(Command):
    args = 'name:str pos:str capfile:str [ reset:str ]'
    def invoke(self, tex):
        Command.invoke(self, tex)
        name = str(self.attributes['name'])

        # Create the float class and the caption class
        floatcls = type(name, (Float,), {})
        captioncls = type('caption', (Caption,),
                                  {'macroName':'caption', 'counter':name})
        floatcls.caption = captioncls
        c = self.ownerDocument.context
        c.addGlobal(name, floatcls)

        # Create a counter
        resetby = self.attributes['reset'] or 'chapter'
        c.newcounter(name, resetby, 0, format='${the%s}.${%s}' % (resetby,name))

        # Create the float name macro
        c.newcommand(name+'name', 0, name)


class floatstyle(Command):
    args = 'style:str'

class restylefloat(Command):
    args = 'float:str'

class floatname(Command):
    args = 'float:str name:str'
    def invoke(self, tex):
        Command.invoke(self, tex)
        float = str(self.attributes['float'])
        name = self.attributes['name']
        c = self.ownerDocument.context
        c.newcommand(float+'name', 0, name)

class floatplacement(Command):
    args = 'float:str pos:str'

class listof(Command):
    args = 'float:str title'