段落在 \tikz@parse@calculator 完成之前结束

段落在 \tikz@parse@calculator 完成之前结束

我正在尝试使用以下示例添加带有渐变单元格阴影的表格 表格中某个单元格的渐变颜色

我的示例文档如下所示:

\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}

但它会产生一个错误:

失控参数?(pic cs:start1)+(0pt,2ex)$)矩形($(pic cs:end1)+(0pt,-\ETC。!段落在\tikz@parse@calculator 完成之前结束。\par l.199
我怀疑你忘记了一个“}”,导致我将这个控制序列应用于太多文本。我们怎样才能恢复?我的计划是忘记整件事并希望得到最好的结果。)

类似的代码在 beamer 中运行良好。

在此处输入图片描述

任何帮助都将不胜感激。谢谢。亚历克斯。

答案1

为了使$tikz 坐标中的符号(如 的定义\ShadeCell)起作用,您需要加载calc库:

\usepackage{tikz}
\usetikzlibrary{calc}%%% add this line

相关内容