我使用 MS Word 制作了此表格。但我有兴趣使用 LaTeX 制作此表格
% Table generated by Excel2LaTeX from sheet 'Sheet2'
\begin{table}[htbp]
\centering
\caption{Add caption}
\begin{tabular}{rcrrr}
%\toprule
\multirow{2}[2]{*}{} & \textbf{} & \multicolumn{1}{c}{\textbf{Development}} & \multicolumn{1}{c}{\textbf{}} & \multicolumn{1}{c}{\textbf{}} \\
%\midrule
& \textbf{License} & \multicolumn{1}{c}{\textbf{Language}} & \multicolumn{1}{c}{\textbf{Platforms}} & \multicolumn{1}{c}{\textbf{Support}} \\
\multicolumn{1}{c}{\textbf{}} & \textbf{} & \multicolumn{1}{c}{\textbf{}} & \multicolumn{1}{c}{\multirow{2}[1]{*}{\textbf{Linux/Unix, Windows, MAC OSX}}} & \multicolumn{1}{c}{} \\
\multicolumn{1}{c}{\textbf{Julius}} & \textbf{BSD} & \multicolumn{1}{c}{\textbf{C}} & \multicolumn{1}{c}{} & \multicolumn{1}{c}{\textbf{_}} \\
\multicolumn{1}{c}{\textbf{}} & \multirow{3}[0]{*}{\textbf{Prohibits redistributions and commercial use but R \& D allowed}} & \multicolumn{1}{c}{\textbf{}} & \multicolumn{1}{c}{\textbf{}} & \multicolumn{1}{c}{\textbf{}} \\
\multicolumn{1}{c}{\textbf{}} & & \multicolumn{1}{c}{\textbf{}} & \multicolumn{1}{c}{\textbf{Windows, Linux/Unix, MAC OSX}} & \multicolumn{1}{c}{\textbf{HTK Book, Active Mailing List}} \\
\multicolumn{1}{c}{\textbf{HTK}} & & \multicolumn{1}{c}{\textbf{C}} & & \\
\multicolumn{1}{c}{\textbf{}} & \textbf{} & \multicolumn{1}{c}{\textbf{}} & \multicolumn{1}{c}{\textbf{}} & \multicolumn{1}{c}{\textbf{}} \\
\multicolumn{1}{c}{\textbf{}} & \textbf{} & \multicolumn{1}{c}{\textbf{}} & \multicolumn{1}{c}{\textbf{Linux/Unix, Windows, MAC OSX}} & \multicolumn{1}{c}{\textbf{Very well documented}} \\
\multicolumn{1}{c}{\textbf{Sphinx}} & \textbf{BSD} & \multicolumn{1}{c}{\textbf{C, JAVA}} & & \\
& \textbf{} & & & \\
& \textbf{} & & & \\
& \textbf{} & & & \\
\multicolumn{1}{c}{\textbf{}} & \textbf{} & \multicolumn{1}{c}{\textbf{}} & \multicolumn{1}{c}{\textbf{}} & \multicolumn{1}{c}{\textbf{}} \\
\multicolumn{1}{c}{\textbf{ISIP ASR}} & \textbf{Public domain (no restrictions)} & \multicolumn{1}{c}{\textbf{C++}} & \multicolumn{1}{c}{\textbf{Windows}} & \multicolumn{1}{c}{\textbf{_}} \\
%\bottomrule
\end{tabular}%
\label{tab:addlabel}%
\end{table}%
我通过 Excel2LaTeX 生成此代码。但这不起作用。
答案1
这不是问题的答案,而是展示如何在 ConTeXt 中绘制这样的表格的答案。
我发现 ConTeXt 比 LaTeX 更适合这样的表格。ConTeXt 可以很好地分离内容和演示。例如,实现所需布局的基本结构是:
\startsetups table:style
% Fill in the details
\stopsetups
\starttext
\startTABLE[setups=table:style]
\NC \NC License \NC Development Language \NC Platforms \NC Support \NC \NR
\NC Julius \NC BSD \NC C \NC Linux/Unix, Windows, Mac OSX \NC --- \NC \NR
\NC HTK \NC Prohibits redistribution and commercial use, but R&D allowed
\NC C \NC Linux/Unix, Windows, Mac OSX \NC HTK Book, Active mailing list \NC \NR
\NC Sphinx \NC BSD \NC C, Java \NC Linux/Unix, Windows, Mac OSX \NC Very well documented \NC \NR
\NC ISIP ASR \NC Public Domain (no restrictions)
\NC C++ \NC Windows \NC --- \NC \NR
\stopTABLE
\stoptext
如果不进行任何修改table:style
,默认输出为:
要获得所需的输出,首先设置字体样式(粗体)和对齐方式(水平和垂直中间对齐),并在单元格周围添加一些偏移。这可以通过以下方式完成:
\startsetups table:style
\setupTABLE[align={middle,lohi}, foregroundstyle=bold, offset=0.25ex]
\stopsetups
这使
最后,使用以下命令设置单元格的背景颜色:
\setupTABLE[background=color, framecolor=white]
\setupTABLE[row][odd] [backgroundcolor=rowcolor1]
\setupTABLE[row][even][backgroundcolor=rowcolor2]
\setupTABLE[row][first][backgroundcolor=headercolor,foregroundcolor=white]
\setupTABLE[column][first][backgroundcolor=headercolor,foregroundcolor=white]
这使:
完整代码如下
\definecolor[rowcolor1] [h=E6EED6]
\definecolor[rowcolor2] [h=CDDDAC]
\definecolor[headercolor][h=9BBB58]
\startsetups table:style
\setupTABLE[align={middle,lohi}, foregroundstyle=bold, offset=0.5em]
\setupTABLE[background=color, framecolor=white]
\setupTABLE[row][odd] [backgroundcolor=rowcolor1]
\setupTABLE[row][even][backgroundcolor=rowcolor2]
\setupTABLE[row][first][backgroundcolor=headercolor,foregroundcolor=white]
\setupTABLE[column][first][backgroundcolor=headercolor,foregroundcolor=white]
\stopsetups
\starttext
\startTABLE[setups=table:style]
\NC \NC License \NC Development Language \NC Platforms \NC Support \NC \NR
\NC Julius \NC BSD \NC C \NC Linux/Unix, Windows, Mac OSX \NC --- \NC \NR
\NC HTK \NC Prohibits redistribution and commercial use, but R&D allowed
\NC C \NC Linux/Unix, Windows, Mac OSX \NC HTK Book, Active mailing list \NC \NR
\NC Sphinx \NC BSD \NC C, Java \NC Linux/Unix, Windows, Mac OSX \NC Very well documented \NC \NR
\NC ISIP ASR \NC Public Domain (no restrictions)
\NC C++ \NC Windows \NC --- \NC \NR
\stopTABLE
\stoptext
答案2
我认为可以使用几个命令来指定单元格背景颜色、行颜色甚至列颜色,您可以在 RGB 或 HTML 上设置颜色。以下是示例:
\documentclass{article}
\usepackage[table,xcdraw]{xcolor}
\begin{document}
\begin{table}[htbp]
\centering
\begin{tabular}{rcrrr}
\rowcolor[HTML]{32CB00} % Fill color of the entire row
something & something & something & something & something \\
\rowcolor[HTML]{67FD9A}
\cellcolor[HTML]{32CB00} something & something & something & something & something \\
\rowcolor[HTML]{9AFF99}
\cellcolor[HTML]{32CB00} something & something & something & something & something \\
\rowcolor[HTML]{67FD9A}
\cellcolor[HTML]{32CB00}something & something & something & something & something
\end{tabular}
\end{table}
\end{document}
确保在序言中使用 xcolor 选项,并且带有 "table" 和 "xcdraw" 。 \rowcolor[]{} 命令会填满整行,而 \cellcolor[]{} 只会为您放置的单元格着色。