diff options
| author | wiemann <wiemann@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2005-09-12 21:22:07 +0000 |
|---|---|---|
| committer | wiemann <wiemann@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2005-09-12 21:22:07 +0000 |
| commit | 4dc02f84713a1d42aceb8b166a09be53c4197511 (patch) | |
| tree | 90c217080734d6937f957448a0a5e32db61bbc8c | |
| parent | 975c77459fea84f0af7d2f435309cdbc1f512fbe (diff) | |
| download | docutils-4dc02f84713a1d42aceb8b166a09be53c4197511.tar.gz | |
more tests, more handling for edge cases, some polishing
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@3875 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
| -rw-r--r-- | docutils/docutils/writers/newlatex2e.py | 9 | ||||
| -rw-r--r-- | docutils/test/functional/input/data/latex.txt | 114 | ||||
| -rw-r--r-- | docutils/tools/stylesheets/latex.tex | 50 |
3 files changed, 142 insertions, 31 deletions
diff --git a/docutils/docutils/writers/newlatex2e.py b/docutils/docutils/writers/newlatex2e.py index 3ea14eaca..aaafa0424 100644 --- a/docutils/docutils/writers/newlatex2e.py +++ b/docutils/docutils/writers/newlatex2e.py @@ -362,10 +362,11 @@ class LaTeXTranslator(nodes.SparseNodeVisitor): siblings = [n for n in paragraph.parent if self.is_visible(n) and not isinstance(n, nodes.Titular)] index = siblings.index(paragraph) - if 'continued' in paragraph['classes']: + if ('continued' in paragraph['classes'] or + index > 0 and isinstance(siblings[index-1], nodes.transition)): return 0 # Indent all but the first paragraphs. - return index > 1 + return index > 0 def before_paragraph(self, node): self.append(r'\renewcommand{\Dparagraphindented}{%s}' @@ -492,7 +493,7 @@ class LaTeXTranslator(nodes.SparseNodeVisitor): self.process_backlinks(node, 'citation') def before_table(self, node): - # A tables contains exactly one tgroup. See before_tgroup. + # A table contains exactly one tgroup. See before_tgroup. pass def before_tgroup(self, node): @@ -507,7 +508,7 @@ class LaTeXTranslator(nodes.SparseNodeVisitor): for w in widths: # 0.93 is probably wrong in many cases. XXX Find a # solution which works *always*. - tablespec += r'p{%s\linewidth}|' % (0.93 * w / + tablespec += r'p{%s\textwidth}|' % (0.93 * w / max(total_width, 60)) self.append(r'\Dmaketable{%s}{' % tablespec) self.context.append('}') diff --git a/docutils/test/functional/input/data/latex.txt b/docutils/test/functional/input/data/latex.txt index ee9c02a4d..20d59db1e 100644 --- a/docutils/test/functional/input/data/latex.txt +++ b/docutils/test/functional/input/data/latex.txt @@ -83,28 +83,108 @@ Nested Elements :Field list: | Line | Block -:Another field: * Bullet - * list +:Field 2: * Bullet + * list +:Another (longer) field: * Bullet + * list +:Yet another long field: + * .. comment + + Bullet + + .. comment + + * .. comment + + list + + .. comment + +:Field: * This + + is + + a + + * bullet + + list + +:Field: * | This is + | a bullet + * | list with + | line blocks +:Last field: Last field. * * * * * * * * Deeply nested list. 1. 2. 3. 4. 5. 6. 7. 8. Deeply nested list. -+---------------+ -| | Line block | -| | -| * Bullet list | -| | -| :: | -| | -| Literal | -| block | -+---------------+ -| :Field 1: | -| Text. | -| :Field 2: | -| More text. | -+---------------+ ++-----------------+ +| | Line block | +| | +| * Bullet list | +| | +| :: | +| | +| Literal | +| block | ++-----------------+ +| :Field 1: | +| Text. | +| :Field 2: | +| More text. | ++-----------------+ +| +-------+-----+ | +| | A |* foo| | +| | nested| | | +| | table.|* bar| | +| +-------+-----+ | ++-----------------+ +| This is a | +| paragraph. | +| | +| +-------+-----+ | +| | A |* foo| | +| | nested| | | +| | table.|* bar| | +| +-------+-----+ | +| | +| Another longer | +| paragraph. | ++-----------------+ +| * A list. | +| * A list. | +| | +| +-------+-----+ | +| | A |* foo| | +| | nested| | | +| | table.|* bar| | +| +-------+-----+ | +| | +| * Another list. | +| * Another list. | ++-----------------+ +| Foo | +| | +| Bar | ++-----------------+ +| * Foo | +| | +| * Bar | ++-----------------+ +| * This is a | +| paragraph. | +| | +| This is a | +| paragraph. | +| | +| * This is a | +| paragraph. | +| | +| This is a | +| paragraph. | ++-----------------+ Images diff --git a/docutils/tools/stylesheets/latex.tex b/docutils/tools/stylesheets/latex.tex index 515c34099..eb19ddb8e 100644 --- a/docutils/tools/stylesheets/latex.tex +++ b/docutils/tools/stylesheets/latex.tex @@ -428,7 +428,7 @@ \Dprovidelength{\Dlistspacing}{0.8\baselineskip} \providecommand{\Dsetlistrightmargin}{% - \ifthenelse{\lengthtest{\linewidth>10em}}{% + \ifthenelse{\lengthtest{\linewidth>12em}}{% % Equal margins. \setlength{\rightmargin}{\leftmargin}% }{% @@ -842,11 +842,23 @@ % 1. Table spec (like "|p|p|"). % 2. Table contents. {% - \renewcommand{\Dinsidetabular}{true}% - \begin{longtable}{#1}% - \hline% - #2% - \end{longtable}% + \ifthenelse{\equal{\Dinsidetabular}{true}}{% + % Inside longtable; we cannot have nested longtables. + % The following \vspace *adds* vertical space. I have no idea + % how to do this in a cleaner way. + %\mbox{}\par\vspace{-0.5em}% + \begin{tabular}{#1}% + \hline% + #2% + \end{tabular}% + %\par\noindent\vspace{-0.5em}% + }{% + \renewcommand{\Dinsidetabular}{true}% + \begin{longtable}{#1}% + \hline% + #2% + \end{longtable}% + }% }% } \providecommand{\DNthead}[1]{% @@ -857,20 +869,38 @@ #1\tabularnewline% \hline% } +\providecommand{\Dinsidemulticolumn}{false} +\providecommand{\Dcompensatingmulticol}[3]{% + \multicolumn{#1}{#2}{% + {% + \renewcommand{\Dinsidemulticolumn}{true}% + % Compensate for weird missing vertical space at top of paragraph. + \raisebox{-2.5pt}{#3}% + }% + }% +} \providecommand{\Dcolspan}[2]{% % Take care of the morecols attribute (but incremented by 1). - &\multicolumn{#1}{l|}{#2}% + &% + \Dcompensatingmulticol{#1}{l|}{#2}% } \providecommand{\Dcolspanleft}[2]{% % Like \Dmorecols, but called for the leftmost entries in a table % row. - \multicolumn{#1}{|l|}{#2}% + \Dcompensatingmulticol{#1}{|l|}{#2}% } \providecommand{\Dsubsequententry}[1]{% % } -% \DNentry is not used because we set the ampersand ("&") in the -% \DAcolspan... macros. +\providecommand{\DNentry}[1]{% + % The following sequence adds minimal vertical space above the top + % lines of the first cell paragraph, so that vertical space is + % balanced at the top and bottom of table cells. + \ifthenelse{\equal{\Dinsidemulticolumn}{false}}{% + \vspace{-1em}\vspace{-\parskip}\par% + }{}% + #1% +} \providecommand{\DAtableheaderentry}[5]{\Dformattableheaderentry{#5}} \providecommand{\Dformattableheaderentry}[1]{{\bfseries#1}} |
