Anonymous avatar Anonymous committed 788d5fc

Print table headers not only in first page but in next pages

Comments (0)

Files changed (1)

sphinx/writers/latex.py

         self.table = Table()
         self.table.longtable = 'longtable' in node['classes']
         self.tablebody = []
+        self.tableheaders = []
         # Redirect body output until table is finished.
         self._body = self.body
         self.body = self.tablebody
             self.next_table_ids.clear()
         if self.table.longtable:
             self.body.append('\\hline\n')
+            self.body.extend(self.tableheaders)
             self.body.append('\\endfirsthead\n\n')
             self.body.append('\\multicolumn{%s}{c}%%\n' % self.table.colcount)
             self.body.append(r'{{\bfseries \tablename\ \thetable{} -- %s}} \\'
                              % _('continued from previous page'))
             self.body.append('\n\\hline\n')
+            self.body.extend(self.tableheaders)
             self.body.append('\\endhead\n\n')
             self.body.append(ur'\hline \multicolumn{%s}{|r|}{{%s}} \\ \hline'
                              % (self.table.colcount,
             self.body.append('\\endlastfoot\n\n')
         else:
             self.body.append('\\hline\n')
+            self.body.extend(self.tableheaders)
         self.body.extend(self.tablebody)
         self.body.append(endmacro)
         if not self.table.longtable and self.table.caption is not None:
         pass
 
     def visit_thead(self, node):
+        self.table.had_head = True
         if self.next_table_colspec:
             self.table.colspec = '{%s}\n' % self.next_table_colspec
         self.next_table_colspec = None
-        # self.body.append('\\hline\n')
-        # self.table.had_head = True
+        # Redirect head output until header is finished. see visit_tbody.
+        self.body = self.tableheaders
     def depart_thead(self, node):
         pass
 
     def visit_tbody(self, node):
         if not self.table.had_head:
             self.visit_thead(node)
+        self.body = self.tablebody
     def depart_tbody(self, node):
         pass
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.