Commit Graph
39 Commits
Author SHA1 Message Date
Jean-François BandStefan Wiehler e7c0881992 LaTeX: support for booktabs-style and zebra-striped tables (#10759)
This is a combination of 2 + 28 + 7 + and some more commits...

* Cherry-pick: Add support for booktabs-style tables to LaTeX builder

* Cherry-pick: Add support for zebra-striped tables to LaTeX builder

Co-authored-by: Stefan Wiehler <stefan.wiehler@missinglinkelectronics.com>

Above work originally initiated by @sephalon (thanks!)

Development refactored and continued by @jfbu

* latex_table_style configuration, support booktabs, colorrows, borderless

Some details:

- Simplify a bit a conditional in the longtable template

  This also puts the target for a longtable with a label but no caption
  above the toprule for better hyperlinking (testing shows hyperlink
  target can not end up alone at bottom of previous page).

- Extend allowed syntax for colour assignments via 'sphinxsetup'

- latex_table_style new configuration value and coloured rows

  For the user interface I tried to look for inspiration in
  https://docutils.sourceforge.io/docs/user/config.html#table-style
  which mentions booktabs and borderless.  They also mention
  captionbelow which we can implement later, now that architecture
  is here.  They don't mention coloured rows.

- Test on our own document... looks fine!

- Work-around an incompatibility of \cline with row colours

- Reverse priority of classes to allow overruling booktabs by standard
  after parsing source but before letting LaTeX writer act

- Closes #8220

  Commit
  https://github.com/sphinx-doc/sphinx/commit/bb859c669679baebd8cc8d10c99382478c0d1647
  already improved a bit, this finishes it (as :rst:dir:`rst-class` was
  actually not linking to anywhere).

- Let booktabs style defaults to *not* using \cmidrule.  They actually
  don't make much sense there, as all \hline's are removed.

- Add \sphinxnorowcolor which allows construct such as this one in
  a tabularcolumns directive:

    >{\columncolor{blue}\sphinxnorowcolor}

  else LaTeX always overrides column colour by row colour

- Add TableMergeColorHeader, TableMergeColorOdd, TableMergeColorEven
  so single-row merged cells can be styled especially

- Extend row colours to all header rows not only the first one
  (all header rows will share same colour settings)

- Auto-adjust to a no '|'-colspec for optimal handling of merged cell

- Add \sphinxcolorblend

- Workaround LaTeX's \cline features and other grid tables matters

- Add \sphinxbuildwarning for important warnings

- Fix some white gaps in merged cells of tables with vlines and
  colorrows

- Work around LaTeX's \cline serious deficiencies for complex grid
  tables

  This commit corrects \cline badly impacting vertical spacing and
  making tables look even more cramped as they usually are in LaTeX
  (although one sees it clearly only with \arrarrulewidth a bit more
  than the LaTeX default of 0.4pt).

  Most importantly this commit solves the problem that \cline's got
  masked by colour panels from the row below.

- Update CHANGES for PR #10759

- Improve documentation of new latex_table_style regarding colours
2022-10-12 17:15:40 +02:00
jfbu 5b6a273825 Let latex writer line trimming from depart_entry() work as before #8781
This is cosmetic as the blank line starting varwidth environment used
for merged table cells in latex output changed nothing to PDF.

Nevertheless I extended a unit test to have a multi-paragraph merged
cell using varwidth. What is important is that \sphinxAtStartPar line
itself is never followed by blank line.
2021-01-30 10:26:42 +01:00
jfbu d6e11b89e9 Fix suppression of needed whiteline, encapsulate into \sphinxAtStartPar
Define it to do nothing with lualatex engine
2021-01-29 10:40:50 +01:00
jfbu 185a2d27fe Fix #8780: long words in narrow columns may not be hyphenated
This is done by adding '\hskip0pt\relax\n' whenever a paragraph starts.
2021-01-29 00:24:44 +01:00
Takeshi KOMIYA 712c20a3d9 Merge branch '2.0' 2019-12-16 00:05:35 +09:00
jfbu 30b26dd6a1 LaTeX: avoid quotes and TeX ligature replacements in PDF output
Refs: #6890

The comma character is not TeX-escaped because it is frequent in general
text and escaping it would make the LaTeX output larger for only dealing
with the problem of the LaTeX-ligature of ,, into a single character.
And one there is problem with the commas in options to Verbatim from
PygmentsBridge.

The hyphen character is escaped (not in ids and URIs!) to
\sphinxhyphen{} for both Unicode and non-Unicode engines. This is needed
to work around hyperref transforming -- and --- from section titles into
EN DASH resp. EM DASH in PDF bookmarks.

https://github.com/latex3/hyperref/issues/112

Note to expert LaTeX users: if Sphinx latex user with xelatex has

- turned off Smart Quotes for some reason,

- but does want TeX ligatures and thus overrode Sphinx
latex_elements['fontenc'] default (since #6888) to this effect,

then this should be added to LaTeX preamble:

    \def\sphinxhyphen#1{-}% (\protected is now not needed)
    \let\sphinxhyphenforbookmarks\sphinxhyphen
2019-12-15 14:19:50 +01:00
Takeshi KOMIYA 7ec567b6d0 Merge branch '2.0' 2019-12-09 00:13:42 +09:00
jfbu a0fe0aba1b Update longtable latex template 2019-12-07 00:37:33 +01:00
Takeshi KOMIYA 35b1b5c328 Fix #6512: typo in continuation label for tables 2019-06-22 01:33:29 +09:00
Takeshi KOMIYA 25027945f5 Close #4550: All tables and figures without `align` option are displayed to center 2019-02-08 01:39:41 +09:00
Takeshi KOMIYA 68c90a26f1 quickstart: Simplify generated conf.py (for latex) 2019-01-07 23:06:14 +09:00
Takeshi KOMIYA 114ff77f68 test: Omit master_doc settings from testcases 2019-01-03 10:58:42 +09:00
Takeshi KOMIYA 5428d94d24 Remove coding magic comments from tests 2019-01-02 21:53:07 +09:00
jfbu 88a019dc99 LaTeX: allow sphinxVerbatim usage without explicit "hllines" extra setup
Fixes: #5810
2018-12-16 16:54:28 +01:00
jfbu 4457038550 LaTeX: compatibility with caption package, 2nd part
Ensure same vertical spaces above caption for tabular(y) and longtable
rendered tables.

Fixes: #5520
2018-11-18 00:40:28 +01:00
jfbu 7f19885641 LaTeX: compatibility with caption package
This compatibility is mainly re-instored for convenience of user to
style the fonts used for the caption, and also possibly influence the
horizontal position via "width" or "margin" option of caption package
(attention that caption package obeys the document class tacit "twoside"
option, so if left and right margins are not set-up to be the same,
positioning of caption will depend on parity of the page number).

Regarding vertical skips, for captions placed on top (which is the table
templates default and also the literalblockcappos default), this commit
ensures that the vertical spacing separating the caption last baseline
to the top of framing is governed by \sphinxbelowcaptionspace in all
these three cases: tabular(y), longtable, literal blocks; the "skip"
option of caption package is ignored for them.

The "skip" is obeyed for the spacing between an image and its caption,
which currently in Sphinx is always below the image (no customization of
the figure caption vertical placement is currently available).

If literalblockcappos is "b" (captions follow code-blocks), this commit
removes the caption-package added \abovecaptionskip, so that "skip" is
also ignored for code-blocks in this case. This looks better due to the
extra space already added by the framing of the code-block and achieves
same spacing as without caption package (presumably loaded mainly to
style the fonts used for the caption). However in future maybe caption's
package "skip" should be obeyed for "literalblock" caption type.

Fixes: 5520
2018-11-13 23:55:11 +01:00
jfbu 45c63a8e2d LaTeX, follow-up to PR #5012, avoid label separated by pagebreak
PR #5012 took care of this for longtable, but the problem can also arise
with tabular/tabulary and is much easier to fix.
2018-06-08 18:46:15 +02:00
jfbu 7bebdd0f97 Add tests for non-captioned table with label in latex 2018-06-08 10:18:53 +02:00
jfbu 38dc048bce Fix broken LateX customization via templates (closes: #4795) 2018-03-29 14:58:32 +02:00
jfbu d2d31e2e7d Fix failed latex test after merge 2018-01-20 10:48:27 +01:00
jfbu 02ee4ec86b Merge branch 'stable' into 1.7-release 2018-01-20 10:38:03 +01:00
jfbu 9aca29a781 Fix "Undefined control sequence \\hlineSomeText" (#4431; refs: #3435) 2018-01-18 15:35:59 +01:00
jfbu ad4481eb15 Merge branch 'stable' 2017-12-11 22:54:34 +01:00
jfbu 70f8d4ddfc Support `:emphasize-lines:` in PDF output (closes #1238) 2017-12-10 12:37:36 +01:00
Takeshi KOMIYA 00169a07e6 Merge branch 'stable' 2017-09-24 22:51:23 +09:00
jfbu f453fe7bf0 Fix #4044 (extra row height in PDF output from empty multicell) 2017-09-11 20:18:35 +02:00
Takeshi KOMIYA e7ffa63463 Merge branch 'stable' 2017-05-16 23:53:46 +09:00
Takeshi KOMIYA 515e3ad13d Refactor test_latex_table 2017-05-13 17:01:34 +09:00
jfbu 75653d85ac Fix #3479: add latex support for docutils table stub columns
This implementation in latex writer allows arbitrary columns to be
declared "stub columns". But currently Docutils option
``:stub-columns:`` only allows a number telling the how many initial
columns are "stub columns".
2017-05-10 11:35:12 +02:00
jfbu 1c38710ed2 update latex table tests and CHANGES for PR#3415 2017-02-11 18:02:19 +01:00
Takeshi KOMIYA 1d3f5c2c55 Fix typo 2017-02-11 17:33:49 +09:00
Takeshi KOMIYA 37f3050933 latex: Fix assertion error for complex table (refs: #3395) 2017-02-11 12:19:12 +09:00
Takeshi KOMIYA fe2daffb4a Fix #3377: Add support for Docutils 0.13 `:align:` option for tables 2017-02-11 10:28:18 +09:00
Takeshi KOMIYA 82e011cae6 Refactor: split .rst file for text-latex-table 2017-02-10 14:15:47 +09:00
Takeshi KOMIYA 8b2c92d54f latex: Refactor spanning cells 2017-02-08 00:11:46 +09:00
Takeshi KOMIYA fdd6f90792 Fix changes in #3381 is lost on merging 2017-02-04 22:29:40 +09:00
Takeshi KOMIYA 40a957009d Add testcases for latex tables 2017-02-04 20:09:46 +09:00
Takeshi KOMIYA 4f8b3f94d4 Add testcase for captioned table and longtable 2017-02-04 20:09:46 +09:00
Takeshi KOMIYA 10ae47d7b9 latex: Fix colwidths without :widths: option 2017-02-04 20:09:46 +09:00