Additional changes for 0004605: Multiple improvements for LaTeX output (patch from Harald Rosemann)
svn: r18034
This commit is contained in:
parent
a175533a07
commit
89a4032499
@ -320,10 +320,11 @@ def latexescapeverbatim(text):
|
|||||||
text = text.replace('{', '\\{')
|
text = text.replace('{', '\\{')
|
||||||
text = text.replace('}', '\\}')
|
text = text.replace('}', '\\}')
|
||||||
text = text.replace(' ', '\\ ')
|
text = text.replace(' ', '\\ ')
|
||||||
text = text.replace('\n', '\\newline\n')
|
text = text.replace('\n', '~\\newline\n')
|
||||||
#spaces at begin are normally ignored, make sure they are not.
|
#spaces at begin are normally ignored, make sure they are not.
|
||||||
#due to above a space at begin is now \newline\n\
|
#due to above a space at begin is now \newline\n\
|
||||||
text = text.replace('\\newline\n\\ ', '\\newline\n\\hspace*{0.1\\grbaseindent}\\ ')
|
text = text.replace('\\newline\n\\ ',
|
||||||
|
'\\newline\n\\hspace*{0.1\\grbaseindent}\\ ')
|
||||||
return text
|
return text
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
@ -434,7 +435,6 @@ class LaTeXDoc(BaseDoc, TextDoc):
|
|||||||
in_table = False
|
in_table = False
|
||||||
spec_var_col = 0
|
spec_var_col = 0
|
||||||
textmem = []
|
textmem = []
|
||||||
akt_paragr_style = ''
|
|
||||||
in_title = True
|
in_title = True
|
||||||
|
|
||||||
|
|
||||||
@ -475,16 +475,15 @@ class LaTeXDoc(BaseDoc, TextDoc):
|
|||||||
self.tabcell = Tab_Cell(self.curcol_char, span, text)
|
self.tabcell = Tab_Cell(self.curcol_char, span, text)
|
||||||
elif tab_state == CELL_TEXT:
|
elif tab_state == CELL_TEXT:
|
||||||
self.textmem.append(text)
|
self.textmem.append(text)
|
||||||
|
|
||||||
elif tab_state == CELL_END: # text == ''
|
elif tab_state == CELL_END: # text == ''
|
||||||
if self.textmem:
|
self.tabcell.content = ''.join(self.textmem)
|
||||||
if self.textmem[0].find('\\centering') != -1:
|
if self.tabcell.content.find('\\centering') != -1:
|
||||||
self.textmem[0] = self.textmem[0].replace(
|
self.tabcell.content = self.tabcell.content.replace(
|
||||||
'\\centering', '')
|
'\\centering', '')
|
||||||
self.tabcell.head = re.sub(
|
self.tabcell.head = re.sub(
|
||||||
TBLFMT_PAT, '\\1c\\2', self.tabcell.head)
|
TBLFMT_PAT, '\\1c\\2', self.tabcell.head)
|
||||||
if self.textmem[-1].endswith(PAT_FOR_LINE_BREAK):
|
self.tabcell.content = self.tabcell.content.replace('\n\n}', '}')
|
||||||
self.textmem[-1] = self.textmem[-1][:-2]
|
|
||||||
self.tabcell.content = ''.join(self.textmem)
|
|
||||||
self.tabrow.cells.append(self.tabcell)
|
self.tabrow.cells.append(self.tabcell)
|
||||||
self.textmem = []
|
self.textmem = []
|
||||||
elif tab_state == ROW_BEG:
|
elif tab_state == ROW_BEG:
|
||||||
@ -539,7 +538,7 @@ class LaTeXDoc(BaseDoc, TextDoc):
|
|||||||
self._backend.write(''.join(('\\grcalctextwidth{',
|
self._backend.write(''.join(('\\grcalctextwidth{',
|
||||||
part, '}{\\grcolwidth', col_char, '}%\n')))
|
part, '}{\\grcolwidth', col_char, '}%\n')))
|
||||||
row.cells[col_num].content = cell.content.replace(
|
row.cells[col_num].content = cell.content.replace(
|
||||||
PAT_FOR_LINE_BREAK, '\\newline %\n')
|
PAT_FOR_LINE_BREAK, '~\\newline %\n')
|
||||||
self._backend.write(''.join(('\\addtolength{\\grwidthused}{',
|
self._backend.write(''.join(('\\addtolength{\\grwidthused}{',
|
||||||
'\\grcolwidth', col_char, '+\\tabcolsep}%\n')))
|
'\\grcolwidth', col_char, '+\\tabcolsep}%\n')))
|
||||||
self._backend.write(''.join(('\\inittabvars{',
|
self._backend.write(''.join(('\\inittabvars{',
|
||||||
@ -563,7 +562,7 @@ class LaTeXDoc(BaseDoc, TextDoc):
|
|||||||
for part in lines:
|
for part in lines:
|
||||||
self._backend.write(''.join(('\\grcalctextwidth{', part, '}{',
|
self._backend.write(''.join(('\\grcalctextwidth{', part, '}{',
|
||||||
row.spec_var_cell_width, '}%\n')))
|
row.spec_var_cell_width, '}%\n')))
|
||||||
row.cells[self.spec_var_col].content = '\\newline %\n'.join(lines)
|
row.cells[self.spec_var_col].content = '~\\newline %\n'.join(lines)
|
||||||
|
|
||||||
# shorten cells too long, calc row-length, search max row width
|
# shorten cells too long, calc row-length, search max row width
|
||||||
self._backend.write('\\inittabvars{\\grspangain}{0.0em}')
|
self._backend.write('\\inittabvars{\\grspangain}{0.0em}')
|
||||||
@ -664,7 +663,7 @@ class LaTeXDoc(BaseDoc, TextDoc):
|
|||||||
row.spec_var_cell_width, '}')))
|
row.spec_var_cell_width, '}')))
|
||||||
leading = ''.join(('{\\tabrowstrutceil\\begin{minipage}[t]{',
|
leading = ''.join(('{\\tabrowstrutceil\\begin{minipage}[t]{',
|
||||||
row.spec_var_cell_width, '}{'))
|
row.spec_var_cell_width, '}{'))
|
||||||
closing = '\\tabrowstrutfloor}\\end{minipage}} & %\n'
|
closing = '}\\end{minipage}} & %\n'
|
||||||
complete.append(''.join((cell.head, leading,
|
complete.append(''.join((cell.head, leading,
|
||||||
cell.content, closing)))
|
cell.content, closing)))
|
||||||
return ''.join((''.join(complete)[:-4], '%\n', row.tail, row.addit))
|
return ''.join((''.join(complete)[:-4], '%\n', row.tail, row.addit))
|
||||||
@ -728,8 +727,7 @@ class LaTeXDoc(BaseDoc, TextDoc):
|
|||||||
align = style.get_alignment_text()
|
align = style.get_alignment_text()
|
||||||
if align == "center":
|
if align == "center":
|
||||||
thisstyle.font_beg += "{\\centering"
|
thisstyle.font_beg += "{\\centering"
|
||||||
thisstyle.font_end = ''.join(("\n\n}",
|
thisstyle.font_end = ''.join(("\n\n}", thisstyle.font_end))
|
||||||
thisstyle.font_end))
|
|
||||||
elif align == "right":
|
elif align == "right":
|
||||||
thisstyle.font_beg += "\\hfill"
|
thisstyle.font_beg += "\\hfill"
|
||||||
|
|
||||||
@ -774,7 +772,6 @@ class LaTeXDoc(BaseDoc, TextDoc):
|
|||||||
"""Paragraphs handling - A Gramps paragraph is any
|
"""Paragraphs handling - A Gramps paragraph is any
|
||||||
single body of text from a single word to several sentences.
|
single body of text from a single word to several sentences.
|
||||||
We assume a linebreak at the end of each paragraph."""
|
We assume a linebreak at the end of each paragraph."""
|
||||||
self.akt_paragr_style= style_name
|
|
||||||
style_sheet = self.get_style_sheet()
|
style_sheet = self.get_style_sheet()
|
||||||
|
|
||||||
style = style_sheet.get_paragraph_style(style_name)
|
style = style_sheet.get_paragraph_style(style_name)
|
||||||
@ -827,7 +824,7 @@ class LaTeXDoc(BaseDoc, TextDoc):
|
|||||||
'\\item%\n')))
|
'\\item%\n')))
|
||||||
|
|
||||||
|
|
||||||
if leader is None and not self.in_list and not self.in_table:
|
if leader is None:
|
||||||
self.emit('\n')
|
self.emit('\n')
|
||||||
self.emit('%s ' % self.fbeg)
|
self.emit('%s ' % self.fbeg)
|
||||||
|
|
||||||
@ -839,12 +836,11 @@ class LaTeXDoc(BaseDoc, TextDoc):
|
|||||||
self.emit('\n\\end{list}\n')
|
self.emit('\n\\end{list}\n')
|
||||||
newline = ''
|
newline = ''
|
||||||
elif self.in_table:
|
elif self.in_table:
|
||||||
newline = (PAT_FOR_LINE_BREAK)
|
newline = ''
|
||||||
|
|
||||||
self.emit('%s%s' % (self.fend, newline))
|
self.emit('%s%s' % (self.fend, newline))
|
||||||
if self.fix_indent:
|
if self.fix_indent:
|
||||||
self.emit(
|
self.emit('\\end{minipage}\\parindent0em%\n\n')
|
||||||
'\\end{minipage}\\parindent0em%\n\n')
|
|
||||||
self.fix_indent = False
|
self.fix_indent = False
|
||||||
|
|
||||||
def start_bold(self):
|
def start_bold(self):
|
||||||
@ -1040,7 +1036,7 @@ class LaTeXDoc(BaseDoc, TextDoc):
|
|||||||
self.start_paragraph(style_name)
|
self.start_paragraph(style_name)
|
||||||
for realline in line.split('\n'):
|
for realline in line.split('\n'):
|
||||||
self.emit(realline)
|
self.emit(realline)
|
||||||
self.emit("\\newline%\n")
|
self.emit("~\\newline%\n")
|
||||||
self.end_paragraph()
|
self.end_paragraph()
|
||||||
|
|
||||||
def write_endnotes_ref(self, text, style_name):
|
def write_endnotes_ref(self, text, style_name):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user