title: Change Latex Table Style using Sphinx
body: <p>I'm using <code>sphinx</code> to generate our company manuals. In our legacy manuals we have a certain table style, that we would like to keep. </p>
  
  <p>The table style consists of tables having a header with dark green background, then there are several light-green background rows and after that several rows with a white background.</p>
  
  <p><code>Sphinx</code> generates my LaTeX input files, which are then made an PDF using PdfLatex. There is the possibility to include LaTeX specific comments right before the LaTeX table starts with <code>:raw-role:</code>.</p>
  
  <p>The input RST file:</p>
  
  <pre><code>.. role:: raw-role(raw)
     :format: latex
  
  :raw-role:`\firstRow`   
  
  === === ===
   A   B   C
  === === ===
  1A   1B  1C
  2A   2B  2C
  3A   3B  3C
  4A   4B  4C
  === === ===
  </code></pre>
  
  <p>Will be transformed into:</p>
  
  <pre><code>\firstRow
  
  \noindent\begin{tabulary}{\linewidth}{|L|L|L|}
  \hline
  \sphinxstylethead{\relax 
  A
  \unskip}\relax &amp;\sphinxstylethead{\relax 
  B
  \unskip}\relax &amp;\sphinxstylethead{\relax 
  C
  \unskip}\relax \\
  \hline
  1A
  &amp;
  1B
  &amp;
  1C
  \\
  \hline
  2A
  &amp;
  2B
  &amp;
  2C
  \\
  \hline
  3A
  &amp;
  3B
  &amp;
  3C
  \\
  \hline
  4A
  &amp;
  4B
  &amp;
  4C
  \\
  \hline\end{tabulary}
  </code></pre>
  
  <p>I'm now in need for a command called <code>\firstRow</code> that modifies the behaviour of the <code>\tabulary</code> environment, so that the header has a dark-green background, the first row beneath has a light-green background and the remaining rows having a white background.</p>
  
  <p>If everything else fails there might be still the possibility to automatically replace the contents of the cells in the RST-File using a tool like <code>pandoc</code>.
  For example it might be possible to replace <code>1A</code> by <code>:raw-role:'\background{green}' 1A</code> in the RST file and then to transform it with <code>sphinx</code>.</p>
  
  <p>I found it interesting that in case of the sphinx <code>HTML</code> target the problem can be very easily solved by using an adapted <code>style.css</code> containing the class <code>firstRow</code> together with a command like <code>.. rst-class:: firstRow</code>, where <code>firstRow</code> represents a table style with one light green background. </p>
  
  <p>Unfortunately, the LaTeX target misses something similar to <code>style.css</code>.</p>