【问题标题】:Longtable with multirows and multicolumns in LatexLatex中具有多行和多列的长表
【发布时间】:2021-07-08 00:41:50
【问题描述】:

我有这张桌子,我想在 Latex 上创建它。我已经尝试了很多表格包,但是对于我使用的每个包,我总是遇到文本超出页面宽度或似乎无法在同一列上创建多行等问题。

任何建议都会有所帮助。

\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} 

【问题讨论】:

    标签: latex overleaf


    【解决方案1】:

    你可以试试这个方法,你使用来自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}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多