我正在用 LaTeX 制作一个相对简单的表格,但是遇到了一个问题。我正在尝试制作下表:
但是,我得到了以下信息:
我的 MWE 如下:
\documentclass{article}
\usepackage{graphicx,multirow}
\setbox0\hbox{\tabular{@{}l}Hydrocarbons\endtabular}
\begin{document}
\begin{tabular}{|c|c|c|c|}
\hline
\multicolumn{2}{|c|}{System} & K-Model & H-Model \\
\hline
\multirow{4}{*}{\rotatebox{90}{\rlap{\usebox0}}} \\
& Ordinary & SRK &SRK \\ \cline{2-4}
& Cryogenics & PR & PR \\ \cline{2-4}
& Crude & CS, GS & LK \\ \cline{2-4}
& Vacuum Crude & ESSO & LK\\ \hline
\hline
\multicolumn{2}{|c|}{Power combustion} & SRK &SRK \\ \hline
\multicolumn{2}{|c|}{Acid, Bases, Electrolytes} & Electrolytes Models &SRK,
HTSL\\ \hline
\multicolumn{2}{|c|}{Chemicals} & Activity Coeff. & Latent Heat\\ \hline
\end{tabular}
\end{document}
答案1
我改变了一些事情:
我把 改成了
\box0
。\newbox\dontdoitbox
如果直接使用盒子寄存器,你可能会覆盖不该覆盖的内容。我改用了一个自动寄存器(但在这里使用盒子仍然没有意义……)。我
\rlap
从 中删除了\usebox
。\rlap
使框从单元格的中心开始,而不是底部。我把
array
包裹放进去,并增加了\setlength{\extrarowheight}{6pt}
桌子单元格的高度,以使所有东西都适合。
结果如下:
代码:
\documentclass{article}
\usepackage{graphicx,multirow}
\usepackage{array}
\setbox0\hbox{\tabular{@{}l}Hydrocarbons\endtabular}
\begin{document}
\pagenumbering{gobble}
\setlength{\extrarowheight}{6pt}
\begin{tabular}{|c|c|c|c|}
\hline
\multicolumn{2}{|c|}{System} & K-Model & H-Model \\
\hline
\multirow{4}{*}{\rotatebox{90}{\usebox0}}
& Ordinary & SRK &SRK \\ \cline{2-4}
& Cryogenics & PR & PR \\ \cline{2-4}
& Crude & CS, GS & LK \\ \cline{2-4}
& Vacuum Crude & ESSO & LK\\ \hline
\hline
\multicolumn{2}{|c|}{Power combustion} & SRK &SRK \\ \hline
\multicolumn{2}{|c|}{Acid, Bases, Electrolytes} & Electrolytes Models &SRK,
HTSL\\ \hline
\multicolumn{2}{|c|}{Chemicals} & Activity Coeff. & Latent Heat\\ \hline
\end{tabular}
\end{document}
答案2
使用包的替代方案makecell
:rotating
\documentclass{article}
\usepackage{makecell,multirow}
\usepackage{rotating}
\begin{document}
\begin{center}
\setcellgapes{5pt}
\makegapedcells
\settowidth\rotheadsize{Hydrocarbons}
\begin{tabular}{|c|c|c|c|}
\hline
\multicolumn{2}{|c|}{System}
& K-Model & H-Model \\\hline
& Ordinary & SRK & SRK \\ \cline{2-4}
& Cryogenics & PR & PR \\ \cline{2-4}
& Crude & CS, GS & LK \\ \cline{2-4}
\multirow[t]{-4}{*}{\rothead{Hydrocarbons}}
& Vacuum Crude & ESSO & LK \\ \hline
\hline
\multicolumn{2}{|c|}{Power combustion}
& SRK & SRK \\ \hline
\multicolumn{2}{|c|}{Acid, Bases, Electrolytes}
& Electrolytes Models
& SRK, HTSL \\ \hline
\multicolumn{2}{|c|}{Chemicals}
& Activity Coeff.
& Latent Heat \\ \hline
\end{tabular}
\end{center}
\end{document}