我正在尝试创建具有格式的三列表 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}
如果代码太长,我深表歉意。看来问题是因为未针对最高单元格调整整个行单元格的高度。它是根据第一列固定的。我试图尝试几种方法,但没有任何效果。有什么建议吗?
答案 0 :(得分:1)
您似乎正在尝试将这些复杂的结构与\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}