2

I'm trying to add a table with gradient cell shading using the example from Gradient color in one cell of a table

My sample document looks like this:

\documentclass[a4paper,twoside,11pt]{article}
%\input{tla.tex}
\usepackage{mathtext} 
\usepackage[cp1251]{inputenc}
\usepackage[english,russian]{babel}
\usepackage{fancyhdr}
%\usepackage{newprog1e}
\usepackage{amsfonts,amsmath,amssymb,amsthm}
\usepackage{icomma}
\usepackage{bm}
%\newcommand{\defeq}{%
%   \mathrel{\vbox{\offinterlineskip\ialign{%
            %               \hfil##\hfil\cr
            %               $\scriptscriptstyle\triangle$\cr
            %               %\noalign{\kern0ex}
            %               $=$\cr
            %}}}}
\usepackage{float}
\usepackage{cmap}

%%% Работа с картинками \usepackage{graphicx} % Для вставки рисунков \graphicspath{{images/}}% папки с картинками \setlength\fboxsep{3pt} % Отступ рамки \fbox{} от рисунка \setlength\fboxrule{1pt} % Толщина линий рамки \fbox{} \usepackage{wrapfig} % Обтекание рисунков текстом \usepackage{subcaption}

%%% Работа с таблицами \usepackage{array,tabularx,tabulary,booktabs} % Дополнительная работа с таблицами \usepackage{longtable} % Длинные таблицы \usepackage{multirow} % Слияние строк в таблице \usepackage{paralist}

\usepackage%[labelfont=bf]% {caption} \captionsetup[table]{labelsep=space, justification=raggedright}

\usepackage[ligature, inference]{semantic} \usepackage{fixltx2e} \usepackage{xcolor} \def\SPSB#1#2{\rlap{\textsuperscript{\textcolor{red}{#1}}}\SB{#2}} \def\SP#1{\textsuperscript{\textcolor{black}{#1}}} \def\SB#1{\textsubscript{\textcolor{black}{#1}}} \usepackage{pdflscape} \def\labelitemi{--}

%\usepackage{geometry}

\usepackage{listings} \definecolor{textblue}{rgb}{.2,.2,.7} \definecolor{textred}{rgb}{0.54,0,0} \definecolor{textgreen}{rgb}{0,0.43,0} \lstset{language=SQL, numbers=left, numberstyle=\tiny, stepnumber=1, numbersep=-.5cm, tabsize=4, basicstyle=\ttfamily, keywordstyle=\color{textblue}, commentstyle=\color{textred},
stringstyle=\color{textgreen}, frame=none,
columns=fullflexible, keepspaces=true, xleftmargin=\parskip, showstringspaces=false} \usepackage{tikz} \usepackage{subcaption} \renewcommand\thesubfigure{\asbuk{subfigure}}

\newenvironment{errortrace} {\ttfamily\list{}{\leftmargin=1em\itemindent=-1em\parsep=\parskip}% \catcode\.=\active \begingroup\lccode~=`. \lowercase{\endgroup\def~}{.\penalty0 }% \obeylines\raggedright\item\relax} {\endlist}

\tolerance=1000

\newcommand{\defi}{\stackrel{\mathrm{def}}{=}}

\numberwithin{equation}{section} \newtheorem{theorem}{Теорема} \newtheorem{definition}{Определение}[section] \newtheorem{lemma}{Лемма}[section] %\newtheorem{theorem_ru}{Теорема} \newtheorem{hypothesis}{Предположение}[section] \newtheorem{assertion}{Утверждение}[section]

% tabular cell shadings start

\makeatletter \tikzset{% remember picture with id/.style={% remember picture, overlay, save picture id=#1, }, save picture id/.code={% \edef\pgf@temp{#1}% \immediate\write\pgfutil@auxout{% \noexpand\savepointas{\pgf@temp}{\pgfpictureid}}% }, if picture id/.code args={#1#2#3}{% @ifundefined{save@pt@#1}{% \pgfkeysalso{#3}% }{ \pgfkeysalso{#2}% } } }

\def\savepointas#1#2{% \expandafter\gdef\csname save@pt@#1\endcsname{#2}% }

\def\tmk@labeldef#1,#2@nil{% \def\tmk@label{#1}% \def\tmk@def{#2}% }

\tikzdeclarecoordinatesystem{pic}{% \pgfutil@in@,{#1}% \ifpgfutil@in@% \tmk@labeldef#1@nil \else \tmk@labeldef#1,(0pt,0pt)@nil \fi @ifundefined{save@pt@\tmk@label}{% \tikz@scan@one@point\pgfutil@firstofone\tmk@def }{% \pgfsys@getposition{\csname save@pt@\tmk@label\endcsname}\save@orig@pic% \pgfsys@getposition{\pgfpictureid}\save@this@pic% \pgf@process{\pgfpointorigin\save@this@pic}% \pgf@xa=\pgf@x \pgf@ya=\pgf@y \pgf@process{\pgfpointorigin\save@orig@pic}% \advance\pgf@x by -\pgf@xa \advance\pgf@y by -\pgf@ya }% }

\newcommand\tikzmark[2][]{% \tikz[remember picture with id=#2] {#1;}} \makeatother % end of Andrew's code

\newcommand\ShadeCell[4][0pt]{% \begin{tikzpicture}[overlay,remember picture]% \shade[#4] ( $ (pic cs:#2) + (0pt,2ex) $ ) rectangle ( $ (pic cs:#3) +
(0pt,-#1*\baselineskip-.8ex) $ ); \end{tikzpicture}% }%

% tabular cell shadings end

\begin{document}

\ShadeCell{start1}{end1}{left color=green!20,right color=green!20}
\ShadeCell{start2}{end2}{left color=green!20,right color=green!20}
\ShadeCell{start3}{end3}{left color=green!20,right color=red!20}
\ShadeCell{start4}{end4}{left color=green!20,right color=green!20}
\ShadeCell{start5}{end5}{left color=green!20,right color=red!20}
\ShadeCell{start6}{end6}{left color=red!20,right color=red!20}
\ShadeCell{start7}{end7}{left color=green!20,right color=green!20}
\ShadeCell{start8}{end8}{left color=green!20,right color=red!20} \ShadeCell{start9}{end9}{left color=red!20,right color=red!20}

\begin{table}[h!]
\centering \captionsetup{justification=raggedleft, singlelinecheck=false} \caption{Практическая реализация требований} \begin{tabular}{ >{\raggedright\arraybackslash}m{3.5cm}| >{\centering\arraybackslash}m{1.8cm}| >{\centering\arraybackslash}m{1.8cm}| >{\centering\arraybackslash}m{1.8cm}}
%&&&&\[.1em] &\centering Физический уровень & \centering Системный уровень & \centering
Уровень СПО \tabularnewline [2.5ex] \hline &&& \ [.1em] Контроль ''легальных'' траекторий и сред распространения & \multicolumn{1}{!{\tikzmark{start1}} c !{\vrule\tikzmark{end1}}}{+} &
\multicolumn{1}{!{\tikzmark{start2}} c !{\vrule\tikzmark{end2}}}{+} &
\multicolumn{1}{!{\tikzmark{start3}} c !{\tikzmark{end3}}}{ $ \pm $} \ [4ex] \hline &&& \ [.1em] Контроль скрытых каналов & \multicolumn{1}{!{\tikzmark{start4}} c !{\vrule\tikzmark{end4}}}{+} & \multicolumn{1}{!{\tikzmark{start5}} c !{\vrule\tikzmark{end5}}}{$ \pm $} & \multicolumn{1}{!{\tikzmark{start6}} c !{\tikzmark{end6}}}{ -- } \ [4ex] \hline &&& \ [.1em] Формальное доказательство эффективности механизмов ЗИ
& \multicolumn{1}{!{\tikzmark{start7}} c !{\vrule\tikzmark{end7}}}{+} & \multicolumn{1}{!{\tikzmark{start8}} c !{\vrule\tikzmark{end8}}}{$ \pm $} & \multicolumn{1}{!{\tikzmark{start9}} c !{\tikzmark{end9}}}{ -- } \ [4ex]
\end{tabular} \label{table:1} \end{table
}
\end{document}

But it produces an error:

Runaway argument? (pic cs:start1) + (0pt,2ex) $ ) rectangle ( $ (pic cs:end1) + (0pt,-\ETC. ! Paragraph ended before \tikz@parse@calculator was complete.

\par l.199
I suspect you've forgotten a `}', causing me to apply this control sequence to too much text. How can we recover? My plan is to forget the whole thing and hope for the best. )

Similar code works fine in beamer.

enter image description here

Any help would be appreciated. Thanks. Alex.

1 Answers1

1

For the $ notation in tikz coordinates (as in the definition of \ShadeCell) to work, you need to load the calc library:

\usepackage{tikz}
\usetikzlibrary{calc}%%% add this line
gernot
  • 49,614