2

I am using the spreadtab package to create a table that shows a recurrence relation:

\begin{spreadtab}{{tabular}{>{\headingstyle}c|cccccccccc}}
@ $r\downarrow ~ s \rightarrow$
& 0        & [-1,0]+1   & [-1,0]+1 & [-1,0]+1  & [-1,0]+1  & [-1,0]+1  & [-1,0]+1  & [-1,0]+1  & [-1,0]+1  & [-1,0]+1 
\\ \hline
0
& 1          & 0                   & 0        & 0 & 0 & 0 & 0 & 0 & 0 & 0
\\ 
[0,-1]+1   
& 1          & ([-1,-1]+[0,-1])/2   & min([-1,-2],([-1,-1]+[0,-1])/2)   & min([-1,-2],([-1,-1]+[0,-1])/2)   & min([-1,-2],([-1,-1]+[0,-1])/2)   & min([-1,-2],([-1,-1]+[0,-1])/2)   & min([-1,-2],([-1,-1]+[0,-1])/2)   & min([-1,-2],([-1,-1]+[0,-1])/2)   & min([-1,-2],([-1,-1]+[0,-1])/2)   & min([-1,-2],([-1,-1]+[0,-1])/2)   

...
\end{spreadtab}

(where the following lines are identical to the last line).

I would like to format some cells differently than the others, for example, make the first row boldface, or change the color of some inner cells.

However, when I insert formatting code into a cell, I get errors such as "Missing = inserted for \ifnum".

Is there a way to do this in spreadtab?

1 Answers1

3

You need to use := for the cells that need formatting:

\documentclass{article}
\usepackage{spreadtab,array,xcolor}

\newcommand{\headingstyle}{}% ???

\newcommand{\textred}[1]{\textcolor{red}{#1}}

\begin{document}

\begin{spreadtab}{{tabular}{>{\headingstyle}c|cccccccccc}}
@ $r\downarrow ~ s \rightarrow$
& 0        & [-1,0]+1   & [-1,0]+1 & [-1,0]+1  & [-1,0]+1  & [-1,0]+1  & [-1,0]+1  & [-1,0]+1  & [-1,0]+1  & [-1,0]+1 
\\ \hline
0
& 1          & 0                   & 0        & 0 & 0 & 0 & 0 & 0 & 0 & 0
\\ 
[0,-1]+1   
& 1          & ([-1,-1]+[0,-1])/2   & min([-1,-2],([-1,-1]+[0,-1])/2)   & min([-1,-2],([-1,-1]+[0,-1])/2)   & min([-1,-2],([-1,-1]+[0,-1])/2)   & min([-1,-2],([-1,-1]+[0,-1])/2)   & min([-1,-2],([-1,-1]+[0,-1])/2)   & min([-1,-2],([-1,-1]+[0,-1])/2)   & min([-1,-2],([-1,-1]+[0,-1])/2)   & min([-1,-2],([-1,-1]+[0,-1])/2)   
\end{spreadtab}

\bigskip

\begin{spreadtab}{{tabular}{>{\headingstyle}c|cccccccccc}}
@ $r\downarrow ~ s \rightarrow$
& 0        & \textbf{:={[-1,0]+1}}   & \textit{:={[-1,0]+1}} & [-1,0]+1  & [-1,0]+1  & [-1,0]+1  & [-1,0]+1  & [-1,0]+1  & [-1,0]+1  & [-1,0]+1 
\\ \hline
0
& 1          & 0                   & 0        & 0 & 0 & 0 & 0 & 0 & 0 & 0
\\ 
[0,-1]+1   
& 1          & \textred{:={([-1,-1]+[0,-1])/2}}   & min([-1,-2],([-1,-1]+[0,-1])/2)   & min([-1,-2],([-1,-1]+[0,-1])/2)   & min([-1,-2],([-1,-1]+[0,-1])/2)   & min([-1,-2],([-1,-1]+[0,-1])/2)   & min([-1,-2],([-1,-1]+[0,-1])/2)   & min([-1,-2],([-1,-1]+[0,-1])/2)   & min([-1,-2],([-1,-1]+[0,-1])/2)   & min([-1,-2],([-1,-1]+[0,-1])/2)   
\end{spreadtab}

\end{document}

enter image description here

egreg
  • 1,121,712