在 Latex 中具有多行和多列的长表
Longtable with multirows and multicolumns in Latex
我有这个 table,我想在 Latex 上创建它。我已经尝试了很多 table 包,但在我使用的每个包中,我总是遇到文本超出页面宽度或似乎无法在同一列上创建多行等问题。
任何建议都会有所帮助。
\begin{longtabu} to \textwidth {|X|X|X|X|}
\caption{Data Dictionary}\label{tab:summary}\
\hline
\textbf{Tables} & \textbf{Columns} & \textbf{Designation} & \textbf{Type} \
\hline
\endfirsthead
\multicolumn{4}{c}%
{\tablename\ \thetable\ -- \textit{Continued from previous page}} \
\hline
\textbf{Tables} & \textbf{Columns} & \textbf{Designation} & \textbf{Type} \
\hline
\endhead
\hline \multicolumn{4}{r}{\textit{Continued on next page}} \
\endfoot
\hline
\endlastfoot
\textbf{Building} \newline &
RI Building Ref
(Primary Key)\newline
Building Name\newline
Development Name\newline
Address\newline
Submarket\newline
Latitude\newline
Longitude &
The building reference in Realinflo database\newline
The building name\newline
The development name to which the building belongs, if any.\newline
The building street address\newline
The submarket the building is located at.\newline
The building latitude\newline
The building longitude &
text\newline
text\newline
text\newline
text\newline
text\newline
float\newline
float\hline
\end{longtabu}
你可以试试这个方法,你使用 multirow
包中的 multirow
和 graphicx
包中的 rotatebox
的组合。在这里,multirow
是这样使用的:\multirow{<number of rows to span>}{<width>}[<vmove>]{<content>}
。如您所见,对于 Building 子表,您使第一列中的第一个单元格跨越 7 行,为内容的自然宽度传递 *,设置 [<vmove>]
= [-5ex]
以允许文本移动更垂直向下,因为它跨越行而不是相邻单元格中的行数。负值降低文本,而正值升高文本。最后,您将内容作为最后一个参数传递。您将 rotatebox
的内容旋转为 \rotate[origin=c]{90}{text}
,其中它会将文本相对于初始轴逆时针方向旋转 90 度。您在 longtable
环境中使用 p{<width>}
以允许文本换行,其中 width
是列的宽度。您使用 cline{i-j}
,其中 i 是第一列,j 是水平线跨越的最后一列,在本例中为 cline{2-4}
。这样,我想您可以尝试剩余的行。请注意,在第一行之后,后续行中的第一个元素留空以允许文本单独跨越多行,因此您将在这些行中的 &
之前看不到任何文本。
\documentclass{article}
\usepackage{longtable}
\usepackage{multirow, graphicx}
\begin{document}
\begin{longtable}{|p{0.5in}|p{1.2in}|p{1.7in}|c|}
\caption{Data Dictionary}\label{tab:summary}\
\hline
\centering \textbf{Tables}&
\centering \textbf{Columns}&
\centering \textbf{Designation}&
\textbf{Type}\
\hline
\endfirsthead
\multicolumn{4}{c}%
{\tablename\ \thetable\ -- \textit{Continued from previous page}} \
\hline
\textbf{Tables} & \textbf{Columns} & \textbf{Designation} & \textbf{Type} \
\hline
\endhead
\hline \multicolumn{4}{r}{\textit{Continued on next page}} \
\endfoot
\hline
\endlastfoot
\multirow{7}{*}[-5ex]{\rotatebox[origin=c]{90}{\textbf{Building}}} &
\centering RI Building Ref
(Primary Key)&
\raggedright The building reference in database&
text\
\cline{2-4}
&\centering Building Name&
The building name&
text\
\cline{2-4}
&\centering Development Name&
The development name to which the building belongs, if any.&
text\
\cline{2-4}
&\centering Address&
The building street address&
text\
\cline{2-4}
&\centering Submarket&
The submarket the building is located at.&
text\
\cline{2-4}
& \centering Latitude&
The building latitude&
float\
\cline{2-4}
&\centering Longitude &
The building longitude&
float\
\hline
\end{longtable}
\end{document}
我有这个 table,我想在 Latex 上创建它。我已经尝试了很多 table 包,但在我使用的每个包中,我总是遇到文本超出页面宽度或似乎无法在同一列上创建多行等问题。
任何建议都会有所帮助。
\begin{longtabu} to \textwidth {|X|X|X|X|}
\caption{Data Dictionary}\label{tab:summary}\
\hline
\textbf{Tables} & \textbf{Columns} & \textbf{Designation} & \textbf{Type} \
\hline
\endfirsthead
\multicolumn{4}{c}%
{\tablename\ \thetable\ -- \textit{Continued from previous page}} \
\hline
\textbf{Tables} & \textbf{Columns} & \textbf{Designation} & \textbf{Type} \
\hline
\endhead
\hline \multicolumn{4}{r}{\textit{Continued on next page}} \
\endfoot
\hline
\endlastfoot
\textbf{Building} \newline &
RI Building Ref
(Primary Key)\newline
Building Name\newline
Development Name\newline
Address\newline
Submarket\newline
Latitude\newline
Longitude &
The building reference in Realinflo database\newline
The building name\newline
The development name to which the building belongs, if any.\newline
The building street address\newline
The submarket the building is located at.\newline
The building latitude\newline
The building longitude &
text\newline
text\newline
text\newline
text\newline
text\newline
float\newline
float\hline
\end{longtabu}
你可以试试这个方法,你使用 multirow
包中的 multirow
和 graphicx
包中的 rotatebox
的组合。在这里,multirow
是这样使用的:\multirow{<number of rows to span>}{<width>}[<vmove>]{<content>}
。如您所见,对于 Building 子表,您使第一列中的第一个单元格跨越 7 行,为内容的自然宽度传递 *,设置 [<vmove>]
= [-5ex]
以允许文本移动更垂直向下,因为它跨越行而不是相邻单元格中的行数。负值降低文本,而正值升高文本。最后,您将内容作为最后一个参数传递。您将 rotatebox
的内容旋转为 \rotate[origin=c]{90}{text}
,其中它会将文本相对于初始轴逆时针方向旋转 90 度。您在 longtable
环境中使用 p{<width>}
以允许文本换行,其中 width
是列的宽度。您使用 cline{i-j}
,其中 i 是第一列,j 是水平线跨越的最后一列,在本例中为 cline{2-4}
。这样,我想您可以尝试剩余的行。请注意,在第一行之后,后续行中的第一个元素留空以允许文本单独跨越多行,因此您将在这些行中的 &
之前看不到任何文本。
\documentclass{article}
\usepackage{longtable}
\usepackage{multirow, graphicx}
\begin{document}
\begin{longtable}{|p{0.5in}|p{1.2in}|p{1.7in}|c|}
\caption{Data Dictionary}\label{tab:summary}\
\hline
\centering \textbf{Tables}&
\centering \textbf{Columns}&
\centering \textbf{Designation}&
\textbf{Type}\
\hline
\endfirsthead
\multicolumn{4}{c}%
{\tablename\ \thetable\ -- \textit{Continued from previous page}} \
\hline
\textbf{Tables} & \textbf{Columns} & \textbf{Designation} & \textbf{Type} \
\hline
\endhead
\hline \multicolumn{4}{r}{\textit{Continued on next page}} \
\endfoot
\hline
\endlastfoot
\multirow{7}{*}[-5ex]{\rotatebox[origin=c]{90}{\textbf{Building}}} &
\centering RI Building Ref
(Primary Key)&
\raggedright The building reference in database&
text\
\cline{2-4}
&\centering Building Name&
The building name&
text\
\cline{2-4}
&\centering Development Name&
The development name to which the building belongs, if any.&
text\
\cline{2-4}
&\centering Address&
The building street address&
text\
\cline{2-4}
&\centering Submarket&
The submarket the building is located at.&
text\
\cline{2-4}
& \centering Latitude&
The building latitude&
float\
\cline{2-4}
&\centering Longitude &
The building longitude&
float\
\hline
\end{longtable}
\end{document}