![如何制作单元格中带有水平文本的横向表格?](https://linux22.com/image/294949/%E5%A6%82%E4%BD%95%E5%88%B6%E4%BD%9C%E5%8D%95%E5%85%83%E6%A0%BC%E4%B8%AD%E5%B8%A6%E6%9C%89%E6%B0%B4%E5%B9%B3%E6%96%87%E6%9C%AC%E7%9A%84%E6%A8%AA%E5%90%91%E8%A1%A8%E6%A0%BC%EF%BC%9F.png)
我需要在 LaTeX 中制作这样的表格:
我想到的只有这个:
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\begin{table}
\rotatebox{270}{
\begin{tabular}{|c|c|} \hline
First First & First Second\\ \hline
Second First & Second Second \\ \hline
\end{tabular}
}
\caption{Table 1}
\label{table1}
\end{table}
\end{document}
但仍然不知道如何旋转标题以及如何添加带有水平文本的单元格(“现有解决方案”单元格)。
编辑:
我“几乎”做到了这一点,但仍然需要“现有解决方案”单元。有什么想法吗?
以下是代码:
\begin{sidewaystable}[ht]
\centering
\begin{tabular}{|c|c|c|c|c|c|c|c|c|} \cline{2-9}
\multicolumn{1}{c|}{} & \multicolumn{8}{c|}{\textbf{Features}} \\ \cline{2-9}
\multicolumn{1}{c|}{} & \textbf{\shortstack{}} & \textbf{\shortstack{}} & \textbf{\shortstack{}} & \textbf{\shortstack{}} & \textbf{\shortstack{}} & \textbf{\shortstack{}} & \textbf{\shortstack{}} & \textbf{\shortstack{}} \\
\hline \shortstack{} & & & \shortstack{} & \shortstack{} & & & \shortstack{} & \\
\hline [25] & & & & & & & & \\
\hline [26] & & & & & & & & \\
\hline [27] & & & & & & & & \\
\hline [28] & & & & & & & & \\
\hline [29] & & & & & & & & \\
\hline [30] & & & & & & & & \\
\hline [31] & & & & & & & & \\
\hline [32] & & & & & & & & \\ \hline
\end{tabular}
\caption{My caption}
\end{sidewaystable}
现在看起来是这样的:
答案1
例如:
\documentclass{article}
\usepackage{pdflscape, array, rotating, multirow}
\begin{document}
\begin{landscape}
\begin{table}
\begin{tabular}{|c|c|c|} \hline
& First First & First Second\\ \cline{2-3}
& First First & First Second\\ \cline{2-3}
& First First & First Second\\ \cline{2-3}
& First First & First Second\\ \cline{2-3}
& First First & First Second\\ \cline{2-3}
& First First & First Second\\ \cline{2-3}
& First First & First Second\\ \cline{2-3}
& First First & First Second\\ \cline{2-3}
& First First & First Second\\ \cline{2-3}
& First First & First Second\\ \cline{2-3}
& First First & First Second\\ \cline{2-3}
\hfill\turnbox{90}{Existing Solutions}\hfill & First First & First Second\\ \cline{2-3}
& First First & First Second\\ \cline{2-3}
& First First & First Second\\ \cline{2-3}
& First First & First Second\\ \cline{2-3}
\phantom{X} & First First & First Second\\ \cline{2-3}
& Second First & Second Second \\ \hline
\end{tabular}
\caption{Table 1}
\label{table1}
\end{table}
\end{landscape}
\end{document}
array
我认为没有必要,但这始终是一个好主意。
如果您想知道为什么不应该这样格式化表格,请参阅文档booktabs
。(可以说这是一种略显极端的立场,但在 99% 的情况下非常有用。)
答案2
\multirow
以下是通过和说明添加字符串“现有解决方案”的解决方案\rotatebox
。说明\multirow
由多行包,而\rotatebox
由图形包。(此包由包自动加载rotating
,因此无需graphicx
单独加载。)
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{rotating,multirow}
\newcommand\mc[1]{\multicolumn{1}{c}{#1}} % a handy shortcut macro
\begin{document}
\begin{sidewaystable}
\centering
\begin{tabular}{|l|*{9}{c|}}
\cline{3-10}
\mc{} & & \multicolumn{8}{c|}{\textbf{Features}} \\
\cline{3-10}
\mc{} & & & & & & & & & \\ \hline
\multirow{9}{*}{\rotatebox{90}{\textbf{Existing solutions}}}
& & & & & & & & & \\ \cline{2-10}
& [25] & & & & & & & & \\ \cline{2-10}
& [26] & & & & & & & & \\ \cline{2-10}
& [27] & & & & & & & & \\ \cline{2-10}
& [28] & & & & & & & & \\ \cline{2-10}
& [29] & & & & & & & & \\ \cline{2-10}
& [30] & & & & & & & & \\ \cline{2-10}
& [31] & & & & & & & & \\ \cline{2-10}
& [32] & & & & & & & & \\ \hline
\end{tabular}
\caption{My caption}
\end{sidewaystable}
\end{document}