我正在使用 spreadtab 包创建一个显示递归关系的表:
\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}
(其中以下各行与最后一行相同)。
我想将一些单元格的格式设置为与其他单元格不同,例如,将第一行设为粗体,或者更改一些内部单元格的颜色。
但是,当我将格式化代码插入单元格时,出现诸如“缺少 = 插入 \ifnum”之类的错误。
有没有办法在电子表格中做到这一点?
答案1
您需要:=
对需要格式化的单元格使用:
\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}