我正在尝试创建一个表格,列出不同提供商的优点和缺点,但我无法使命令\multirow
可读。我应该把它放在哪里?我从这里发帖的人那里得到了这个表格代码。我对乳胶还不熟悉,所以我想了解为什么它没有读取以及我应该把它发布在哪里。这是我正在使用的代码。
\usepackage[utf8]{inputenc}
\usepackage[toc]{glossaries}
\usepackage{enumitem}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{float}
\usepackage{multirow}
\usepackage{tabu}
\usepackage{array}
\newcommand*{\arraycolor}[1]{\protect\leavevmode\color{#1}}
\newcolumntype{A}{>{\columncolor{blue!50!white}}c}
\newcolumntype{B}{>{\columncolor{green!50!white}}c}
\newcolumntype{C}{>{\columncolor{FireBrick!50}}c}
\newcolumntype{D}{>{\columncolor{Gray!42}}c}
\begin{table} [H]
\begin{center}
\sffamily
\arrayrulecolor{white}
\arrayrulewidth=1pt
\renewcommand{\arraystretch}{1.5}
\rowcolors[\hline]{3}{.!50!White}{}
\begin{tabular}{D|B|C}
%\multicolumn{4}{D}{\bfseries Example table}\\
\rowcolor{.!50!Black}
\arraycolor{White}\bfseries Solution &
\arraycolor{White}\bfseries Advantages &
\arraycolor{White}\bfseries Disadvantages \\
\multirow{3}{*}{Provider A} & B & C \\
Provider B & B & F \\
Provider C & C & G \\
Provider D & D & H \\
Provider E & D & H \\
\end{tabular}
\end{center}
\end{table}
答案1
这是一个快速而粗略的解决方法。您需要提前定义要跨越的所有行(无论如何这都是必需的)。
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[toc]{glossaries}
\usepackage{enumitem}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{float}
\usepackage{multirow}
\usepackage{tabu}
\usepackage[table,dvipsnames,svgnames]{xcolor}
\usepackage{array}
\newcommand*{\arraycolor}[1]{\protect\leavevmode\color{#1}}
\newcolumntype{A}{>{\columncolor{blue!50!white}}c}
\newcolumntype{B}{>{\columncolor{green!50!white}}c}
\newcolumntype{C}{>{\columncolor{FireBrick!50}}c}
\newcolumntype{D}{>{\columncolor{Gray!42}}c}
\begin{document}
\begin{table} [H]
\begin{center}
\sffamily
\arrayrulecolor{white}
\arrayrulewidth=1pt
\renewcommand{\arraystretch}{1.5}
\rowcolors[\hline]{3}{.!50!White}{}
\begin{tabular}{D|B|C}
%\multicolumn{4}{D}{\bfseries Example table}\\
\rowcolor{.!50!Black}
\arraycolor{White}\bfseries Solution &
\arraycolor{White}\bfseries Advantages &
\arraycolor{White}\bfseries Disadvantages \\
& B & C \\
& &\\
\multirow{-3}{*}{Provider A}& &\\
Provider B & B & F \\
Provider C & C & G \\
Provider D & D & H \\
Provider E & D & H \\
\end{tabular}
\end{center}
\end{table}
\end{document}
答案2
这是彩色表格中的经典问题\multirow
。诀窍是将\multirow
命令放在最后一个“多行”单元格中,并使用负参数:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[toc]{glossaries}
\usepackage{enumitem}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{float}
\usepackage{multirow}
\usepackage{tabu}
\usepackage[table, svgnames]{xcolor}
\usepackage{array}
\newcommand*{\arraycolor}[1]{\protect\leavevmode\color{#1}}
\newcolumntype{A}{>{\columncolor{blue!50!white}}c}
\newcolumntype{B}{>{\columncolor{green!50!white}}c}
\newcolumntype{C}{>{\columncolor{FireBrick!50}}c}
\newcolumntype{D}{>{\columncolor{Gray!42}}c}
\begin{document}
\begin{table} [H]
\begin{center}
\sffamily
\arrayrulecolor{white}
\arrayrulewidth=1pt
\renewcommand{\arraystretch}{1.5}
\rowcolors[\hline]{3}{.!50!White}{}
\begin{tabular}{D|B|C}
%\multicolumn{4}{D}{\bfseries Example table}\\
\rowcolor{.!50!Black}
\arraycolor{White}\bfseries Solution &
\arraycolor{White}\bfseries Advantages &
\arraycolor{White}\bfseries Disadvantages \\
& B & C \\
& & \\
\multirow{-3}{*}{Provider A} & & \\
Provider B & B & F \\
Provider C & C & G \\
Provider D & D & H \\
Provider E & D & H \\
\end{tabular}
\end{center}
\end{table}
\end{document}
答案3
这有点难以理解,但从您对其他答案的评论来看,这似乎就是您想要的。我曾经\cellcolor
覆盖 定义的颜色设置\rowcolors
。
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{booktabs}
\usepackage{float}
\usepackage[table, svgnames]{xcolor}
\usepackage{array}
\newcommand*{\arraycolor}[1]{\protect\leavevmode\color{#1}}
\newcolumntype{A}{>{\columncolor{blue!50!white}}c}
\newcolumntype{B}{>{\columncolor{green!50!white}}c}
\newcolumntype{C}{>{\columncolor{FireBrick!50}}c}
\newcolumntype{D}{>{\columncolor{Gray!42}}c}
\begin{document}
\begin{table}[H]
\centering
\sffamily
\arrayrulecolor{white}
\arrayrulewidth=1pt
\renewcommand{\arraystretch}{1.5}
\rowcolors[\hline]{3}{.!50!White}{}
\begin{tabular}{D|B|C}
%\multicolumn{4}{D}{\bfseries Example table}\\
\rowcolor{.!50!Black}
\arraycolor{White}\bfseries Solution &
\arraycolor{White}\bfseries Advantages &
\arraycolor{White}\bfseries Disadvantages \\
Provider A & B & C \\
\cellcolor{Gray!42}& \cellcolor{green!50!white} & \cellcolor{FireBrick!50}\\
&&\\
Provider B & B & F \\
Provider C & C & G \\
Provider D & D & H \\
Provider E & D & H \\
\end{tabular}
\end{table}
\end{document}