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
  • Please don't post code fragments. Can you turn this into a compilable document that shows the problem. – Alan Munn Aug 31 '18 at 11:01
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.