diff options
author | Jean-François B <jfbu@free.fr> | 2017-02-05 20:37:24 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-05 20:37:24 +0100 |
commit | 2e83241486c94cc43e870073e5306b202dbda401 (patch) | |
tree | eb009e5b16c41bcdcfbc8af3e73675d61b2547ea | |
parent | aefa1e0ab7f47a51b3dc537717ea57ab856a31ba (diff) | |
parent | 368e5d87275cdf8722cb9d95234be1102a704616 (diff) | |
download | sphinx-git-2e83241486c94cc43e870073e5306b202dbda401.tar.gz |
Merge pull request #3390 from jfbu/latex_table_newlines
Latex table newlines
-rw-r--r-- | sphinx/templates/latex/longtable.tex_t | 10 | ||||
-rw-r--r-- | sphinx/templates/latex/tabular.tex_t | 10 | ||||
-rw-r--r-- | sphinx/templates/latex/tabulary.tex_t | 10 | ||||
-rw-r--r-- | sphinx/writers/latex.py | 2 | ||||
-rw-r--r-- | tests/test_build_latex.py | 22 |
5 files changed, 28 insertions, 26 deletions
diff --git a/sphinx/templates/latex/longtable.tex_t b/sphinx/templates/latex/longtable.tex_t index 694483ce2..516f6d0fa 100644 --- a/sphinx/templates/latex/longtable.tex_t +++ b/sphinx/templates/latex/longtable.tex_t @@ -3,19 +3,21 @@ \caption{<%= ''.join(table.caption) %>}<%= labels %>\\ <% endif -%> \hline -<%= ''.join(table.header) -%> +<%= ''.join(table.header) %> \endfirsthead \multicolumn{<%= table.colcount %>}{c}% {{\tablecontinued{\tablename\ \thetable{} -- <%= _('continued from previous page') %>}}} \\ \hline -<%= ''.join(table.header) -%> +<%= ''.join(table.header) %> \endhead -\hline \multicolumn{<%= table.colcount %>}{|r|}{{\tablecontinued{<%= _('Continued on next page') %>}}} \\ \hline +\hline +\multicolumn{<%= table.colcount %>}{|r|}{{\tablecontinued{<%= _('Continued on next page') %>}}} \\ +\hline \endfoot \endlastfoot -<%= ''.join(table.body) -%> +<%= ''.join(table.body) %> \end{longtable} diff --git a/sphinx/templates/latex/tabular.tex_t b/sphinx/templates/latex/tabular.tex_t index 7448d6c1f..27e5c30c0 100644 --- a/sphinx/templates/latex/tabular.tex_t +++ b/sphinx/templates/latex/tabular.tex_t @@ -1,12 +1,12 @@ <%- if table.caption -%> \begin{threeparttable} \capstart\caption{<%= ''.join(table.caption) %>}<%= labels %> -<%- endif %> +<% endif -%> \noindent\begin{tabular}<%= table.get_colspec() -%> \hline -<%= ''.join(table.header) -%> -<%= ''.join(table.body) -%> +<%= ''.join(table.header) %> +<%=- ''.join(table.body) %> \end{tabular} -<%- if table.caption -%> +<%- if table.caption %> \end{threeparttable} -<%- endif -%> +<%- endif %> diff --git a/sphinx/templates/latex/tabulary.tex_t b/sphinx/templates/latex/tabulary.tex_t index 959eadcbd..11ec79b33 100644 --- a/sphinx/templates/latex/tabulary.tex_t +++ b/sphinx/templates/latex/tabulary.tex_t @@ -1,12 +1,12 @@ <%- if table.caption -%> \begin{threeparttable} \capstart\caption{<%= ''.join(table.caption) %>}<%= labels %> -<%- endif %> +<% endif -%> \noindent\begin{tabulary}{\linewidth}<%= table.get_colspec() -%> \hline -<%= ''.join(table.header) -%> -<%= ''.join(table.body) -%> +<%= ''.join(table.header) %> +<%=- ''.join(table.body) %> \end{tabulary} -<%- if table.caption -%> +<%- if table.caption %> \end{threeparttable} -<%- endif -%> +<%- endif %> diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index 7cdec13c9..5858ad85e 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -1216,7 +1216,7 @@ class LaTeXTranslator(nodes.NodeVisitor): dict(table=self.table, labels=labels)) self.body.append("\n\n") self.body.append(table) - self.body.append("\n\n") + self.body.append("\n") self.unrestrict_footnote(node) self.table = None diff --git a/tests/test_build_latex.py b/tests/test_build_latex.py index 4813fbbbc..1c1cd3928 100644 --- a/tests/test_build_latex.py +++ b/tests/test_build_latex.py @@ -481,7 +481,7 @@ def test_footnote(app, status, warning): '\ncite\n}') in result assert '\\caption{Table caption \\sphinxfootnotemark[4]' in result assert 'name \\sphinxfootnotemark[5]' in result - assert ('\\end{threeparttable}\n\n%\n' + assert ('\\end{threeparttable}\n%\n' '\\begin{footnotetext}[4]\sphinxAtStartFootnote\n' 'footnotes in table caption\n%\n\\end{footnotetext}%\n' '\\begin{footnotetext}[5]\sphinxAtStartFootnote\n' @@ -514,7 +514,7 @@ def test_reference_in_caption_and_codeblock_in_footnote(app, status, warning): 'in caption of normal table}\\label{\\detokenize{index:id28}}') in result assert ('\\caption{footnote \\sphinxfootnotemark[8] ' 'in caption \sphinxfootnotemark[9] of longtable}') in result - assert ('\end{longtable}\n\n%\n\\begin{footnotetext}[8]' + assert ('\end{longtable}\n%\n\\begin{footnotetext}[8]' '\sphinxAtStartFootnote\n' 'Foot note in longtable\n%\n\\end{footnotetext}' in result) assert ('This is a reference to the code-block in the footnote:\n' @@ -837,7 +837,7 @@ def test_latex_table(app, status, warning): assert ('\\hline\ncell1-1\n&\ncell1-2\n\\\\' in table) assert ('\\hline\ncell2-1\n&\ncell2-2\n\\\\' in table) assert ('\\hline\ncell3-1\n&\ncell3-2\n\\\\' in table) - assert ('\\hline\\end{tabulary}' in table) + assert ('\\hline\n\\end{tabulary}' in table) # table having :widths: option table = tables['table having :widths: option'] @@ -848,7 +848,7 @@ def test_latex_table(app, status, warning): assert ('\\hline\ncell1-1\n&\ncell1-2\n\\\\' in table) assert ('\\hline\ncell2-1\n&\ncell2-2\n\\\\' in table) assert ('\\hline\ncell3-1\n&\ncell3-2\n\\\\' in table) - assert ('\\hline\\end{tabular}' in table) + assert ('\\hline\n\\end{tabular}' in table) # table with tabularcolumn table = tables['table with tabularcolumn'] @@ -865,7 +865,7 @@ def test_latex_table(app, status, warning): assert ('\\hline\ncell1-1\n&\ncell1-2\n\\\\' in table) assert ('\\hline\ncell2-1\n&\ncell2-2\n\\\\' in table) assert ('\\hline\ncell3-1\n&\ncell3-2\n\\\\' in table) - assert ('\\hline\\end{tabulary}' in table) + assert ('\\hline\n\\end{tabulary}' in table) assert ('\\end{threeparttable}' in table) # table having verbatim @@ -886,20 +886,20 @@ def test_latex_table(app, status, warning): assert ('\\hline\n' '\\sphinxstylethead{\\relax \nheader1\n\\unskip}\\relax &' '\\sphinxstylethead{\\relax \nheader2\n\\unskip}\\relax \\\\\n' - '\\hline\\endfirsthead' in table) + '\\hline\n\\endfirsthead' in table) assert ('\\multicolumn{2}{c}%\n' '{{\\tablecontinued{\\tablename\\ \\thetable{} -- ' 'continued from previous page}}} \\\\\n\\hline\n' '\\sphinxstylethead{\\relax \nheader1\n\\unskip}\\relax &' '\\sphinxstylethead{\\relax \nheader2\n\\unskip}\\relax \\\\\n' - '\\hline\\endhead' in table) - assert ('\\hline \\multicolumn{2}{|r|}' - '{{\\tablecontinued{Continued on next page}}} \\\\ \\hline\n' - '\\endfoot\n\n\\endlastfoot' in table) + '\\hline\n\\endhead' in table) + assert ('\\hline\n\\multicolumn{2}{|r|}' + '{{\\tablecontinued{Continued on next page}}} \\\\\n' + '\\hline\n\\endfoot\n\n\\endlastfoot' in table) assert ('\ncell1-1\n&\ncell1-2\n\\\\' in table) assert ('\\hline\ncell2-1\n&\ncell2-2\n\\\\' in table) assert ('\\hline\ncell3-1\n&\ncell3-2\n\\\\' in table) - assert ('\\hline\\end{longtable}' in table) + assert ('\\hline\n\\end{longtable}' in table) # longtable having :widths: option table = tables['longtable having :widths: option'] |