如何在Latex的列之间绘制垂直线?

问题描述 投票:0回答:1

如何在第3列和第4列之间以及第2列和第3列之间绘制垂直线?我使用了long table和\ multirow,并且将文本包装成table内部,但是我不知道如何在列之间绘制线条?代码的错误结果在这里:https://ibb.co/cQfVs1w

    \begin{longtable}[H] {|p{2cm}|p{2.8cm}|p{2.8cm}|p{2.8cm}|}
% table caption is above the table
\caption{xxx}
\label{tab:2}       % Give a unique label
% For LaTeX tables use
%\begin{tabular}{|p{2cm}|p{2.8cm}|p{2.8cm}|p{2.8cm}|}
\\
\hline\noalign{\smallskip}
Reference & Description & Advantages & Limitations  \\
\noalign{\smallskip}\hline\noalign{\smallskip}

xx & xx & {\multirow{3}{*}{\parbox{2.8cm} {1.xxx\\
            2.  xxxx\\
            3.  xxx \\
            4.  xxx \\
            5.  xxx\\
            6.  xxxx\\ 
            7.  xxxx\\
}}}
& {\multirow{3}{*}{\parbox{2.8cm}{ 1.   xxx\\
            2.  xxx\\
            3.  xxx\\
            4.  xxx\\
}}}\\
xx [18] & xxx  &  & \\
xx [6] & xxx  &  & \\
\\
\\
\\
\\
\noalign{\smallskip}\hline
%\end{tabular}
    \end{longtable}
latex multirow longtable
1个回答
1
投票

您的表毫无用处。您可以以更简单易读的方式描述这种表,并且不需要多行。在非常特殊的情况下使用多行很有用,例如,您的图片或行描述必须跨越几行。

这里是一个可能的解决方案。

\documentclass{article}

\usepackage{longtable}
%\usepackage{multirow}
\usepackage{booktabs}

\begin{document}
\begin{longtable}[H] {|p{2cm}|p{2.8cm}|p{2.8cm}|p{2.8cm}|}
% table caption is above the table
\caption{xxx}
\label{tab:2}       % Give a unique label
% For LaTeX tables use
%\begin{tabular}{|p{2cm}|p{2.8cm}|p{2.8cm}|p{2.8cm}|}
\\\hline            %%%% \noalign{\smallskip}
Reference & Description & Advantages & Limitations  \\
%%%%%%%% \noalign{\smallskip}\hline\noalign{\smallskip}
\hline
xx      & xx   & 1.  xxx     & 1. xxx\\
xx[18]  & xxx  & 2.  xxxx    & 2. xxx\\
xx [6]  & xxx  & 3.  xxx     & 3. xxx\\
        &      & 4.  xxx     & 4. xxx\\
        &      & 5.  xxx     &       \\
        &      & 6.  xxxx    &       \\ 
        &      & 7.  xxxx    &       \\
\hline
%\end{tabular}
\end{longtable}
\end{document}

enter image description here我禁止使用\ noalign在垂直行和水平规则之间创建间隙。也许它们是为了解决LaTeX中规则和文本之间不正确的间距,但我建议您改用booktabs包。它固定了这个间距,并提供了创建表格的方法,这些表格没有更好的可读性的垂直列。

\begin{longtable}[H] {p{2cm}p{2.8cm}p{2.8cm}p{2.8cm}}
% table caption is above the table
\caption{xxx}
\label{tab:2}       % Give a unique label
\\\toprule
Reference & Description & Advantages & Limitations  \\
\midrule
xx      & xx   & 1.xxx       & 1. xxx\\
xx[18]  & xxx  & 2.  xxxx    & 2. xxx\\
xx [6]  & xxx  & 3.  xxx     & 3. xxx\\
        &      & 4.  xxx     & 4. xxx\\
        &      & 5.  xxx     &       \\
        &      & 6.  xxxx    &       \\ 
        &      & 7.  xxxx    &       \\
\bottomrule
\end{longtable}

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.