diff --git a/doc/usage/configuration.rst b/doc/usage/configuration.rst index 9e6230cd2db..00c3ba8f67c 100644 --- a/doc/usage/configuration.rst +++ b/doc/usage/configuration.rst @@ -2241,6 +2241,16 @@ These options influence LaTeX output. .. versionadded:: 1.8 +.. confval:: latex_use_booktabs + + If ``True``, render tables without vertical rules and horizontal rules of + varying thickness (with additional space above and below) using the + booktabs_ package. + + .. _booktabs: https://ctan.org/pkg/booktabs + + .. versionadded:: 5.2.0 + .. confval:: latex_elements .. versionadded:: 0.5 diff --git a/sphinx/builders/latex/__init__.py b/sphinx/builders/latex/__init__.py index 32f9d32ef88..f02e69483e6 100644 --- a/sphinx/builders/latex/__init__.py +++ b/sphinx/builders/latex/__init__.py @@ -170,6 +170,7 @@ def init_context(self) -> None: self.context.update(self.config.latex_elements) self.context['release'] = self.config.release self.context['use_xindy'] = self.config.latex_use_xindy + self.context['use_booktabs'] = self.config.latex_use_booktabs if self.config.today: self.context['date'] = self.config.today @@ -517,6 +518,7 @@ def setup(app: Sphinx) -> Dict[str, Any]: app.add_config_value('latex_appendices', [], None) app.add_config_value('latex_use_latex_multicolumn', False, None) app.add_config_value('latex_use_xindy', default_latex_use_xindy, None, [bool]) + app.add_config_value('latex_use_booktabs', False, None) app.add_config_value('latex_toplevel_sectioning', None, None, ENUM(None, 'part', 'chapter', 'section')) app.add_config_value('latex_domain_indices', True, None, [list]) diff --git a/sphinx/templates/latex/latex.tex_t b/sphinx/templates/latex/latex.tex_t index 66408a4c4a5..1cebac93418 100644 --- a/sphinx/templates/latex/latex.tex_t +++ b/sphinx/templates/latex/latex.tex_t @@ -25,6 +25,9 @@ %% memoir class requires extra handling \makeatletter\@ifclassloaded{memoir} {\ifdefined\memhyperindexfalse\memhyperindexfalse\fi}{}\makeatother +<% endif %> +<% if use_booktabs -%> +\PassOptionsToPackage{booktabs}{sphinx} <% endif -%> <%= passoptionstopackages %> \PassOptionsToPackage{warn}{textcomp} diff --git a/sphinx/templates/latex/longtable.tex_t b/sphinx/templates/latex/longtable.tex_t index 8d4cd748c1e..a96c2003775 100644 --- a/sphinx/templates/latex/longtable.tex_t +++ b/sphinx/templates/latex/longtable.tex_t @@ -10,25 +10,32 @@ <%- if table.caption -%> \sphinxthelongtablecaptionisattop \caption{<%= ''.join(table.caption) %>\strut}<%= labels %>\\*[\sphinxlongtablecapskipadjust] -\hline +\sphinxtoprule <% elif labels -%> -\hline\noalign{\phantomsection<%= labels %>}% +\sphinxtoprule\noalign{\phantomsection<%= labels %>}% <% else -%> -\hline +\sphinxtoprule +<% endif -%> +<%= ''.join(table.header) -%> +<%- if table.header -%> +\sphinxmidrule <% endif -%> -<%= ''.join(table.header) %> \endfirsthead \multicolumn{<%= table.colcount %>}{c}% {\makebox[0pt]{\sphinxtablecontinued{\tablename\ \thetable{} \textendash{} <%= _('continued from previous page') %>}}}\\ -\hline -<%= ''.join(table.header) %> +\sphinxtoprule +<%= ''.join(table.header) -%> +<%- if table.header -%> +\sphinxmidrule +<% endif -%> \endhead -\hline +\sphinxbottomrule \multicolumn{<%= table.colcount %>}{r}{\makebox[0pt][r]{\sphinxtablecontinued{<%= _('continues on next page') %>}}}\\ \endfoot \endlastfoot -<%= ''.join(table.body) %> +<%= ''.join(table.body) -%> +\sphinxbottomrule \end{longtable}\sphinxatlongtableend\end{savenotes} diff --git a/sphinx/templates/latex/tabular.tex_t b/sphinx/templates/latex/tabular.tex_t index a0db7faff1f..d1a0b97f488 100644 --- a/sphinx/templates/latex/tabular.tex_t +++ b/sphinx/templates/latex/tabular.tex_t @@ -19,9 +19,13 @@ \phantomsection<%= labels %>\nobreak <% endif -%> \begin{tabular}[t]<%= table.get_colspec() -%> -\hline -<%= ''.join(table.header) %> -<%=- ''.join(table.body) %> +\sphinxtoprule +<%= ''.join(table.header) -%> +<%- if table.header -%> +\sphinxmidrule +<%- endif -%> +<%=- ''.join(table.body) -%> +\sphinxbottomrule \end{tabular} \par \sphinxattableend\end{savenotes} diff --git a/sphinx/templates/latex/tabulary.tex_t b/sphinx/templates/latex/tabulary.tex_t index 3236b798a52..f71214f5491 100644 --- a/sphinx/templates/latex/tabulary.tex_t +++ b/sphinx/templates/latex/tabulary.tex_t @@ -19,9 +19,13 @@ \phantomsection<%= labels %>\nobreak <% endif -%> \begin{tabulary}{\linewidth}[t]<%= table.get_colspec() -%> -\hline -<%= ''.join(table.header) %> -<%=- ''.join(table.body) %> +\sphinxtoprule +<%= ''.join(table.header) -%> +<%- if table.header -%> +\sphinxmidrule +<%- endif -%> +<%=- ''.join(table.body) -%> +\sphinxbottomrule \end{tabulary} \par \sphinxattableend\end{savenotes} diff --git a/sphinx/texinputs/sphinx.sty b/sphinx/texinputs/sphinx.sty index 8e01c8ac24c..dabe1d37b75 100644 --- a/sphinx/texinputs/sphinx.sty +++ b/sphinx/texinputs/sphinx.sty @@ -57,6 +57,8 @@ \RequirePackage{kvoptions} \SetupKeyvalOptions{prefix=spx@opt@} % use \spx@opt@ prefix +% Optional usage of booktabs package for tables +\DeclareBoolOption[false]{booktabs} % Sphinx legacy text layout: 1in margins on all four sides \ifx\@jsc@uplatextrue\@undefined \DeclareStringOption[1in]{hmargin} @@ -594,6 +596,7 @@ \DisableKeyvalOption{sphinx}{numfigreset} \DisableKeyvalOption{sphinx}{nonumfigreset} \DisableKeyvalOption{sphinx}{mathnumfig} +\DisableKeyvalOption{sphinx}{booktabs} % FIXME: this is unrelated to an option, move this elsewhere % To allow hyphenation of first word in narrow contexts; no option, % customization to be done via 'preamble' key @@ -724,6 +727,36 @@ %% TABLES % \input{sphinxlatextables.sty} +% Those two are produced by the latex writer +\def\sphinxhline{\hline} +\def\sphinxcline{\cline} +% Those three are inserted by the table templates +\def\sphinxtoprule{\hline} +\def\sphinxmidrule{\hline} +\def\sphinxbottomrule{\hline} +% \def\sphinxarrayrulewidth{\arrayrulewidth}% already done +\ifspx@opt@booktabs + \RequirePackage{booktabs} + \def\sphinxarrayrulewidth{\z@}% (attention! Do NOT assign to \sphinxarrayrulewidth + % this would modify \z@ and break all of LaTeX...) + \let\sphinxhline\@empty + \def\sphinxcline{\cmidrule(lr)}% + \def\sphinxtoprule{\toprule}% + \def\sphinxmidrule{\midrule}% + \def\sphinxbottomrule{\bottomrule}% +\fi +\AtBeginDocument +{\@ifpackageloaded{booktabs}% + {\ifspx@opt@booktabs\else + \AtEndDocument{% +\PackageWarningNoLine{sphinx}{% + Package booktabs is detected but configuration option\MessageBreak + latex_use_booktabs is False. Tables will not use booktabs styling}% +}% + \fi}% + {}% +}% + %% NUMBERING OF FIGURES, TABLES, AND LITERAL BLOCKS diff --git a/sphinx/texinputs/sphinxlatextables.sty b/sphinx/texinputs/sphinxlatextables.sty index c3c1d6ad1ff..bc4cdc44583 100644 --- a/sphinx/texinputs/sphinxlatextables.sty +++ b/sphinx/texinputs/sphinxlatextables.sty @@ -1,7 +1,7 @@ %% TABLES (WITH SUPPORT FOR MERGED CELLS OF GENERAL CONTENTS) % % change this info string if making any custom modification -\ProvidesFile{sphinxlatextables.sty}[2021/01/27 tables]% +\ProvidesFile{sphinxlatextables.sty}[2022/08/07 tables]% % Provides support for this output mark-up from Sphinx latex writer % and table templates: @@ -42,10 +42,11 @@ % sphinxpackagemulticell.sty % X or S (Sphinx) may have meanings if some table package is loaded hence % \X was chosen to avoid possibility of conflict +\def\sphinxarrayrulewidth{\arrayrulewidth}% will be set to \z@ if booktabs option \newcolumntype{\X}[2]{p{\dimexpr - (\linewidth-\arrayrulewidth)*#1/#2-\tw@\tabcolsep-\arrayrulewidth\relax}} + (\linewidth-\sphinxarrayrulewidth)*#1/#2-\tw@\tabcolsep-\sphinxarrayrulewidth\relax}} \newcolumntype{\Y}[1]{p{\dimexpr - #1\dimexpr\linewidth-\arrayrulewidth\relax-\tw@\tabcolsep-\arrayrulewidth\relax}} + #1\dimexpr\linewidth-\sphinxarrayrulewidth\relax-\tw@\tabcolsep-\sphinxarrayrulewidth\relax}} % using here T (for Tabulary) feels less of a problem than the X could be \newcolumntype{T}{J}% % For tables allowing pagebreaks @@ -208,6 +209,10 @@ % \arrayrulewidth space for each column separation in its estimate of available % width). % +% EDIT: Sphinx 5.2.0 uses \sphinxarrayrulewidth which is \z@ if booktabs +% option has been used. Do not mix booktabs option with usage of | in +% tabularcolumns directive. +% % TN. 1b: as Sphinx multicolumn uses neither \omit nor \span, it can not % (easily) get rid of extra macros from >{...} or <{...} between columns. At % least, it has been made compatible with colortbl's \columncolor. @@ -285,12 +290,12 @@ \else % if in an l, r, c type column, try and hope for the best \xdef\sphinx@tempb{\the\dimexpr(\ifx\TY@final\@undefined\linewidth\else - \sphinx@TY@tablewidth\fi-\arrayrulewidth)/\sphinx@tempa - -\tw@\tabcolsep-\arrayrulewidth\relax}% + \sphinx@TY@tablewidth\fi-\sphinxarrayrulewidth)/\sphinx@tempa + -\tw@\tabcolsep-\sphinxarrayrulewidth\relax}% \fi \noindent\kern\sphinx@tempb\relax \xdef\sphinx@multiwidth - {\the\dimexpr\sphinx@multiwidth+\sphinx@tempb+\tw@\tabcolsep+\arrayrulewidth}% + {\the\dimexpr\sphinx@multiwidth+\sphinx@tempb+\tw@\tabcolsep+\sphinxarrayrulewidth}% % hack the \vline and the colortbl macros \sphinx@hack@vline\sphinx@hack@CT&\relax % repeat @@ -299,8 +304,10 @@ % packages like colortbl add group levels, we need to "climb back up" to be % able to hack the \vline and also the colortbl inserted tokens. This creates % empty space whether or not the columns were | separated: +% (5.2.0 sets \sphinxarrayrulewidth to expand to \z@ if booktabs option has been +% made use of, the \arrayrulewidth\z@ serves then nothing but shoud not hurt). \def\sphinx@hack@vline{\ifnum\currentgrouptype=6\relax - \kern\arrayrulewidth\arrayrulewidth\z@\else\aftergroup\sphinx@hack@vline\fi}% + \kern\sphinxarrayrulewidth\arrayrulewidth\z@\else\aftergroup\sphinx@hack@vline\fi}% \def\sphinx@hack@CT{\ifnum\currentgrouptype=6\relax \let\CT@setup\sphinx@CT@setup\else\aftergroup\sphinx@hack@CT\fi}% % It turns out \CT@row@color is not expanded contrarily to \CT@column@color @@ -320,8 +327,8 @@ \else \xdef\sphinx@multiwidth{\the\dimexpr\sphinx@multiwidth+ (\ifx\TY@final\@undefined\linewidth\else - \sphinx@TY@tablewidth\fi-\arrayrulewidth)/\sphinx@tempa - -\tw@\tabcolsep-\arrayrulewidth\relax}% + \sphinx@TY@tablewidth\fi-\sphinxarrayrulewidth)/\sphinx@tempa + -\tw@\tabcolsep-\sphinxarrayrulewidth\relax}% \fi % we need to remove colour set-up also for last cell of the multi-column \aftergroup\sphinx@hack@CT @@ -345,8 +352,8 @@ \linewidth \else % l, c, r columns. Do our best. - \dimexpr(\linewidth-\arrayrulewidth)/#2- - \tw@\tabcolsep-\arrayrulewidth\relax + \dimexpr(\linewidth-\sphinxarrayrulewidth)/#2- + \tw@\tabcolsep-\sphinxarrayrulewidth\relax \fi \else % in tabulary \ifx\equation$%$% first pass @@ -357,8 +364,8 @@ \linewidth % in a L, R, C, J column or a p, \X, \Y ... \else % we have hacked \TY@final to put in \sphinx@TY@tablewidth the table width - \dimexpr(\sphinx@TY@tablewidth-\arrayrulewidth)/#2- - \tw@\tabcolsep-\arrayrulewidth\relax + \dimexpr(\sphinx@TY@tablewidth-\sphinxarrayrulewidth)/#2- + \tw@\tabcolsep-\sphinxarrayrulewidth\relax \fi \fi \fi @@ -368,7 +375,7 @@ % \sphinxcolwidth will use this only inside LaTeX's standard \multicolumn \def\sphinx@multiwidth #1#2{\dimexpr % #1 to gobble the \@gobble (!) (\ifx\TY@final\@undefined\linewidth\else\sphinx@TY@tablewidth\fi - -\arrayrulewidth)*#2-\tw@\tabcolsep-\arrayrulewidth\relax}% + -\sphinxarrayrulewidth)*#2-\tw@\tabcolsep-\sphinxarrayrulewidth\relax}% %%%%%%%%%%%%%%%%%% % --- MULTIROW --- diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index 5debd681f4c..7b21d6fd6cd 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -99,6 +99,7 @@ def __init__(self, node: Element) -> None: self.classes: List[str] = node.get('classes', []) self.colcount = 0 self.colspec: str = None + self.booktabs = False self.colwidths: List[int] = [] self.has_problematic = False self.has_oldproblematic = False @@ -143,23 +144,30 @@ def get_colspec(self) -> str: This is what LaTeX calls the 'preamble argument' of the used table environment. - .. note:: the ``\\X`` and ``T`` column type specifiers are defined in ``sphinx.sty``. + .. note:: + + The ``\\X`` and ``T`` column type specifiers are defined in + ``sphinxlatextables.sty``. """ if self.colspec: return self.colspec - elif self.colwidths and 'colwidths-given' in self.classes: + + _colsep = '' if self.booktabs else '|' + if self.colwidths and 'colwidths-given' in self.classes: total = sum(self.colwidths) colspecs = [r'\X{%d}{%d}' % (width, total) for width in self.colwidths] - return '{|%s|}' % '|'.join(colspecs) + CR + return '{%s%s%s}' % (_colsep, _colsep.join(colspecs), _colsep) + CR elif self.has_problematic: - return r'{|*{%d}{\X{1}{%d}|}}' % (self.colcount, self.colcount) + CR + return r'{%s*{%d}{\X{1}{%d}%s}}' % (_colsep, self.colcount, + self.colcount, _colsep) + CR elif self.get_table_type() == 'tabulary': # sphinx.sty sets T to be J by default. - return '{|' + ('T|' * self.colcount) + '}' + CR + return '{' + _colsep + (('T' + _colsep) * self.colcount) + '}' + CR elif self.has_oldproblematic: - return r'{|*{%d}{\X{1}{%d}|}}' % (self.colcount, self.colcount) + CR + return r'{%s*{%d}{\X{1}{%d}%s}}' % (_colsep, self.colcount, + self.colcount, _colsep) + CR else: - return '{|' + ('l|' * self.colcount) + '}' + CR + return '{' + _colsep + (('l' + _colsep) * self.colcount) + '}' + CR def add_cell(self, height: int, width: int) -> None: """Adds a new cell to a table. @@ -857,11 +865,16 @@ def visit_table(self, node: Element) -> None: (self.curfilestack[-1], node.line or '')) self.tables.append(Table(node)) + self.table.booktabs = self.builder.config.latex_use_booktabs if self.next_table_colspec: self.table.colspec = '{%s}' % self.next_table_colspec + CR if 'colwidths-given' in node.get('classes', []): logger.info(__('both tabularcolumns and :widths: option are given. ' ':widths: is ignored.'), location=node) + if '|' in self.table.colspec and self.table.booktabs: + logger.info(__('tabularcolumns argument contains | and ' + 'latex_use_booktabs is True. Expect gaps between vertical ' + 'and horizontal rules in this table.'), location=node) self.next_table_colspec = None def depart_table(self, node: Element) -> None: @@ -896,6 +909,8 @@ def visit_thead(self, node: Element) -> None: self.pushbody(self.table.header) def depart_thead(self, node: Element) -> None: + if self.body and self.body[-1] == r'\sphinxhline': + self.body.pop() self.popbody() def visit_tbody(self, node: Element) -> None: @@ -903,10 +918,13 @@ def visit_tbody(self, node: Element) -> None: self.pushbody(self.table.body) def depart_tbody(self, node: Element) -> None: + if self.body and self.body[-1] == r'\sphinxhline': + self.body.pop() self.popbody() def visit_row(self, node: Element) -> None: self.table.col = 0 + _colsep = '' if self.table.booktabs else '|' # fill columns if the row starts with the bottom of multirow cell while True: @@ -921,22 +939,22 @@ def visit_row(self, node: Element) -> None: # insert suitable strut for equalizing row heights in given multirow self.body.append(r'\sphinxtablestrut{%d}' % cell.cell_id) else: # use \multicolumn for wide multirow cell - self.body.append(r'\multicolumn{%d}{|l|}{\sphinxtablestrut{%d}}' % - (cell.width, cell.cell_id)) + self.body.append(r'\multicolumn{%d}{%sl%s}{\sphinxtablestrut{%d}}' % + (cell.width, _colsep, _colsep, cell.cell_id)) def depart_row(self, node: Element) -> None: self.body.append(r'\\' + CR) cells = [self.table.cell(self.table.row, i) for i in range(self.table.colcount)] underlined = [cell.row + cell.height == self.table.row + 1 for cell in cells] if all(underlined): - self.body.append(r'\hline') + self.body.append(r'\sphinxhline') else: i = 0 underlined.extend([False]) # sentinel while i < len(underlined): if underlined[i] is True: j = underlined[i:].index(False) - self.body.append(r'\cline{%d-%d}' % (i + 1, i + j)) + self.body.append(r'\sphinxcline{%d-%d}' % (i + 1, i + j)) i += j i += 1 self.table.row += 1 @@ -947,12 +965,14 @@ def visit_entry(self, node: Element) -> None: self.table.add_cell(node.get('morerows', 0) + 1, node.get('morecols', 0) + 1) cell = self.table.cell() context = '' + _colsep = '' if self.table.booktabs else '|' if cell.width > 1: if self.config.latex_use_latex_multicolumn: if self.table.col == 0: - self.body.append(r'\multicolumn{%d}{|l|}{%%' % cell.width + CR) + self.body.append(r'\multicolumn{%d}{%sl%s}{%%' % + (cell.width, _colsep, _colsep) + CR) else: - self.body.append(r'\multicolumn{%d}{l|}{%%' % cell.width + CR) + self.body.append(r'\multicolumn{%d}{l%s}{%%' % (cell.width, _colsep) + CR) context = '}%' + CR else: self.body.append(r'\sphinxstartmulticolumn{%d}%%' % cell.width + CR) @@ -992,6 +1012,7 @@ def depart_entry(self, node: Element) -> None: cell = self.table.cell() self.table.col += cell.width + _colsep = '' if self.table.booktabs else '|' # fill columns if next ones are a bottom of wide-multirow cell while True: @@ -1007,8 +1028,8 @@ def depart_entry(self, node: Element) -> None: self.body.append(r'\sphinxtablestrut{%d}' % nextcell.cell_id) else: # use \multicolumn for wide multirow cell - self.body.append(r'\multicolumn{%d}{l|}{\sphinxtablestrut{%d}}' % - (nextcell.width, nextcell.cell_id)) + self.body.append(r'\multicolumn{%d}{l%s}{\sphinxtablestrut{%d}}' % + (nextcell.width, _colsep, nextcell.cell_id)) def visit_acks(self, node: Element) -> None: # this is a list in the source, but should be rendered as a diff --git a/tests/roots/test-latex-table/expects/complex_spanning_cell.tex b/tests/roots/test-latex-table/expects/complex_spanning_cell.tex index 966f39a955e..81fc939067b 100644 --- a/tests/roots/test-latex-table/expects/complex_spanning_cell.tex +++ b/tests/roots/test-latex-table/expects/complex_spanning_cell.tex @@ -16,7 +16,7 @@ \begin{savenotes}\sphinxattablestart \centering \begin{tabulary}{\linewidth}[t]{|T|T|T|T|T|} -\hline +\sphinxtoprule \sphinxmultirow{3}{1}{% \begin{varwidth}[t]{\sphinxcolwidth{1}{5}} \sphinxAtStartPar @@ -49,7 +49,7 @@ \vskip-\baselineskip\vbox{\hbox{\strut}}\end{varwidth}% }% \\ -\cline{3-3}\sphinxtablestrut{1}&\sphinxtablestrut{2}&\sphinxmultirow{2}{6}{% +\sphinxcline{3-3}\sphinxtablestrut{1}&\sphinxtablestrut{2}&\sphinxmultirow{2}{6}{% \begin{varwidth}[t]{\sphinxcolwidth{1}{5}} \sphinxAtStartPar cell2\sphinxhyphen{}3 @@ -57,11 +57,11 @@ \vskip-\baselineskip\vbox{\hbox{\strut}}\end{varwidth}% }% &\sphinxtablestrut{4}&\sphinxtablestrut{5}\\ -\cline{5-5}\sphinxtablestrut{1}&\sphinxtablestrut{2}&\sphinxtablestrut{6}&\sphinxtablestrut{4}& +\sphinxcline{5-5}\sphinxtablestrut{1}&\sphinxtablestrut{2}&\sphinxtablestrut{6}&\sphinxtablestrut{4}& \sphinxAtStartPar cell3\sphinxhyphen{}5 \\ -\hline +\sphinxbottomrule \end{tabulary} \par \sphinxattableend\end{savenotes} diff --git a/tests/roots/test-latex-table/expects/gridtable.tex b/tests/roots/test-latex-table/expects/gridtable.tex index a71c9e202a0..f5780a5ea3c 100644 --- a/tests/roots/test-latex-table/expects/gridtable.tex +++ b/tests/roots/test-latex-table/expects/gridtable.tex @@ -3,7 +3,7 @@ \begin{savenotes}\sphinxattablestart \centering \begin{tabulary}{\linewidth}[t]{|T|T|T|} -\hline +\sphinxtoprule \sphinxstyletheadfamily \sphinxAtStartPar header1 @@ -14,7 +14,7 @@ \sphinxAtStartPar header3 \\ -\hline +\sphinxmidrule \sphinxAtStartPar cell1\sphinxhyphen{}1 &\sphinxmultirow{2}{5}{% @@ -28,7 +28,7 @@ \sphinxAtStartPar cell1\sphinxhyphen{}3 \\ -\cline{1-1}\cline{3-3}\sphinxmultirow{2}{7}{% +\sphinxcline{1-1}\sphinxcline{3-3}\sphinxmultirow{2}{7}{% \begin{varwidth}[t]{\sphinxcolwidth{1}{3}} \sphinxAtStartPar cell2\sphinxhyphen{}1 @@ -39,7 +39,7 @@ \sphinxAtStartPar cell2\sphinxhyphen{}3 \\ -\cline{2-3}\sphinxtablestrut{7}&\sphinxstartmulticolumn{2}% +\sphinxcline{2-3}\sphinxtablestrut{7}&\sphinxstartmulticolumn{2}% \sphinxmultirow{2}{9}{% \begin{varwidth}[t]{\sphinxcolwidth{2}{3}} \sphinxAtStartPar @@ -52,11 +52,11 @@ }% \sphinxstopmulticolumn \\ -\cline{1-1} +\sphinxcline{1-1} \sphinxAtStartPar cell4\sphinxhyphen{}1 &\multicolumn{2}{l|}{\sphinxtablestrut{9}}\\ -\hline\sphinxstartmulticolumn{3}% +\sphinxhline\sphinxstartmulticolumn{3}% \begin{varwidth}[t]{\sphinxcolwidth{3}{3}} \sphinxAtStartPar cell5\sphinxhyphen{}1 @@ -64,7 +64,7 @@ \vskip-\baselineskip\vbox{\hbox{\strut}}\end{varwidth}% \sphinxstopmulticolumn \\ -\hline +\sphinxbottomrule \end{tabulary} \par \sphinxattableend\end{savenotes} diff --git a/tests/roots/test-latex-table/expects/longtable.tex b/tests/roots/test-latex-table/expects/longtable.tex index e2138ad58fe..2654962f523 100644 --- a/tests/roots/test-latex-table/expects/longtable.tex +++ b/tests/roots/test-latex-table/expects/longtable.tex @@ -1,7 +1,7 @@ \label{\detokenize{longtable:longtable}} \begin{savenotes}\sphinxatlongtablestart\begin{longtable}[c]{|l|l|} -\hline +\sphinxtoprule \sphinxstyletheadfamily \sphinxAtStartPar header1 @@ -9,12 +9,12 @@ \sphinxAtStartPar header2 \\ -\hline +\sphinxmidrule \endfirsthead \multicolumn{2}{c}% {\makebox[0pt]{\sphinxtablecontinued{\tablename\ \thetable{} \textendash{} continued from previous page}}}\\ -\hline +\sphinxtoprule \sphinxstyletheadfamily \sphinxAtStartPar header1 @@ -22,10 +22,10 @@ \sphinxAtStartPar header2 \\ -\hline +\sphinxmidrule \endhead -\hline +\sphinxbottomrule \multicolumn{2}{r}{\makebox[0pt][r]{\sphinxtablecontinued{continues on next page}}}\\ \endfoot @@ -37,19 +37,19 @@ \sphinxAtStartPar cell1\sphinxhyphen{}2 \\ -\hline +\sphinxhline \sphinxAtStartPar cell2\sphinxhyphen{}1 & \sphinxAtStartPar cell2\sphinxhyphen{}2 \\ -\hline +\sphinxhline \sphinxAtStartPar cell3\sphinxhyphen{}1 & \sphinxAtStartPar cell3\sphinxhyphen{}2 \\ -\hline +\sphinxbottomrule \end{longtable}\sphinxatlongtableend\end{savenotes} diff --git a/tests/roots/test-latex-table/expects/longtable_having_align.tex b/tests/roots/test-latex-table/expects/longtable_having_align.tex index 764ef55f301..08819526218 100644 --- a/tests/roots/test-latex-table/expects/longtable_having_align.tex +++ b/tests/roots/test-latex-table/expects/longtable_having_align.tex @@ -1,7 +1,7 @@ \label{\detokenize{longtable:longtable-having-align-option}} \begin{savenotes}\sphinxatlongtablestart\begin{longtable}[r]{|l|l|} -\hline +\sphinxtoprule \sphinxstyletheadfamily \sphinxAtStartPar header1 @@ -9,12 +9,12 @@ \sphinxAtStartPar header2 \\ -\hline +\sphinxmidrule \endfirsthead \multicolumn{2}{c}% {\makebox[0pt]{\sphinxtablecontinued{\tablename\ \thetable{} \textendash{} continued from previous page}}}\\ -\hline +\sphinxtoprule \sphinxstyletheadfamily \sphinxAtStartPar header1 @@ -22,10 +22,10 @@ \sphinxAtStartPar header2 \\ -\hline +\sphinxmidrule \endhead -\hline +\sphinxbottomrule \multicolumn{2}{r}{\makebox[0pt][r]{\sphinxtablecontinued{continues on next page}}}\\ \endfoot @@ -37,19 +37,19 @@ \sphinxAtStartPar cell1\sphinxhyphen{}2 \\ -\hline +\sphinxhline \sphinxAtStartPar cell2\sphinxhyphen{}1 & \sphinxAtStartPar cell2\sphinxhyphen{}2 \\ -\hline +\sphinxhline \sphinxAtStartPar cell3\sphinxhyphen{}1 & \sphinxAtStartPar cell3\sphinxhyphen{}2 \\ -\hline +\sphinxbottomrule \end{longtable}\sphinxatlongtableend\end{savenotes} diff --git a/tests/roots/test-latex-table/expects/longtable_having_caption.tex b/tests/roots/test-latex-table/expects/longtable_having_caption.tex index 0ca5506be9a..04f4e29d669 100644 --- a/tests/roots/test-latex-table/expects/longtable_having_caption.tex +++ b/tests/roots/test-latex-table/expects/longtable_having_caption.tex @@ -3,7 +3,7 @@ \begin{savenotes}\sphinxatlongtablestart\begin{longtable}[c]{|l|l|} \sphinxthelongtablecaptionisattop \caption{caption for longtable\strut}\label{\detokenize{longtable:id1}}\\*[\sphinxlongtablecapskipadjust] -\hline +\sphinxtoprule \sphinxstyletheadfamily \sphinxAtStartPar header1 @@ -11,12 +11,12 @@ \sphinxAtStartPar header2 \\ -\hline +\sphinxmidrule \endfirsthead \multicolumn{2}{c}% {\makebox[0pt]{\sphinxtablecontinued{\tablename\ \thetable{} \textendash{} continued from previous page}}}\\ -\hline +\sphinxtoprule \sphinxstyletheadfamily \sphinxAtStartPar header1 @@ -24,10 +24,10 @@ \sphinxAtStartPar header2 \\ -\hline +\sphinxmidrule \endhead -\hline +\sphinxbottomrule \multicolumn{2}{r}{\makebox[0pt][r]{\sphinxtablecontinued{continues on next page}}}\\ \endfoot @@ -39,19 +39,19 @@ \sphinxAtStartPar cell1\sphinxhyphen{}2 \\ -\hline +\sphinxhline \sphinxAtStartPar cell2\sphinxhyphen{}1 & \sphinxAtStartPar cell2\sphinxhyphen{}2 \\ -\hline +\sphinxhline \sphinxAtStartPar cell3\sphinxhyphen{}1 & \sphinxAtStartPar cell3\sphinxhyphen{}2 \\ -\hline +\sphinxbottomrule \end{longtable}\sphinxatlongtableend\end{savenotes} diff --git a/tests/roots/test-latex-table/expects/longtable_having_problematic_cell.tex b/tests/roots/test-latex-table/expects/longtable_having_problematic_cell.tex index 9551a0a3b25..810fd59d18c 100644 --- a/tests/roots/test-latex-table/expects/longtable_having_problematic_cell.tex +++ b/tests/roots/test-latex-table/expects/longtable_having_problematic_cell.tex @@ -1,7 +1,7 @@ \label{\detokenize{longtable:longtable-having-problematic-cell}} \begin{savenotes}\sphinxatlongtablestart\begin{longtable}[c]{|*{2}{\X{1}{2}|}} -\hline +\sphinxtoprule \sphinxstyletheadfamily \sphinxAtStartPar header1 @@ -9,12 +9,12 @@ \sphinxAtStartPar header2 \\ -\hline +\sphinxmidrule \endfirsthead \multicolumn{2}{c}% {\makebox[0pt]{\sphinxtablecontinued{\tablename\ \thetable{} \textendash{} continued from previous page}}}\\ -\hline +\sphinxtoprule \sphinxstyletheadfamily \sphinxAtStartPar header1 @@ -22,10 +22,10 @@ \sphinxAtStartPar header2 \\ -\hline +\sphinxmidrule \endhead -\hline +\sphinxbottomrule \multicolumn{2}{r}{\makebox[0pt][r]{\sphinxtablecontinued{continues on next page}}}\\ \endfoot @@ -44,19 +44,19 @@ \sphinxAtStartPar cell1\sphinxhyphen{}2 \\ -\hline +\sphinxhline \sphinxAtStartPar cell2\sphinxhyphen{}1 & \sphinxAtStartPar cell2\sphinxhyphen{}2 \\ -\hline +\sphinxhline \sphinxAtStartPar cell3\sphinxhyphen{}1 & \sphinxAtStartPar cell3\sphinxhyphen{}2 \\ -\hline +\sphinxbottomrule \end{longtable}\sphinxatlongtableend\end{savenotes} diff --git a/tests/roots/test-latex-table/expects/longtable_having_stub_columns_and_problematic_cell.tex b/tests/roots/test-latex-table/expects/longtable_having_stub_columns_and_problematic_cell.tex index e54f8acec03..37309a892d1 100644 --- a/tests/roots/test-latex-table/expects/longtable_having_stub_columns_and_problematic_cell.tex +++ b/tests/roots/test-latex-table/expects/longtable_having_stub_columns_and_problematic_cell.tex @@ -1,7 +1,7 @@ \label{\detokenize{longtable:longtable-having-both-stub-columns-and-problematic-cell}} \begin{savenotes}\sphinxatlongtablestart\begin{longtable}[c]{|*{3}{\X{1}{3}|}} -\hline +\sphinxtoprule \sphinxstyletheadfamily \sphinxAtStartPar header1 @@ -12,12 +12,12 @@ \sphinxAtStartPar header3 \\ -\hline +\sphinxmidrule \endfirsthead \multicolumn{3}{c}% {\makebox[0pt]{\sphinxtablecontinued{\tablename\ \thetable{} \textendash{} continued from previous page}}}\\ -\hline +\sphinxtoprule \sphinxstyletheadfamily \sphinxAtStartPar header1 @@ -28,10 +28,10 @@ \sphinxAtStartPar header3 \\ -\hline +\sphinxmidrule \endhead -\hline +\sphinxbottomrule \multicolumn{3}{r}{\makebox[0pt][r]{\sphinxtablecontinued{continues on next page}}}\\ \endfoot @@ -53,7 +53,7 @@ \sphinxAtStartPar notinstub1\sphinxhyphen{}3 \\ -\hline\sphinxstyletheadfamily +\sphinxhline\sphinxstyletheadfamily \sphinxAtStartPar cell2\sphinxhyphen{}1 &\sphinxstyletheadfamily @@ -63,5 +63,5 @@ \sphinxAtStartPar cell2\sphinxhyphen{}3 \\ -\hline +\sphinxbottomrule \end{longtable}\sphinxatlongtableend\end{savenotes} diff --git a/tests/roots/test-latex-table/expects/longtable_having_verbatim.tex b/tests/roots/test-latex-table/expects/longtable_having_verbatim.tex index a0e7ecfcd07..97ed0413374 100644 --- a/tests/roots/test-latex-table/expects/longtable_having_verbatim.tex +++ b/tests/roots/test-latex-table/expects/longtable_having_verbatim.tex @@ -1,7 +1,7 @@ \label{\detokenize{longtable:longtable-having-verbatim}} \begin{savenotes}\sphinxatlongtablestart\begin{longtable}[c]{|*{2}{\X{1}{2}|}} -\hline +\sphinxtoprule \sphinxstyletheadfamily \sphinxAtStartPar header1 @@ -9,12 +9,12 @@ \sphinxAtStartPar header2 \\ -\hline +\sphinxmidrule \endfirsthead \multicolumn{2}{c}% {\makebox[0pt]{\sphinxtablecontinued{\tablename\ \thetable{} \textendash{} continued from previous page}}}\\ -\hline +\sphinxtoprule \sphinxstyletheadfamily \sphinxAtStartPar header1 @@ -22,10 +22,10 @@ \sphinxAtStartPar header2 \\ -\hline +\sphinxmidrule \endhead -\hline +\sphinxbottomrule \multicolumn{2}{r}{\makebox[0pt][r]{\sphinxtablecontinued{continues on next page}}}\\ \endfoot @@ -38,19 +38,19 @@ \sphinxAtStartPar cell1\sphinxhyphen{}2 \\ -\hline +\sphinxhline \sphinxAtStartPar cell2\sphinxhyphen{}1 & \sphinxAtStartPar cell2\sphinxhyphen{}2 \\ -\hline +\sphinxhline \sphinxAtStartPar cell3\sphinxhyphen{}1 & \sphinxAtStartPar cell3\sphinxhyphen{}2 \\ -\hline +\sphinxbottomrule \end{longtable}\sphinxatlongtableend\end{savenotes} diff --git a/tests/roots/test-latex-table/expects/longtable_having_widths.tex b/tests/roots/test-latex-table/expects/longtable_having_widths.tex index cdd0e7a2b32..43de6ffe65a 100644 --- a/tests/roots/test-latex-table/expects/longtable_having_widths.tex +++ b/tests/roots/test-latex-table/expects/longtable_having_widths.tex @@ -1,7 +1,7 @@ \label{\detokenize{longtable:longtable-having-widths-option}} \begin{savenotes}\sphinxatlongtablestart\begin{longtable}[c]{|\X{30}{100}|\X{70}{100}|} -\hline\noalign{\phantomsection\label{\detokenize{longtable:namedlongtable}}\label{\detokenize{longtable:mylongtable}}}% +\sphinxtoprule\noalign{\phantomsection\label{\detokenize{longtable:namedlongtable}}\label{\detokenize{longtable:mylongtable}}}% \sphinxstyletheadfamily \sphinxAtStartPar header1 @@ -9,12 +9,12 @@ \sphinxAtStartPar header2 \\ -\hline +\sphinxmidrule \endfirsthead \multicolumn{2}{c}% {\makebox[0pt]{\sphinxtablecontinued{\tablename\ \thetable{} \textendash{} continued from previous page}}}\\ -\hline +\sphinxtoprule \sphinxstyletheadfamily \sphinxAtStartPar header1 @@ -22,10 +22,10 @@ \sphinxAtStartPar header2 \\ -\hline +\sphinxmidrule \endhead -\hline +\sphinxbottomrule \multicolumn{2}{r}{\makebox[0pt][r]{\sphinxtablecontinued{continues on next page}}}\\ \endfoot @@ -37,21 +37,21 @@ \sphinxAtStartPar cell1\sphinxhyphen{}2 \\ -\hline +\sphinxhline \sphinxAtStartPar cell2\sphinxhyphen{}1 & \sphinxAtStartPar cell2\sphinxhyphen{}2 \\ -\hline +\sphinxhline \sphinxAtStartPar cell3\sphinxhyphen{}1 & \sphinxAtStartPar cell3\sphinxhyphen{}2 \\ -\hline +\sphinxbottomrule \end{longtable}\sphinxatlongtableend\end{savenotes} \sphinxAtStartPar diff --git a/tests/roots/test-latex-table/expects/longtable_having_widths_and_problematic_cell.tex b/tests/roots/test-latex-table/expects/longtable_having_widths_and_problematic_cell.tex index ea868ffe4ea..5a193d7c909 100644 --- a/tests/roots/test-latex-table/expects/longtable_having_widths_and_problematic_cell.tex +++ b/tests/roots/test-latex-table/expects/longtable_having_widths_and_problematic_cell.tex @@ -1,7 +1,7 @@ \label{\detokenize{longtable:longtable-having-both-widths-and-problematic-cell}} \begin{savenotes}\sphinxatlongtablestart\begin{longtable}[c]{|\X{30}{100}|\X{70}{100}|} -\hline +\sphinxtoprule \sphinxstyletheadfamily \sphinxAtStartPar header1 @@ -9,12 +9,12 @@ \sphinxAtStartPar header2 \\ -\hline +\sphinxmidrule \endfirsthead \multicolumn{2}{c}% {\makebox[0pt]{\sphinxtablecontinued{\tablename\ \thetable{} \textendash{} continued from previous page}}}\\ -\hline +\sphinxtoprule \sphinxstyletheadfamily \sphinxAtStartPar header1 @@ -22,10 +22,10 @@ \sphinxAtStartPar header2 \\ -\hline +\sphinxmidrule \endhead -\hline +\sphinxbottomrule \multicolumn{2}{r}{\makebox[0pt][r]{\sphinxtablecontinued{continues on next page}}}\\ \endfoot @@ -44,19 +44,19 @@ \sphinxAtStartPar cell1\sphinxhyphen{}2 \\ -\hline +\sphinxhline \sphinxAtStartPar cell2\sphinxhyphen{}1 & \sphinxAtStartPar cell2\sphinxhyphen{}2 \\ -\hline +\sphinxhline \sphinxAtStartPar cell3\sphinxhyphen{}1 & \sphinxAtStartPar cell3\sphinxhyphen{}2 \\ -\hline +\sphinxbottomrule \end{longtable}\sphinxatlongtableend\end{savenotes} diff --git a/tests/roots/test-latex-table/expects/longtable_with_tabularcolumn.tex b/tests/roots/test-latex-table/expects/longtable_with_tabularcolumn.tex index 426086de5ce..feab1f62e1c 100644 --- a/tests/roots/test-latex-table/expects/longtable_with_tabularcolumn.tex +++ b/tests/roots/test-latex-table/expects/longtable_with_tabularcolumn.tex @@ -1,7 +1,7 @@ \label{\detokenize{longtable:longtable-with-tabularcolumn}} \begin{savenotes}\sphinxatlongtablestart\begin{longtable}[c]{|c|c|} -\hline +\sphinxtoprule \sphinxstyletheadfamily \sphinxAtStartPar header1 @@ -9,12 +9,12 @@ \sphinxAtStartPar header2 \\ -\hline +\sphinxmidrule \endfirsthead \multicolumn{2}{c}% {\makebox[0pt]{\sphinxtablecontinued{\tablename\ \thetable{} \textendash{} continued from previous page}}}\\ -\hline +\sphinxtoprule \sphinxstyletheadfamily \sphinxAtStartPar header1 @@ -22,10 +22,10 @@ \sphinxAtStartPar header2 \\ -\hline +\sphinxmidrule \endhead -\hline +\sphinxbottomrule \multicolumn{2}{r}{\makebox[0pt][r]{\sphinxtablecontinued{continues on next page}}}\\ \endfoot @@ -37,19 +37,19 @@ \sphinxAtStartPar cell1\sphinxhyphen{}2 \\ -\hline +\sphinxhline \sphinxAtStartPar cell2\sphinxhyphen{}1 & \sphinxAtStartPar cell2\sphinxhyphen{}2 \\ -\hline +\sphinxhline \sphinxAtStartPar cell3\sphinxhyphen{}1 & \sphinxAtStartPar cell3\sphinxhyphen{}2 \\ -\hline +\sphinxbottomrule \end{longtable}\sphinxatlongtableend\end{savenotes} diff --git a/tests/roots/test-latex-table/expects/simple_table.tex b/tests/roots/test-latex-table/expects/simple_table.tex index a06bfb1cfad..01ba7681608 100644 --- a/tests/roots/test-latex-table/expects/simple_table.tex +++ b/tests/roots/test-latex-table/expects/simple_table.tex @@ -3,7 +3,7 @@ \begin{savenotes}\sphinxattablestart \centering \begin{tabulary}{\linewidth}[t]{|T|T|} -\hline +\sphinxtoprule \sphinxstyletheadfamily \sphinxAtStartPar header1 @@ -11,28 +11,28 @@ \sphinxAtStartPar header2 \\ -\hline +\sphinxmidrule \sphinxAtStartPar cell1\sphinxhyphen{}1 & \sphinxAtStartPar cell1\sphinxhyphen{}2 \\ -\hline +\sphinxhline \sphinxAtStartPar cell2\sphinxhyphen{}1 & \sphinxAtStartPar cell2\sphinxhyphen{}2 \\ -\hline +\sphinxhline \sphinxAtStartPar cell3\sphinxhyphen{}1 & \sphinxAtStartPar cell3\sphinxhyphen{}2 \\ -\hline +\sphinxbottomrule \end{tabulary} \par \sphinxattableend\end{savenotes} diff --git a/tests/roots/test-latex-table/expects/table_having_caption.tex b/tests/roots/test-latex-table/expects/table_having_caption.tex index 33a5f1d8fdb..e57f4725ffb 100644 --- a/tests/roots/test-latex-table/expects/table_having_caption.tex +++ b/tests/roots/test-latex-table/expects/table_having_caption.tex @@ -7,7 +7,7 @@ \sphinxcaption{caption for table}\label{\detokenize{tabular:id1}} \sphinxaftertopcaption \begin{tabulary}{\linewidth}[t]{|T|T|} -\hline +\sphinxtoprule \sphinxstyletheadfamily \sphinxAtStartPar header1 @@ -15,28 +15,28 @@ \sphinxAtStartPar header2 \\ -\hline +\sphinxmidrule \sphinxAtStartPar cell1\sphinxhyphen{}1 & \sphinxAtStartPar cell1\sphinxhyphen{}2 \\ -\hline +\sphinxhline \sphinxAtStartPar cell2\sphinxhyphen{}1 & \sphinxAtStartPar cell2\sphinxhyphen{}2 \\ -\hline +\sphinxhline \sphinxAtStartPar cell3\sphinxhyphen{}1 & \sphinxAtStartPar cell3\sphinxhyphen{}2 \\ -\hline +\sphinxbottomrule \end{tabulary} \par \sphinxattableend\end{savenotes} diff --git a/tests/roots/test-latex-table/expects/table_having_problematic_cell.tex b/tests/roots/test-latex-table/expects/table_having_problematic_cell.tex index c5c57e2f758..e11a45f7290 100644 --- a/tests/roots/test-latex-table/expects/table_having_problematic_cell.tex +++ b/tests/roots/test-latex-table/expects/table_having_problematic_cell.tex @@ -3,7 +3,7 @@ \begin{savenotes}\sphinxattablestart \centering \begin{tabular}[t]{|*{2}{\X{1}{2}|}} -\hline +\sphinxtoprule \sphinxstyletheadfamily \sphinxAtStartPar header1 @@ -11,7 +11,7 @@ \sphinxAtStartPar header2 \\ -\hline\begin{itemize} +\sphinxmidrule\begin{itemize} \item {} \sphinxAtStartPar item1 @@ -25,21 +25,21 @@ \sphinxAtStartPar cell1\sphinxhyphen{}2 \\ -\hline +\sphinxhline \sphinxAtStartPar cell2\sphinxhyphen{}1 & \sphinxAtStartPar cell2\sphinxhyphen{}2 \\ -\hline +\sphinxhline \sphinxAtStartPar cell3\sphinxhyphen{}1 & \sphinxAtStartPar cell3\sphinxhyphen{}2 \\ -\hline +\sphinxbottomrule \end{tabular} \par \sphinxattableend\end{savenotes} diff --git a/tests/roots/test-latex-table/expects/table_having_stub_columns_and_problematic_cell.tex b/tests/roots/test-latex-table/expects/table_having_stub_columns_and_problematic_cell.tex index 13c48a21322..68a485519d4 100644 --- a/tests/roots/test-latex-table/expects/table_having_stub_columns_and_problematic_cell.tex +++ b/tests/roots/test-latex-table/expects/table_having_stub_columns_and_problematic_cell.tex @@ -3,7 +3,7 @@ \begin{savenotes}\sphinxattablestart \centering \begin{tabular}[t]{|*{3}{\X{1}{3}|}} -\hline +\sphinxtoprule \sphinxstyletheadfamily \sphinxAtStartPar header1 @@ -14,7 +14,7 @@ \sphinxAtStartPar header3 \\ -\hline\sphinxstyletheadfamily \begin{itemize} +\sphinxmidrule\sphinxstyletheadfamily \begin{itemize} \item {} \sphinxAtStartPar instub1\sphinxhyphen{}1a @@ -31,7 +31,7 @@ \sphinxAtStartPar notinstub1\sphinxhyphen{}3 \\ -\hline\sphinxstyletheadfamily +\sphinxhline\sphinxstyletheadfamily \sphinxAtStartPar cell2\sphinxhyphen{}1 &\sphinxstyletheadfamily @@ -41,7 +41,7 @@ \sphinxAtStartPar cell2\sphinxhyphen{}3 \\ -\hline +\sphinxbottomrule \end{tabular} \par \sphinxattableend\end{savenotes} diff --git a/tests/roots/test-latex-table/expects/table_having_threeparagraphs_cell_in_first_col.tex b/tests/roots/test-latex-table/expects/table_having_threeparagraphs_cell_in_first_col.tex index c1a440558e6..2ea24d37309 100644 --- a/tests/roots/test-latex-table/expects/table_having_threeparagraphs_cell_in_first_col.tex +++ b/tests/roots/test-latex-table/expects/table_having_threeparagraphs_cell_in_first_col.tex @@ -3,12 +3,12 @@ \begin{savenotes}\sphinxattablestart \centering \begin{tabulary}{\linewidth}[t]{|T|} -\hline +\sphinxtoprule \sphinxstyletheadfamily \sphinxAtStartPar header1 \\ -\hline +\sphinxmidrule \sphinxAtStartPar cell1\sphinxhyphen{}1\sphinxhyphen{}par1 @@ -18,7 +18,7 @@ \sphinxAtStartPar cell1\sphinxhyphen{}1\sphinxhyphen{}par3 \\ -\hline +\sphinxbottomrule \end{tabulary} \par \sphinxattableend\end{savenotes} diff --git a/tests/roots/test-latex-table/expects/table_having_verbatim.tex b/tests/roots/test-latex-table/expects/table_having_verbatim.tex index 23faac55e19..de90c32b113 100644 --- a/tests/roots/test-latex-table/expects/table_having_verbatim.tex +++ b/tests/roots/test-latex-table/expects/table_having_verbatim.tex @@ -3,7 +3,7 @@ \begin{savenotes}\sphinxattablestart \centering \begin{tabular}[t]{|*{2}{\X{1}{2}|}} -\hline +\sphinxtoprule \sphinxstyletheadfamily \sphinxAtStartPar header1 @@ -11,7 +11,7 @@ \sphinxAtStartPar header2 \\ -\hline +\sphinxmidrule \begin{sphinxVerbatimintable}[commandchars=\\\{\}] \PYG{n}{hello} \PYG{n}{world} \end{sphinxVerbatimintable} @@ -19,21 +19,21 @@ \sphinxAtStartPar cell1\sphinxhyphen{}2 \\ -\hline +\sphinxhline \sphinxAtStartPar cell2\sphinxhyphen{}1 & \sphinxAtStartPar cell2\sphinxhyphen{}2 \\ -\hline +\sphinxhline \sphinxAtStartPar cell3\sphinxhyphen{}1 & \sphinxAtStartPar cell3\sphinxhyphen{}2 \\ -\hline +\sphinxbottomrule \end{tabular} \par \sphinxattableend\end{savenotes} diff --git a/tests/roots/test-latex-table/expects/table_having_widths.tex b/tests/roots/test-latex-table/expects/table_having_widths.tex index d01a40576bb..6891df9abde 100644 --- a/tests/roots/test-latex-table/expects/table_having_widths.tex +++ b/tests/roots/test-latex-table/expects/table_having_widths.tex @@ -4,7 +4,7 @@ \centering \phantomsection\label{\detokenize{tabular:namedtabular}}\label{\detokenize{tabular:mytabular}}\nobreak \begin{tabular}[t]{|\X{30}{100}|\X{70}{100}|} -\hline +\sphinxtoprule \sphinxstyletheadfamily \sphinxAtStartPar header1 @@ -12,28 +12,28 @@ \sphinxAtStartPar header2 \\ -\hline +\sphinxmidrule \sphinxAtStartPar cell1\sphinxhyphen{}1 & \sphinxAtStartPar cell1\sphinxhyphen{}2 \\ -\hline +\sphinxhline \sphinxAtStartPar cell2\sphinxhyphen{}1 & \sphinxAtStartPar cell2\sphinxhyphen{}2 \\ -\hline +\sphinxhline \sphinxAtStartPar cell3\sphinxhyphen{}1 & \sphinxAtStartPar cell3\sphinxhyphen{}2 \\ -\hline +\sphinxbottomrule \end{tabular} \par \sphinxattableend\end{savenotes} diff --git a/tests/roots/test-latex-table/expects/table_having_widths_and_problematic_cell.tex b/tests/roots/test-latex-table/expects/table_having_widths_and_problematic_cell.tex index ca6b697e5ec..b81c9867b02 100644 --- a/tests/roots/test-latex-table/expects/table_having_widths_and_problematic_cell.tex +++ b/tests/roots/test-latex-table/expects/table_having_widths_and_problematic_cell.tex @@ -3,7 +3,7 @@ \begin{savenotes}\sphinxattablestart \centering \begin{tabular}[t]{|\X{30}{100}|\X{70}{100}|} -\hline +\sphinxtoprule \sphinxstyletheadfamily \sphinxAtStartPar header1 @@ -11,7 +11,7 @@ \sphinxAtStartPar header2 \\ -\hline\begin{itemize} +\sphinxmidrule\begin{itemize} \item {} \sphinxAtStartPar item1 @@ -25,21 +25,21 @@ \sphinxAtStartPar cell1\sphinxhyphen{}2 \\ -\hline +\sphinxhline \sphinxAtStartPar cell2\sphinxhyphen{}1 & \sphinxAtStartPar cell2\sphinxhyphen{}2 \\ -\hline +\sphinxhline \sphinxAtStartPar cell3\sphinxhyphen{}1 & \sphinxAtStartPar cell3\sphinxhyphen{}2 \\ -\hline +\sphinxbottomrule \end{tabular} \par \sphinxattableend\end{savenotes} diff --git a/tests/roots/test-latex-table/expects/tabular_having_widths.tex b/tests/roots/test-latex-table/expects/tabular_having_widths.tex index 596ba4868e3..90e6b9dc19e 100644 --- a/tests/roots/test-latex-table/expects/tabular_having_widths.tex +++ b/tests/roots/test-latex-table/expects/tabular_having_widths.tex @@ -3,7 +3,7 @@ \begin{savenotes}\sphinxattablestart \raggedright \begin{tabular}[t]{|\X{30}{100}|\X{70}{100}|} -\hline +\sphinxtoprule \sphinxstyletheadfamily \sphinxAtStartPar header1 @@ -11,28 +11,28 @@ \sphinxAtStartPar header2 \\ -\hline +\sphinxmidrule \sphinxAtStartPar cell1\sphinxhyphen{}1 & \sphinxAtStartPar cell1\sphinxhyphen{}2 \\ -\hline +\sphinxhline \sphinxAtStartPar cell2\sphinxhyphen{}1 & \sphinxAtStartPar cell2\sphinxhyphen{}2 \\ -\hline +\sphinxhline \sphinxAtStartPar cell3\sphinxhyphen{}1 & \sphinxAtStartPar cell3\sphinxhyphen{}2 \\ -\hline +\sphinxbottomrule \end{tabular} \par \sphinxattableend\end{savenotes} diff --git a/tests/roots/test-latex-table/expects/tabularcolumn.tex b/tests/roots/test-latex-table/expects/tabularcolumn.tex index c020e0cb4eb..8274ae2382c 100644 --- a/tests/roots/test-latex-table/expects/tabularcolumn.tex +++ b/tests/roots/test-latex-table/expects/tabularcolumn.tex @@ -3,7 +3,7 @@ \begin{savenotes}\sphinxattablestart \centering \begin{tabulary}{\linewidth}[t]{|c|c|} -\hline +\sphinxtoprule \sphinxstyletheadfamily \sphinxAtStartPar header1 @@ -11,28 +11,28 @@ \sphinxAtStartPar header2 \\ -\hline +\sphinxmidrule \sphinxAtStartPar cell1\sphinxhyphen{}1 & \sphinxAtStartPar cell1\sphinxhyphen{}2 \\ -\hline +\sphinxhline \sphinxAtStartPar cell2\sphinxhyphen{}1 & \sphinxAtStartPar cell2\sphinxhyphen{}2 \\ -\hline +\sphinxhline \sphinxAtStartPar cell3\sphinxhyphen{}1 & \sphinxAtStartPar cell3\sphinxhyphen{}2 \\ -\hline +\sphinxbottomrule \end{tabulary} \par \sphinxattableend\end{savenotes} diff --git a/tests/roots/test-latex-table/expects/tabulary_having_widths.tex b/tests/roots/test-latex-table/expects/tabulary_having_widths.tex index 0b42fb0cfa3..939a7f67a49 100644 --- a/tests/roots/test-latex-table/expects/tabulary_having_widths.tex +++ b/tests/roots/test-latex-table/expects/tabulary_having_widths.tex @@ -3,7 +3,7 @@ \begin{savenotes}\sphinxattablestart \raggedleft \begin{tabulary}{\linewidth}[t]{|T|T|} -\hline +\sphinxtoprule \sphinxstyletheadfamily \sphinxAtStartPar header1 @@ -11,28 +11,28 @@ \sphinxAtStartPar header2 \\ -\hline +\sphinxmidrule \sphinxAtStartPar cell1\sphinxhyphen{}1 & \sphinxAtStartPar cell1\sphinxhyphen{}2 \\ -\hline +\sphinxhline \sphinxAtStartPar cell2\sphinxhyphen{}1 & \sphinxAtStartPar cell2\sphinxhyphen{}2 \\ -\hline +\sphinxhline \sphinxAtStartPar cell3\sphinxhyphen{}1 & \sphinxAtStartPar cell3\sphinxhyphen{}2 \\ -\hline +\sphinxbottomrule \end{tabulary} \par \sphinxattableend\end{savenotes} diff --git a/tests/test_build_latex.py b/tests/test_build_latex.py index 8f7a2e85acc..cf6b40d9756 100644 --- a/tests/test_build_latex.py +++ b/tests/test_build_latex.py @@ -22,7 +22,8 @@ DOCCLASSES = ['howto', 'manual'] STYLEFILES = ['article.cls', 'fancyhdr.sty', 'titlesec.sty', 'amsmath.sty', 'framed.sty', 'color.sty', 'fancyvrb.sty', - 'fncychap.sty', 'geometry.sty', 'kvoptions.sty', 'hyperref.sty'] + 'fncychap.sty', 'geometry.sty', 'kvoptions.sty', 'hyperref.sty', + 'booktabs.sty'] LATEX_WARNINGS = ENV_WARNINGS + """\ %(root)s/index.rst:\\d+: WARNING: unknown option: '&option' @@ -90,6 +91,8 @@ def skip_if_stylefiles_notfound(testfunc): def test_build_latex_doc(app, status, warning, engine, docclass): app.config.latex_engine = engine app.config.latex_documents = [app.config.latex_documents[0][:4] + (docclass,)] + if engine == 'xelatex': + app.config.latex_use_booktabs = True app.builder.init() LaTeXTranslator.ignore_missing_images = True @@ -723,7 +726,7 @@ def test_footnote(app, status, warning): assert '\\sphinxcite{footnote:bar}' in result assert ('\\bibitem[bar]{footnote:bar}\n\\sphinxAtStartPar\ncite\n') in result assert '\\sphinxcaption{Table caption \\sphinxfootnotemark[4]' in result - assert ('\\hline%\n\\begin{footnotetext}[4]\\sphinxAtStartFootnote\n' + assert ('\\sphinxmidrule%\n\\begin{footnotetext}[4]\\sphinxAtStartFootnote\n' 'footnote in table caption\n%\n\\end{footnotetext}\\ignorespaces %\n' '\\begin{footnotetext}[5]\\sphinxAtStartFootnote\n' 'footnote in table header\n%\n\\end{footnotetext}\\ignorespaces ' @@ -731,8 +734,8 @@ def test_footnote(app, status, warning): 'VIDIOC\\_CROPCAP\n&\n\\sphinxAtStartPar\n') in result assert ('Information about VIDIOC\\_CROPCAP %\n' '\\begin{footnote}[6]\\sphinxAtStartFootnote\n' - 'footnote in table not in header\n%\n\\end{footnote}\n\\\\\n\\hline\n' - '\\end{tabulary}\n' + 'footnote in table not in header\n%\n\\end{footnote}\n\\\\\n' + '\\sphinxbottomrule\n\\end{tabulary}\n' '\\par\n\\sphinxattableend\\end{savenotes}\n') in result @@ -1315,6 +1318,18 @@ def get_expected(name): assert actual == expected +@pytest.mark.sphinx('latex', testroot='latex-table', + confoverrides={'latex_use_booktabs': True}) +def test_latex_table_with_booktabs(app, status, warning): + app.builder.build_all() + result = (app.outdir / 'python.tex').read_text(encoding='utf8') + assert r'\PassOptionsToPackage{booktabs}{sphinx}' in result + assert r'\begin{tabulary}{\linewidth}[t]{TTTTT}' in result + assert r'\begin{longtable}[c]{ll}' in result + assert r'\begin{tabular}[t]{*{2}{\X{1}{2}}}' in result + assert r'\begin{tabular}[t]{\X{30}{100}\X{70}{100}}' in result + + @pytest.mark.sphinx('latex', testroot='latex-table', confoverrides={'templates_path': ['_mytemplates/latex']}) def test_latex_table_custom_template_caseA(app, status, warning):