# Color alternate row in latex table

The often mentioned solution is the following:

\usepackage[table]{xcolor} % loads also colortbl
\rowcolors{1}{gray!10}{white} % color rows with gray!10 then white and so on starting with row 1


This works when when it doesn’t it is not very straightforward to figure out why.

If you have run into ‘xcolor’ related issue something like xcolor is already loaded etc. etc., Then do the following: At the very top of document, even before \documentclass [2].

\PassOptionsToPackage{table}{xcolor}


And do not \usepackage[table]{xcolor}; and then somewhere in your document — before the table — use the rowcolors statement.

\rowcolors{1}{gray!10}{white}


The package xcolor is heavily used by many other packages and it is very likely that some of package you have loaded before are already using xcolor therefore this error.

# References:

1. https://tex.stackexchange.com/a/5365/8087
2. https://tex.stackexchange.com/a/5375/8087 (see comment by Bertram)
Lets say the expression is sys which contains variable RM. You first want to replace RM by R_m .  Be sure to load mactex-utilities if you have matrix. Without loading this module, the tex command generates TeX output, not LaTeX.
load( "mactex-utilities" )$sys : RM * a / b * log( 10 )$
texput( RM, "R_m")$sysTex : tex( sys, false)$
with_stdout( "outout.txt", display( sysTex ) )$ Other methods such as stringout, save and write put extra non-TeX characters in file. I get the following in file outout.txt after executing the above. {{\log 10\,R_m\,a}\over{b}} # Fix “unknown script ‘context.lua’ or ‘mtx-context.lua'” • $ locate mtx-context.lua in linux-shell. If it is found, then you probably need to export TEXMF variable.
• In my case, all I had to do: \$ export TEXMF=/usr/share/texmf on my system with  OpenSUSE Leap installed. I installed texlive-context package using zypper`.