Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Latex/PDF: change longtable to be correctly row colored #4045

Closed
salim-b opened this issue Nov 6, 2017 · 3 comments
Closed

Latex/PDF: change longtable to be correctly row colored #4045

salim-b opened this issue Nov 6, 2017 · 3 comments

Comments

@salim-b
Copy link
Contributor

salim-b commented Nov 6, 2017

If one would like to have zebra striped table rows (or any other kind of row coloring) in the PDF output converted from Pandoc Markdown, the longtable environment could be redefined in the YAML header like the following:

---
header-includes:
  - \usepackage[table]{xcolor}
  - \definecolor{lightgray}{gray}{0.95}
  - \let\OldLongtable\longtable
  - \let\OldEndLongtable\endlongtable
  - \renewenvironment{longtable}{\rowcolors{1}{white}{lightgray}\OldLongtable}{\OldEndLongtable}
---

Now the problem with this is that the resulting row coloring is wider than the actual table. Therefore I've asked for a solution on the Tex/Latex Stack Exchange site and a user called Zarko recently provided a workaround – but on the level of the intermediary Latex code. Right now the longtable for a 4-column table with right-left-left-center alignments produced by Pandoc starts with

\begin{longtable}[]{@{}rllc@{}}

Zarko changed this into

\begin{longtable}[]{@{} >{\columncolor{white}[0pt][\tabcolsep]}rll >{\columncolor{white}[\tabcolsep][0pt]} c@{}}

which makes the row coloring the correct width.

Now I wonder if his adjustmens could be somehow incorporated into Pandoc or it's default Latex template to allow users to define zebra-striped tables. 🙂

(Unfortunately I'm not proficient enough to assess – not to speak of implement – this.)

Addendum:
As Zarko pointed out, just removing the two @{} so that the longtable begins only with

\begin{longtable}[]{rllc}

also fixes the problem. But I guess the @{} do serve some purpose, right?

@mb21
Copy link
Collaborator

mb21 commented Nov 7, 2017

there's also quite some discussion about table LaTeX output in this issue: #1023

@Wandmalfarbe
Copy link
Contributor

This seems to be a duplicate of #3929.

@mb21
Copy link
Collaborator

mb21 commented Nov 9, 2017

Duplicate of #3929

@mb21 mb21 marked this as a duplicate of #3929 Nov 9, 2017
@mb21 mb21 closed this as completed Nov 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants