![如何在垂直旋转的合并单元格中换行?](https://linux22.com/image/472363/%E5%A6%82%E4%BD%95%E5%9C%A8%E5%9E%82%E7%9B%B4%E6%97%8B%E8%BD%AC%E7%9A%84%E5%90%88%E5%B9%B6%E5%8D%95%E5%85%83%E6%A0%BC%E4%B8%AD%E6%8D%A2%E8%A1%8C%EF%BC%9F.png)
我有一张表格,代码如下:
\begin{table}[]
\begin{tabular}{cc|cccccc|}
\cline{3-8}
\multicolumn{1}{l}{}
& & \multicolumn{6}{c|}{\textbf{Time-period (t)}}
\\ \cline{3-8}
\multicolumn{1}{l}{}
& \textbf{} & \multicolumn{1}{c|}{\textbf{0}} &
\multicolumn{1}{c|}{\textbf{1}} & \multicolumn{1}{c|}
{\textbf{2}} & \multicolumn{1}{c|}{\textbf{3}}
& \multicolumn{1}{c|}{\textbf{4}} & \textbf{5}
\\ \hline
\multicolumn{1}{|c|}{}
& \textbf{1} & \multicolumn{1}{c|}{{\color[HTML]{32CB00} 3}} &
\multicolumn{1}{c|}{{\color[HTML]{000000} 3}} & \multicolumn{1}{c|}
{{\color[HTML]{000000} 3}} & \multicolumn{1}{c|}{{\color[HTML]
{000000} 3}} & \multicolumn{1}{c|}{{\color[HTML]{FF0000} -3}+
{\color[HTML]{32CB00}3}+3} & {\color[HTML]{000000} 3} \\ \cline{2-
8}
\multicolumn{1}{|c|}{}
& \textbf{2} & \multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{{\color[HTML]{32CB00} 3}} & \multicolumn{1}{c|}
{3} & \multicolumn{1}{c|}{3}
& \multicolumn{1}{c|}{3} & 3
\\ \cline{2-8}
\multicolumn{1}{|c|}{}
& \textbf{3} & \multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} & \multicolumn{1}{c|}
{{\color[HTML]{32CB00} 3}} & \multicolumn{1}{c|}{3}
& \multicolumn{1}{c|}{3} & 3
\\ \cline{2-8}
\multicolumn{1}{|c|}{\multirow{-4}{*}{{\rotatebox[origin=c]{90}
{\textbf{Sensor node $i \in V$}}}}} & \textbf{4} & \multicolumn{1}
{c|}{} & \multicolumn{1}{c|}{}
& \multicolumn{1}{c|}{} & \multicolumn{1}
{c|}{{\color[HTML]{32CB00} 3}} & \multicolumn{1}{c|}{3}
& 3 \\ \hline
\end{tabular}
\end{table}
第一列中的文本超出了表格范围。我该如何修复此问题?
答案1
以下附加代码确实满足了换行多行旋转文本的要求
\begin{turn}{90}
{
\tabular{@{}c@{}}
\textbf{Sensor} \\\textbf{node} \\\textbf{$i \in V$}
\endtabular
}
\end{turn}
平均能量损失
\documentclass{article}
\usepackage{array}
\usepackage{multirow}
\usepackage{rotating,booktabs,xcolor}
\begin{document}
\begin{table}[]
\begin{tabular}{cc|cccccc|}
\cline{3-8}
\multicolumn{1}{l}{}
& & \multicolumn{6}{c|}{\textbf{Time-period (t)}}
\\ \cline{3-8}
\multicolumn{1}{l}{}
& \textbf{} & \multicolumn{1}{c|}{\textbf{0}} &
\multicolumn{1}{c|}{\textbf{1}} & \multicolumn{1}{c|}
{\textbf{2}} & \multicolumn{1}{c|}{\textbf{3}}
& \multicolumn{1}{c|}{\textbf{4}} & \textbf{5}
\\ \hline
\multicolumn{1}{|c|}{}
& \textbf{1} & \multicolumn{1}{c|}{{\color[HTML]{32CB00} 3}} &
\multicolumn{1}{c|}{{\color[HTML]{000000} 3}} & \multicolumn{1}{c|}
{{\color[HTML]{000000} 3}} & \multicolumn{1}{c|}{{\color[HTML]
{000000} 3}} & \multicolumn{1}{c|}{{\color[HTML]{FF0000} -3}+
{\color[HTML]{32CB00}3}+3} & {\color[HTML]{000000} 3} \\ \cline{2-
8}
\multicolumn{1}{|c|}{}
& \textbf{2} & \multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{{\color[HTML]{32CB00} 3}} & \multicolumn{1}{c|}
{3} & \multicolumn{1}{c|}{3}
& \multicolumn{1}{c|}{3} & 3
\\ \cline{2-8}
\multicolumn{1}{|c|}{}
& \textbf{3} & \multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} & \multicolumn{1}{c|}
{{\color[HTML]{32CB00} 3}} & \multicolumn{1}{c|}{3}
& \multicolumn{1}{c|}{3} & 3
\\ \cline{2-8}
\multicolumn{1}{|c|}
{
\multirow{-4}{*}
{
\begin{turn}{90}
{
\tabular{@{}c@{}}
\textbf{Sensor} \\\textbf{node} \\ \textbf{$i \in V$}
\endtabular
}
\end{turn}
}
}
& \textbf{4} & \multicolumn{1}
{c|}{} & \multicolumn{1}{c|}{}
& \multicolumn{1}{c|}{} & \multicolumn{1}
{c|}{{\color[HTML]{32CB00} 3}} & \multicolumn{1}{c|}{3}
& 3 \\ \hline
\end{tabular}
\end{table}
\end{document}