如何将属性应用于表格中不包括一个单元格的单个列

如何将属性应用于表格中不包括一个单元格的单个列

我正在使用这个代码:

\documentclass{article}
\usepackage{collcell}
\usepackage{array}% actually already loaded by `collcell`
\newcommand*{\mymacro}[1]{\fbox{#1}}% Do anything you like with `#1`
\newcolumntype{C}{>{\collectcell\mymacro}c<{\endcollectcell}}

\begin{document}

\begin{tabular}{Cc}
  TestA  & A longer test cell \\
  \empty & The new version supports 'verb'! \\
\end{tabular}

\end{document}

,将某些属性应用于单个列。有没有办法针对该列的一个单元格(例如顶部单元格)进行转义?

答案1

\multicolumn很简单:

\documentclass[svgnames]{article}
\usepackage{collcell}
\usepackage{array, makecell, xcolor}
\renewcommand\theadfont{\bfseries\color{Crimson!60!}}% actually already loaded by `collcell`
\newcommand*{\mymacro}[1]{\fbox{#1}}% Do anything you like with `#1`
\newcolumntype{C}{>{\collectcell\mymacro}c<{\endcollectcell}}

\begin{document}

\begin{tabular}{Cc}
\multicolumn{1}{c}{\thead{First Head}} & \thead{Second Head}\\
  TestA & A longer test cell \\
  \empty & The new version supports 'verb'! \\
\end{tabular}

\end{document} 

在此处输入图片描述

相关内容