大家好,我在 word 中制作了一个非常奇怪的表格,我想在 LaTeX 中制作它,因为我是 LaTeX 新手,我不知道如何将一列拆分成几行,有人能告诉我如何编码吗,我附上了一张我想要的图片
我可以制作第一行,但我知道如何将第二行分成红绿蓝行
更新
伙计们这是我正在使用的代码
\begin{table}
\begin{tabular}{ |
>{\centering\arraybackslash} p{5cm}
| >{\centering\arraybackslash}p{2cm}
| >{\centering\arraybackslash}p{2cm}
| >{\centering\arraybackslash}p{2cm}
| >{\centering\arraybackslash}p{2cm} |} \hline
\bfseries{Oil Concentration} & \bfseries{Colour} & \bfseries{Oil} & \bfseries{Water} & \bfseries{Rock}\\ \hline
\multirow{3}{*}{N-Decane + Oil Red O} & Red & 88 & 109 & 24 \\ \hline
& Green & 72 & 112 & 14 \\ \hline
& Blue & 58 & 105 & 13 \\ \hline
\end{tabular}
\end{table}
但是现在我遇到一个新问题,如何删除 N-Decane + Oil Red O 之间第一列的水平线???
答案1
这里有两种解决方案,一种是带垂直线的,一种是不带垂直线的,更“专业”(需要软件包booktabs
)。在这两种情况下,我都使用makecell
软件包,它允许使用常见的格式和换行符作为列和行标题,以及cellspace
一些垂直填充。
\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{array, booktabs, multirow, makecell, cellspace} %
\setlength\cellspacetoplimit{3pt}
\setlength\cellspacebottomlimit{5pt}
\renewcommand\theadfont{\bfseries}
\usepackage{eqparbox}
\begin{document}
\begin{table}
\begin{tabular}{ |
>{\centering\arraybackslash} p{5cm}
| >{\centering\begin{eqminipage}[l]{COL}}p{2cm}<{\end{eqminipage}}
| >{\centering\arraybackslash}S{p{2cm}}
| >{\centering\arraybackslash}p{2cm}
| >{\centering\arraybackslash}p{2cm} |} \hline
\thead{Oil Concentration} & \thead{\makebox[0pt]{Colour}} & \thead{Oil} & \thead{Water} & \thead{Rock} \\
\hline
\multirowthead{3}[-1ex]{N-Decane + Oil Red O} & Red & 88 & 109 & 24 \\\cline{2-5}
& Green & 72 & 112 & 14 \\ \cline{2-5}
& Blue & 58 & 105 & 13 \\
\hline
\multirowthead{3}{N-Decane + Oil Red O & & & & \\ $ + {}$ Cyclo Hexane\\ Pentanoic Acid} & Red & 155 & 137 & 15 \\
\cline{2-5}
& Green & 114 & 164 & 11 \\ \cline{2-5}
& Blue & 110 & 125 & 1 \\
\hline
\multirowthead{3}{N-Decane + Oil Red O & & & & \\ $ + {}$ Cyclo Hexane\\ Butyric Acid} & Red & 180 & 179 & 24 \\
\cline{2-5}
& Green & 164 & 209 & 20 \\ \cline{2-5}
& Blue & 143 & 177 & 13 \\
\hline
\multirowthead{3}{N-Decane + Oil Red O & & & & \\ $ + {}$ Cyclo Hexane\\ Carboxylic Acid} & Red & 162 & 136 & 17 \\
\cline{2-5}
& Green & 121 & 119 & 7 \\
\cline{2-5}
& Blue & 95 & 107 & 0 \\
\hline
\end{tabular}
\end{table}
\begin{table}
\begin{tabular}{@{} %
>{\centering\arraybackslash} p{5cm}
>{\centering\begin{eqminipage}[l]{COL}}p{2cm}<{\end{eqminipage}}
>{\centering\arraybackslash}S{p{2cm}}
>{\centering\arraybackslash}p{2cm}
>{\centering\arraybackslash}p{2cm}@{}}
\toprule
\thead{Oil Concentration} & \thead{\makebox[0pt]{Colour}} & \thead{Oil} & \thead{Water} & \thead{Rock} \\
\cmidrule(lr){1-5}
\multirowthead{3}[-1ex]{N-Decane + Oil Red O} & Red & 88 & 109 & 24 \\
& Green & 72 & 112 & 14 \\
& Blue & 58 & 105 & 13 \\
\addlinespace
\multirowthead{3}{N-Decane + Oil Red O & & & & \\ $ + {}$ Cyclo Hexane\\ Pentanoic Acid} & Red & 155 & 137 & 15 \\
& Green & 114 & 164 & 11 \\
& Blue & 110 & 125 & 1 \\
\addlinespace
\multirowthead{3}{N-Decane + Oil Red O & & & & \\ $ + {}$ Cyclo Hexane\\ Butyric Acid} & Red & 180 & 179 & 24 \\
& Green & 164 & 209 & 20 \\
& Blue & 143 & 177 & 13 \\
\addlinespace
\multirowthead{3}{N-Decane + Oil Red O & & & & \\ $ + {}$ Cyclo Hexane\\ Carboxylic Acid} & Red & 162 & 136 & 17 \\
& Green & 121 & 119 & 7 \\
& Blue & 95 & 107 & 0 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
答案2
这里介绍一种可能的方法:
\documentclass[11pt]{article}
\usepackage{multirow}
\begin{document}
\begin{tabular}{|c|c|c|c|c|}
\hline
Oil Concentration & Colour & Oil & Water & Rock \\
\hline
\multirow{3}{*}{N-Decane + Oil Red O} & Red & 88 & 109 & 24 \\ \cline{2-5}
& Green & 72 & 112 & 14 \\ \cline{2-5}
& Blue & 58 & 105 & 13 \\ \cline{2-5}
\hline
\multirow{3}{*}{\parbox{4cm}{N-Decane + Oil Red O + Cyclo Hexane Pentanoic Acid}} & Red & 153 & 137 & 15 \\
\cline{2-5}
& Green & 114 & 164 & 11 \\ \cline{2-5}
& Blue & 110 & 125 & 1 \\ \cline{2-5}
\hline
\multirow{3}{*}{\parbox{4cm}{N-Decane + Oil Red O + Cyclo Hexane Pentanoic Acid}} & Red & 153 & 137 & 15 \\
\cline{2-5}
& Green & 114 & 164 & 11 \\ \cline{2-5}
& Blue & 110 & 125 & 1 \\ \cline{2-5}
\hline
\multirow{3}{*}{\parbox{4cm}{N-Decane + Oil Red O + Cyclo Hexane Pentanoic Acid}} & Red & 153 & 137 & 15 \\
\cline{2-5}
& Green & 114 & 164 & 11 \\ \cline{2-5}
& Blue & 110 & 125 & 1 \\ \cline{2-5}
\hline
\end{tabular}
\end{document}