![如何根据另一个相邻的表动态设置表的行高?](https://linux22.com/image/275079/%E5%A6%82%E4%BD%95%E6%A0%B9%E6%8D%AE%E5%8F%A6%E4%B8%80%E4%B8%AA%E7%9B%B8%E9%82%BB%E7%9A%84%E8%A1%A8%E5%8A%A8%E6%80%81%E8%AE%BE%E7%BD%AE%E8%A1%A8%E7%9A%84%E8%A1%8C%E9%AB%98%EF%BC%9F.png)
我有 2 个并排的表格。表 1 是动态的,而表 2 是静态的(固定内容)。我需要调整表 2 的行高,该行高必须等于表 1 的总高度(如多行),但我不想使用多行。
\documentclass{article}
\usepackage{subcaption}
\begin{document}
\begin{minipage}{0.8\linewidth}
\begin{tabular}{ | p{5cm} | p{1cm} | p{2.5cm} | }
\hline
A clear day with lots of sunshine.However, the strong breeze will bring down the temperatures & 2 & 3 \\[2cm]
\hline
A clear day with lots of sunshine. However, the strong breeze will bring down the temperatures & 5 & 6 \\[2cm]
\hline
A clear day with lots of sunshine. However, the strong breeze will bring down the temperatures & 8 & 9 \\[1cm]
\hline
\end{tabular}
\end{minipage}
\begin{minipage}{0.2\linewidth}
\begin{tabular}{ |p{5cm}| }
\hline
For columns that will contain text whose length exceeds the column's width, it is recommended that you use the p attribute and specify the desired width of the column (although it may take some trial-and-error to get the result you want). \\[5cm]
\hline
\end{tabular}
\end{minipage}
\end{document}
我该如何实现这个?
答案1
为了避免这种情况,您可以简单地在另一个中\multirow
使用一个。tabular
tabular
我还缩短了列宽以避免overfull \hbox
。
\documentclass{article}
\usepackage{array}
\renewcommand{\arraystretch}{1.2}
\usepackage{subcaption}
\begin{document}
\begin{table}\centering
\begin{tabular}{|@{}c@{}|m{4cm}|}
\hline
\begin{tabular}{p{4cm} | p{1cm} | p{1.3cm}}
A clear day with lots of sunshine. However, the strong breeze will bring down the temperatures & 2 & 3 \\
\hline
A clear day with lots of sunshine. However, the strong breeze will bring down the temperatures & 5 & 6 \\
\hline
A clear day with lots of sunshine. However, the strong breeze will bring down the temperatures & 8 & 9 \\
\end{tabular}
&
For columns that will contain text whose length exceeds the column's width, it is recommended that you use the p attribute and specify the desired width of the column (although it may take some trial-and-error to get the result you want). \\
\hline
\end{tabular}
\end{table}
\end{document}