On 02/08/11 Michael P. Soulier said:

> Hi,
> 
> I want to style my html and latex output such that each table header has a
> particular background color, and each row alternates between two colors.
> 
> This is built-in in rst2pdf, but beyond hacking the output I'm not sure how to
> do this in Sphinx.
> 
> Is this possible?

This simple patch to the latex writer shows how it might be done.

msoulier@anton:...es/sphinx/writers$ diff -u latex.py.orig latex.py
--- latex.py.orig   2011-08-02 08:38:24.000000000 -0400
+++ latex.py    2011-08-02 08:42:12.000000000 -0400
@@ -48,6 +48,11 @@
 \newcommand{\sphinxlogo}{%(logo)s}
 \renewcommand{\releasename}{%(releasename)s}
 %(makeindex)s
+\usepackage{color}
+\usepackage{colortbl}
+\definecolor{tableheader}{rgb}{0,0,1}
+\definecolor{row1}{rgb}{0.7,0.7,0.7}
+\definecolor{row2}{rgb}{0.9,0.9,0.9}
 '''
 
 BEGIN_DOC = r'''
@@ -712,6 +717,10 @@
         self.body.append('\\hline\n')
 
     def visit_row(self, node):
+        if self.table.rowcount % 2 == 0:
+            self.body.append('\\rowcolor{row1}\n')
+        else:
+            self.body.append('\\rowcolor{row2}\n')
         self.table.col = 0
     def depart_row(self, node):
         self.body.append('\\\\\n')

mps

-- 
You received this message because you are subscribed to the Google Groups 
"sphinx-dev" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sphinx-dev?hl=en.

Reply via email to