如何为多行合并单元格着色?

如何为多行合并单元格着色?

如何为多行合并单元格着色?我想为单元格完全着色,但我不知道该怎么做。提前谢谢您。

% XeLaTeX

\documentclass[12pt,a4paper,oneside]{article}

\usepackage{xunicode}
\usepackage{xltxtra}
\usepackage{fontspec}
\usepackage{polyglossia}
\setdefaultlanguage{portuges}
\usepackage[bookmarks=true,
  citecolor=black,
  filecolor=black,
  linkcolor=black,
  urlcolor=black,
  unicode=false,
  colorlinks=false,
  plainpages=false,
  pdfpagelabels,
  colorlinks=true,
  xetex]{hyperref}
\usepackage{longtable}
\usepackage{multirow}
\usepackage{lscape}
\usepackage{booktabs}
\usepackage{array}
\usepackage{rotating}
\usepackage[table]{xcolor}


\begin{document}

%\multirow{nrows}[bigstruts]{width}[fixup]{text}
\renewcommand{\arraystretch}{1.2}

\begin{landscape}
\small
\begin{longtable}{|c|c|c|c|c|c|c|c|c|c|c|c|c|c|}
\hline
\multicolumn{6}{|c|}{Elementos do Plano de Acção} & \multicolumn{8}{c|}{Temas} \\ \hline
%
&  & \multicolumn{4}{c|}{\raisebox{-1em}{Concretização}} &  &  &  &  &  &  &  &  \\ [2em] \cline{3-6}
%
\multicolumn{1}{|c|}{\multirow{-2}{*}[3em]{\cellcolor{red!10}\begin{sideways} Acção \# \end{sideways}}} & 
\multirow{-2}{*}{\rotatebox[origin=c]{00}{\begin{minipage}{14em}\centering\raisebox{0em}{ Acções Previstas} \end{minipage}}} & 
\begin{minipage}{6em}\centering\raisebox{-4em}{ Recursos } \end{minipage} & 
\begin{minipage}{6em}\centering\raisebox{-4em}{ Intervenientes } \end{minipage} & 
\begin{minipage}{6em}\raisebox{-4em}{\centering Calendarização } \end{minipage} & 
\begin{minipage}{6em}\centering\raisebox{-4em}{ Avaliação } \end{minipage} & 
\multicolumn{1}{c|}{\multirow{-2}{*}[3em]{\begin{sideways} Água \end{sideways}}} & 
\multicolumn{1}{c|}{\multirow{-2}{*}[3em]{\begin{sideways} Resíduos \end{sideways}}} & 
\multicolumn{1}{c|}{\multirow{-2}{*}[3em]{\begin{sideways} Energia \end{sideways}}} & 
\multicolumn{1}{c|}{\multirow{-2}{*}[3em]{\begin{sideways} Espaços exteriores \end{sideways}}} & 
\multicolumn{1}{c|}{\multirow{-2}{*}[3em]{\begin{sideways} Agricultura Biológica \end{sideways}}} & 
\multicolumn{1}{c|}{\multirow{-2}{*}[3em]{\begin{sideways} Mar \end{sideways}}} & 
\multicolumn{1}{c|}{\multirow{-2}{*}[3em]{\begin{sideways} Biodiversidade \end{sideways}}} & 
\multicolumn{1}{c|}{\multirow{-2}{*}[3em]{\begin{sideways} Alterações climáticas \end{sideways}}} \\ [4em] 
\endfirsthead

\multicolumn{14}{r}{Continua na próxima página}
\endfoot

\hline \hline
\endlastfoot


\end{longtable}
\end{landscape}

\end{document}

在此处输入图片描述

答案1

\multirow指定一次后无法将颜色放入两个单元格中\cellcolor。如果要为两个单元格着色,请输入\cellcolor两次,例如:

....
\cellcolor{red!10}&  & \multicolumn{4}{c|}{\raisebox{-1em}{Concretização}} &  &  &  &  &  &  &  &  \\ [2em] \cline{3-6}       %%% here in the first cell
%
\multicolumn{1}{|c|}{\multirow{-2}{*}[3em]{\cellcolor{red!10}\begin{sideways} Acção \# \end{sideways}}} & 
....

完整代码:

% 西拉特克斯

\documentclass[12pt,a4paper,oneside]{article}

\usepackage{xunicode}
\usepackage{xltxtra}
\usepackage{fontspec}
\usepackage{polyglossia}
\setdefaultlanguage{portuges}
\usepackage[bookmarks=true,
  citecolor=black,
  filecolor=black,
  linkcolor=black,
  urlcolor=black,
  unicode=false,
  colorlinks=false,
  plainpages=false,
  pdfpagelabels,
  colorlinks=true,
  xetex]{hyperref}
\usepackage{longtable}
\usepackage{multirow}
\usepackage{lscape}
\usepackage{booktabs}
\usepackage{array}
\usepackage{rotating}
\usepackage[table]{xcolor}


\begin{document}

%\multirow{nrows}[bigstruts]{width}[fixup]{text}
\renewcommand{\arraystretch}{1.2}

\begin{landscape}
\small
\begin{longtable}{|c|c|c|c|c|c|c|c|c|c|c|c|c|c|}
\hline
\multicolumn{6}{|c|}{Elementos do Plano de Acção} & \multicolumn{8}{c|}{Temas} \\ \hline
%
\cellcolor{red!10}&  & \multicolumn{4}{c|}{\raisebox{-1em}{Concretização}} &  &  &  &  &  &  &  &  \\ [2em] \cline{3-6}       %%% here in the first cell
%
\multicolumn{1}{|c|}{\multirow{-2}{*}[3em]{\cellcolor{red!10}\begin{sideways} Acção \# \end{sideways}}} & 
\multirow{-2}{*}{\rotatebox[origin=c]{00}{\begin{minipage}{14em}\centering\raisebox{0em}{ Acções Previstas} \end{minipage}}} &
\begin{minipage}{6em}\centering\raisebox{-4em}{ Recursos } \end{minipage} &
\begin{minipage}{6em}\centering\raisebox{-4em}{ Intervenientes } \end{minipage} &
\begin{minipage}{6em}\raisebox{-4em}{\centering Calendarização } \end{minipage} &
\begin{minipage}{6em}\centering\raisebox{-4em}{ Avaliação } \end{minipage} &
\multicolumn{1}{c|}{\multirow{-2}{*}[3em]{\begin{sideways} Água \end{sideways}}} &
\multicolumn{1}{c|}{\multirow{-2}{*}[3em]{\begin{sideways} Resíduos \end{sideways}}} &
\multicolumn{1}{c|}{\multirow{-2}{*}[3em]{\begin{sideways} Energia \end{sideways}}} &
\multicolumn{1}{c|}{\multirow{-2}{*}[3em]{\begin{sideways} Espaços exteriores \end{sideways}}} &
\multicolumn{1}{c|}{\multirow{-2}{*}[3em]{\begin{sideways} Agricultura Biológica \end{sideways}}} &
\multicolumn{1}{c|}{\multirow{-2}{*}[3em]{\begin{sideways} Mar \end{sideways}}} &
\multicolumn{1}{c|}{\multirow{-2}{*}[3em]{\begin{sideways} Biodiversidade \end{sideways}}} &
\multicolumn{1}{c|}{\multirow{-2}{*}[3em]{\begin{sideways} Alterações climáticas \end{sideways}}} \\ [4em]
\endfirsthead

\multicolumn{14}{r}{Continua na próxima página}
\endfoot

\hline \hline
\endlastfoot


\end{longtable}
\end{landscape}

\end{document}

在此处输入图片描述

相关内容