在 table 中使用多个多行命令时出现问题
Problem when using multiple multirow commands in a table
我正在尝试创建一个具有格式的三列 table
like this.
自然地,描述比名称栏长。此外,出于美观原因,我想对示例列使用 \multicolumn 命令。这是代码,
\begin{document}
\begin{table}
\begin{tabular}{|c|p {5 cm}|p {5 cm}|}
\hline
\multirow{2}{*}{Complex Type} & \multirow{2}{5 cm}{\parbox[c]{5 cm}{This variable type is used to declare a complex number, the real part and also the imaginary part.}} & \multicolumn{1}{l|}{Defining a complex number 3.0 + 5.0 i :} \
& & \multicolumn{1}{l|}{complex :: a = (3.0, 5.0)} \
\hline
\multirow{4}{*}{Character Type} & \multirow{4}{4 cm}{This variable type is used to store one character by default. It can be used to store string or multiple characters using the len modifier. The len modifier works exactly the same as kind modifier. The example is on how to declare two variables, var1 for a character and var 2 for a sentence holder.} & character :: var1 \
& & character (len = 40) :: var2 \
& & var1 = "A" \
& & var2 = "How do you turn this on?" \
\hline
\end{tabular}
\end{tabular}
如果代码太长,我深表歉意。看来问题是因为整个行单元格的高度没有针对最高单元格进行调整。它是基于第一列固定的。我尝试了几种方法,但没有任何效果。有什么建议吗?
看起来您正在尝试将这些复杂的结构与 \multicolumn
和 \multirow
一起使用,只是为了更改对齐方式和添加换行符,这可以更容易地完成:
\documentclass{article}
\usepackage{geometry}
\usepackage{multirow}
\usepackage{array}
\begin{document}
\begin{table}
\begin{tabular}{|c|m{5cm}|>{\raggedright\arraybackslash}m{6.2cm}|}
\hline
Complex Type &
This variable type is used to declare a complex number, the real part and also the imaginary part. &
Defining a complex number 3.0 + 5.0 i : \linebreak
complex :: a = (3.0, 5.0) \
\hline
Character Type &
This variable type is used to store one character by default. It can be used to store string or multiple characters using the len modifier. The len modifier works exactly the same as kind modifier. The example is on how to declare two variables, var1 for a character and var 2 for a sentence holder. &
character :: var1 \linebreak
character (len = 40) :: var2 \linebreak
var1 = "A" \linebreak
var2 = "How do you turn this on?" \
\hline
\end{tabular}
\end{table}
\end{document}
我正在尝试创建一个具有格式的三列 table like this. 自然地,描述比名称栏长。此外,出于美观原因,我想对示例列使用 \multicolumn 命令。这是代码,
\begin{document}
\begin{table}
\begin{tabular}{|c|p {5 cm}|p {5 cm}|}
\hline
\multirow{2}{*}{Complex Type} & \multirow{2}{5 cm}{\parbox[c]{5 cm}{This variable type is used to declare a complex number, the real part and also the imaginary part.}} & \multicolumn{1}{l|}{Defining a complex number 3.0 + 5.0 i :} \
& & \multicolumn{1}{l|}{complex :: a = (3.0, 5.0)} \
\hline
\multirow{4}{*}{Character Type} & \multirow{4}{4 cm}{This variable type is used to store one character by default. It can be used to store string or multiple characters using the len modifier. The len modifier works exactly the same as kind modifier. The example is on how to declare two variables, var1 for a character and var 2 for a sentence holder.} & character :: var1 \
& & character (len = 40) :: var2 \
& & var1 = "A" \
& & var2 = "How do you turn this on?" \
\hline
\end{tabular}
\end{tabular}
如果代码太长,我深表歉意。看来问题是因为整个行单元格的高度没有针对最高单元格进行调整。它是基于第一列固定的。我尝试了几种方法,但没有任何效果。有什么建议吗?
看起来您正在尝试将这些复杂的结构与 \multicolumn
和 \multirow
一起使用,只是为了更改对齐方式和添加换行符,这可以更容易地完成:
\documentclass{article}
\usepackage{geometry}
\usepackage{multirow}
\usepackage{array}
\begin{document}
\begin{table}
\begin{tabular}{|c|m{5cm}|>{\raggedright\arraybackslash}m{6.2cm}|}
\hline
Complex Type &
This variable type is used to declare a complex number, the real part and also the imaginary part. &
Defining a complex number 3.0 + 5.0 i : \linebreak
complex :: a = (3.0, 5.0) \
\hline
Character Type &
This variable type is used to store one character by default. It can be used to store string or multiple characters using the len modifier. The len modifier works exactly the same as kind modifier. The example is on how to declare two variables, var1 for a character and var 2 for a sentence holder. &
character :: var1 \linebreak
character (len = 40) :: var2 \linebreak
var1 = "A" \linebreak
var2 = "How do you turn this on?" \
\hline
\end{tabular}
\end{table}
\end{document}