]> git.llucax.com Git - z.facultad/75.00/informe.git/blobdiff - ext/fig.py
Hacer que el Glosario no tenga número de capítulo
[z.facultad/75.00/informe.git] / ext / fig.py
index d258dea92a14bbe1b9ca387b0613b8c594282313..f777222dc54e8d1cd6dc68b10de4349405536d43 100644 (file)
@@ -27,7 +27,7 @@ class subfig(nodes.General, nodes.Element):
 def latex_visit_subfig(self, node):
     space = '\\hspace{%sin}\n' % node['space'] if node['space'] else ''
     self.body.append(space)
 def latex_visit_subfig(self, node):
     space = '\\hspace{%sin}\n' % node['space'] if node['space'] else ''
     self.body.append(space)
-    self.body.append('\\subfigure')
+    self.body.append('\\subfloat')
 
 def latex_depart_subfig(self, node):
     self.body.append('}\n')
 
 def latex_depart_subfig(self, node):
     self.body.append('}\n')
@@ -67,6 +67,24 @@ class SubfigDirective(Directive):
 # fig
 ############################################################################
 
 # fig
 ############################################################################
 
+class captitle(nodes.Part, nodes.TextElement):
+    pass
+
+def latex_visit_captitle(self, node):
+    self.body.append('\\caption[')
+
+def latex_depart_captitle(self, node):
+    self.body.append(']')
+
+class capdesc(nodes.Part, nodes.TextElement):
+    pass
+
+def latex_visit_capdesc(self, node):
+    self.body.append('{')
+
+def latex_depart_capdesc(self, node):
+    self.body.append('}\n')
+
 class pad(nodes.Part, nodes.TextElement):
     pass
 
 class pad(nodes.Part, nodes.TextElement):
     pass
 
@@ -114,10 +132,28 @@ class FigDirective(Directive):
             fig_node['label'] = self.arguments[0]
         node = nodes.Element() # anonymous container for parsing
         self.state.nested_parse(self.content, self.content_offset, node)
             fig_node['label'] = self.arguments[0]
         node = nodes.Element() # anonymous container for parsing
         self.state.nested_parse(self.content, self.content_offset, node)
-        first_node = node[0]
-        cap = None
-        if isinstance(first_node, nodes.paragraph):
-            cap = nodes.caption(first_node.rawsource, '', *first_node.children)
+        first_node = None
+        second_node = None
+        try:
+            first_node = node[0]
+            second_node = node[1]
+        except IndexError:
+            pass
+        is_first_para = isinstance(first_node, nodes.paragraph)
+        is_second_para = isinstance(second_node, nodes.paragraph)
+        capt = None
+        capd = None
+        if is_first_para and is_second_para:
+            capt = captitle(first_node.rawsource, '', *first_node.children)
+            capd = capdesc(second_node.rawsource, '', *second_node.children)
+            node = node[2:]
+        elif is_first_para:
+            capt = captitle(first_node.rawsource, '', *first_node.children)
+            capd = capdesc(first_node.rawsource, '', *first_node.children)
+            node = node[1:]
+        elif is_second_para:
+            capt = captitle(second_node.rawsource, '', *second_node.children)
+            capd = capdesc(second_node.rawsource, '', *second_node.children)
             node = node[1:]
         first = True
         children = []
             node = node[1:]
         first = True
         children = []
@@ -130,8 +166,9 @@ class FigDirective(Directive):
                             inches=fig_node['padding']))
             children.append(n)
         fig_node += children
                             inches=fig_node['padding']))
             children.append(n)
         fig_node += children
-        if cap:
-            fig_node += cap
+        if capt and capd:
+            fig_node += capt
+            fig_node += capd
         return [fig_node]
 
 
         return [fig_node]
 
 
@@ -139,6 +176,8 @@ class FigDirective(Directive):
 def setup(app):
     app.add_node(subcap, latex=(latex_visit_subcap, latex_depart_subcap))
     app.add_node(subfig, latex=(latex_visit_subfig, latex_depart_subfig))
 def setup(app):
     app.add_node(subcap, latex=(latex_visit_subcap, latex_depart_subcap))
     app.add_node(subfig, latex=(latex_visit_subfig, latex_depart_subfig))
+    app.add_node(captitle, latex=(latex_visit_captitle, latex_depart_captitle))
+    app.add_node(capdesc, latex=(latex_visit_capdesc, latex_depart_capdesc))
     app.add_node(pad, latex=(latex_visit_pad, latex_depart_pad))
     app.add_node(fig, latex=(latex_visit_fig, latex_depart_fig))
     app.add_directive('fig', FigDirective)
     app.add_node(pad, latex=(latex_visit_pad, latex_depart_pad))
     app.add_node(fig, latex=(latex_visit_fig, latex_depart_fig))
     app.add_directive('fig', FigDirective)