我使用 \newcommand 定义一个变量,并在其中一个表参数中使用该变量,但产生了错误
这是我的代码:
\documentclass[a4paper,11pt,english]{report}
\usepackage{longtable}
\usepackage{multirow}
\usepackage{graphicx}
\usepackage[table,xcdraw]{xcolor}
\usepackage{lipsum} % just for dummy text- not needed for a longtable
\begin{document}
\lipsum[1]
\lipsum[1]
\lipsum[1]
\newcommand{\SecondCol}{p{0.175\linewidth}}
\definecolor{lightgray}{HTML}{EFEFEF}
\begin{longtable}{|>{\columncolor{lightgray}} p{0.2\linewidth} | \SecondCol | p{0.175\linewidth} |}
\noalign{\nobreak\vskip-.5pt} \hline\noalign{\nobreak\vskip.5pt}
Here & Here & Here
\\[.5pt]\noalign{\nobreak\vskip-.5pt} \hline\noalign{\nobreak\vskip.5pt}
\endfirsthead
\noalign{\nobreak\vskip-.5pt} \hline\noalign{\nobreak\vskip.5pt}
Here & Here & Here
\\[.5pt]\noalign{\nobreak\vskip-.5pt} \hline\noalign{\nobreak\vskip.5pt}
\endhead
\noalign{\nobreak\vskip-.5pt} \hline\noalign{\nobreak\vskip.5pt}
\endfoot
foo & bar & dada \\[.5pt]\noalign{\nobreak\vskip-.5pt} \hline\noalign{\nobreak\vskip.5pt}
foo & bar & dada \\ \cline{2-2}
foo & bar & dada \\ \cline{2-2}
foo & bar & dada \\ \cline{2-2}
foo & bar & dada \\ \cline{2-2}
foo & bar & dada \\ \cline{2-2}
foo & bar & dada \\ \cline{2-2}
foo & bar & dada \\ \cline{2-2}
foo & bar & dada \\ \cline{2-2}
foo & bar & dada \\ \cline{2-2}
foo & bar & dada \\[.5pt]\noalign{\nobreak\vskip-.5pt} \hline\noalign{\nobreak\vskip.5pt}
\caption{Your caption here} % needs to go inside longtable environment
\label{tab:myfirstlongtable}
\end{longtable}
\end{document}
问题出在 \SeconCol 变量上。有什么帮助吗?