forced tables flush left, cell styles implemented

svn: r758
This commit is contained in:
Donald A. Peterson 2002-02-06 16:03:24 +00:00
parent e75b7162d2
commit 111f053c08

View File

@ -211,6 +211,7 @@ class LaTeXDoc(TextDoc):
if self.in_list: if self.in_list:
self.in_list = 0 self.in_list = 0
self.f.write('\n\\end{enumerate}\n') self.f.write('\n\\end{enumerate}\n')
newline = _('')
elif self.in_table: elif self.in_table:
newline = _('') newline = _('')
@ -232,55 +233,74 @@ class LaTeXDoc(TextDoc):
"""Begin new table""" """Begin new table"""
self.in_table = 1 self.in_table = 1
self.currow = 0 self.currow = 0
# We need to know a priori how many columns are in this table # We need to know a priori how many columns are in this table
self.tblstyle = self.table_styles[style_name] self.tblstyle = self.table_styles[style_name]
self.numcols = self.tblstyle.get_columns() self.numcols = self.tblstyle.get_columns()
tblfmt = _('*{%d}{l}' % self.numcols) tblfmt = _('*{%d}{l}' % self.numcols)
self.f.write('\n\n\\begin{longtable}{%s}\n' % tblfmt) self.f.write('\n\n\\begin{longtable}[l]{%s}\n' % tblfmt)
def end_table(self): def end_table(self):
"""Close the table environment""" """Close the table environment"""
self.in_table = 0 self.in_table = 0
# Using \hfill immediately after the tabular should left-justify # Create a paragraph separation below the table.
# the entire table, then create a paragraph separation below it. self.f.write('\\end{longtable}\n\\par\n')
self.f.write('\\end{longtable}\n\\hfill\\par\n')
def start_row(self): def start_row(self):
"""Begin a new row""" """Begin a new row"""
# doline is a flag for adding "\hline" at the end # doline/skipfirst are flags for adding hor. rules
# (doesn't quite work yet) self.doline = 0
# self.doline = 0 self.skipfirst = 0
self.curcol = 1 self.curcol = 0
self.currow = self.currow + 1 self.currow = self.currow + 1
def end_row(self): def end_row(self):
"""End the row (new line)""" """End the row (new line)"""
if self.currow == 1: self.f.write('\\\\ ')
self.f.write('\\\\ \\hline\n') if self.doline == 1:
if self.skipfirst == 1:
self.f.write('\\cline{2-%d}\n' % self.numcols)
else:
self.f.write('\\hline\n')
else: else:
self.f.write('\\\\ \n') self.f.write('\n')
def start_cell(self,style_name,span=1): def start_cell(self,style_name,span=1):
"""Add an entry to the table. """Add an entry to the table.
We always place our data inside braces We always place our data inside braces
for safety of formatting.""" for safety of formatting."""
self.colspan = span self.colspan = span
cellfmt = "" self.curcol = self.curcol + self.colspan
if span != 1:
cellfmt = ('\\multicolumn{%d}{l}{' % span) self.cstyle = self.cell_styles[style_name]
# self.doline = 1 self.lborder = self.cstyle.get_left_border()
self.rborder = self.cstyle.get_right_border()
self.bborder = self.cstyle.get_bottom_border()
self.tborder = self.cstyle.get_top_border()
cellfmt = "l"
# Account for vertical rules
if self.lborder == 1:
cellfmt = '|' + cellfmt
if self.rborder == 1:
cellfmt = cellfmt + '|'
# and Horizontal rules
if self.bborder == 1:
self.doline = 1
elif self.curcol == 1:
self.skipfirst = 1
self.f.write('%s' % cellfmt) if self.tborder != 0:
self.curcol = self.curcol + span self.f.write('\\hline\n')
self.f.write ('\\multicolumn{%d}{%s}{' % (span,cellfmt))
def end_cell(self): def end_cell(self):
"""Prepares for next cell""" """Prepares for next cell"""
if self.colspan > 1: self.f.write('} ')
self.f.write('}')
if self.curcol < self.numcols: if self.curcol < self.numcols:
self.f.write(' & ') self.f.write('& ')
self.f.write(' ')
def add_photo(self,name,pos,x,y): def add_photo(self,name,pos,x,y):
"""Currently no photo support""" """Currently no photo support"""