1#!/usr/bin/env python 2 3from plasTeX import Command 4from plasTeX.Base.LaTeX.Floats import Float, Caption 5 6class newfloat(Command): 7 args = 'name:str pos:str capfile:str [ reset:str ]' 8 def invoke(self, tex): 9 Command.invoke(self, tex) 10 name = str(self.attributes['name']) 11 12 # Create the float class and the caption class 13 floatcls = type(name, (Float,), {}) 14 captioncls = type('caption', (Caption,), 15 {'macroName':'caption', 'counter':name}) 16 floatcls.caption = captioncls 17 c = self.ownerDocument.context 18 c.addGlobal(name, floatcls) 19 20 # Create a counter 21 resetby = self.attributes['reset'] or 'chapter' 22 c.newcounter(name, resetby, 0, format='${the%s}.${%s}' % (resetby,name)) 23 24 # Create the float name macro 25 c.newcommand(name+'name', 0, name) 26 27 28class floatstyle(Command): 29 args = 'style:str' 30 31class restylefloat(Command): 32 args = 'float:str' 33 34class floatname(Command): 35 args = 'float:str name:str' 36 def invoke(self, tex): 37 Command.invoke(self, tex) 38 float = str(self.attributes['float']) 39 name = self.attributes['name'] 40 c = self.ownerDocument.context 41 c.newcommand(float+'name', 0, name) 42 43class floatplacement(Command): 44 args = 'float:str pos:str' 45 46class listof(Command): 47 args = 'float:str title' 48