长表项目之间的垂直间距

长表项目之间的垂直间距

几年来,我一直以长表的形式保存我的简历。我最近买了一台新电脑(Win 10),因此换了新版本的 MikTex,我发现简历不再能正确编译。特别是,以前在长表中的条目末尾,您可以放置\\[6pt]​​一些空间以在下一个条目之前留出一些空间。现在这只在条目长度少于一行时才有效。

有人能提出解决方案吗?谢谢!

梅威瑟:

\documentclass[letterpaper,12pt]{article}
\usepackage{array, xcolor}

\usepackage{longtable}

\definecolor{lightgray}{gray}{0.8}
\newcolumntype{L}{>{\raggedleft}p{0.18\textwidth}}
\newcolumntype{R}{p{.78\textwidth}}
\newcommand\VRule{\color{lightgray}\vrule width 0.5pt}

\begin{document}
    
     
    \section*{A List Where It Works}
    \begin{longtable}{L!{\VRule}R}
        2021&If it stays on one line, the spacing works!\\[6pt]
        2020&If it stays on one line, the spacing works!\\[6pt]
        2018&If it stays on one line, the spacing works!\\[6pt]
    \end{longtable}
    
    \vspace{10pt}
    
        \section*{A List Where It Doesn't}
    \begin{longtable}{L!{\VRule}R}
        2021&If it runs over to more than one line, all of a sudden the spacing no longer works.\\[6pt]
        2020&If it runs over to more than one line, all of a sudden the spacing no longer works.\\[6pt]
        2018&If it runs over to more than one line, all of a sudden the spacing no longer works.\\[6pt]
    \end{longtable}

        \section*{Looks Bad When Mixed!}
\begin{longtable}{L!{\VRule}R}
    2021&If it runs over to more than one line, all of a sudden the spacing no longer works.\\[6pt]
    2020&If it stays on one line, it works.\\[6pt]
    2018&If it runs over to more than one line, all of a sudden the spacing no longer works.\\[6pt]
\end{longtable}
    
\end{document}

答案1

我提出了一个基于的解决方案bigstrut:您可以\bigstrut[b]在最后一列的每个单元格末尾自动添加(我在下面的代码中执行了此操作),或者为您感兴趣的行手动添加空格。

\documentclass[letterpaper, 12pt]{article}
\usepackage{array, xcolor}
\usepackage{longtable}

\definecolor{lightgray}{gray}{0.8}
\newcolumntype{L}{>{\raggedleft}p{0.18\textwidth}}
\newcolumntype{R}{p{.78\textwidth}}
\newcommand\VRule{\color{lightgray}\vrule width 0.5pt}
\usepackage{bigstrut}

\begin{document}

    \section*{A List Where It Works}
    \begin{longtable}{L!{\VRule}R}
        2021&If it stays on one line, the spacing works!\\[6pt]
        2020&If it stays on one line, the spacing works!\\[6pt]
        2018&If it stays on one line, the spacing works!\\[6pt]
    \end{longtable}

    \vspace{10pt}

        \section*{Another List Where It Works}
\setlength{\bigstrutjot}{6pt}
    \begin{longtable}{L!{\VRule}R<{\bigstrut[b]}}
        2021&If it runs over to more than one line, all of a sudden the spacing no longer works.\bigstrut[b]\\
        2020&If it runs over to more than one line, all of a sudden the spacing no longer works.\\
        2018&If it runs over to more than one line, all of a sudden the spacing no longer works.\\
    \end{longtable}

        \section*{Doesn’t Look So Bad When Mixed!}
\begin{longtable}{L!{\VRule}R<{\bigstrut[b]}}
    2021&If it runs over to more than one line, all of a sudden the spacing no longer works.\\
    2020&If it stays on one line, it works.\\
    2018&If it runs over to more than one line, all of a sudden the spacing no longer works.\\
\end{longtable}

\end{document} 

在此处输入图片描述

答案2

那么基于不同值的方法怎么样\arraystretch?(我还通过修改其中一个自定义列来确保摆脱过满的 hbox 警告。)

\documentclass[letterpaper,12pt]{article}
\usepackage{array, xcolor}
\usepackage{longtable}

\definecolor{lightgray}{gray}{0.8}
\newcolumntype{L}{>{\raggedleft\arraybackslash}p{\dimexpr 0.18\textwidth-2\tabcolsep}}
\newcolumntype{R}{p{.78\textwidth}}
\newcommand\VRule{\color{lightgray}\vrule width 0.5pt}

\begin{document}
\renewcommand*{\arraystretch}{1.4}
     
    \section*{A List Where It Works}
    \begin{longtable}{L!{\VRule}R}
        2021&If it stays on one line, the spacing works!\\
        2020&If it stays on one line, the spacing works!\\
        2018&If it stays on one line, the spacing works!\\
    \end{longtable}
    
    \vspace{10pt}
    
        \section*{A List Where It Doesn't}
    \begin{longtable}{L!{\VRule}R}
        2021&If it runs over to more than one line, all of a sudden the spacing no longer works.\\
        2020&If it runs over to more than one line, all of a sudden the spacing no longer works.\\
        2018&If it runs over to more than one line, all of a sudden the spacing no longer works.\\
    \end{longtable}

        \section*{Looks Bad When Mixed!}
\begin{longtable}{L!{\VRule}R}
    2021&If it runs over to more than one line, all of a sudden the spacing no longer works.\\
    2020&If it stays on one line, it works.\\
    2018&If it runs over to more than one line, all of a sudden the spacing no longer works.\\
\end{longtable}
    
\end{document}

相关内容