5

I have a table in which I am including lists in each cell of a column and I am insistent on using vertical lines. At present, I have the following MWE:

\documentclass[11pt]{article}

\usepackage[margin=20mm]{geometry}
% \usepackage{booktabs}
\usepackage{enumitem}
\usepackage{longtable}

\begin{document}

\begin{longtable}{|p{0.05\textwidth}|p{.75\textwidth}|p{0.10\textwidth}|}
  % \toprule
  \hline
    Serial No.\ & Assignment Name & Date \\
    % \midrule
    \hline

    1 
    & 
    \begin{minipage}[t]{\linewidth}
      Foo bar
      \begin{enumerate}[nosep,after=\strut]
      \item foo
      \item foo
      \item bar
      \item bar
    \end{enumerate}
    \end{minipage}
    & 
    10.01.2022\\
    % \midrule
    \hline

    2
    &
    \begin{minipage}[t]{\linewidth}
      \begin{enumerate}[nosep, after=\strut, label=(\Alph*)]
        \item 
        Given two sequences:
        \[ x_1 = \{\mathbf{2}, 2, 1, 2 \} \]
        \[ x_2 = \{\mathbf{-2}, -1, 3, 2 \} \]
      \end{enumerate} 
      % other items...
      Find their convolution
    \end{minipage}
    &
    17.01.2022\\
    %\bottomrule
    \hline
\end{longtable}
\end{document}

I have two versions:

  1. with booktabs which gives me more or less proper spacing between the row lines but discontinuous vertical lines (expected of booktabs) enter image description here

  2. without booktabs which removes the discontinuous vertical line but messes up the line spacing (the rows are too close to the horizontal lines separating them): enter image description here

I am looking for an in-between which:

  1. gives me proper spacing
  2. removes the discontinuous vertical lines.

(It needs to be long table because there are many more entries which will together span 3 pages at least.)

0

4 Answers 4

5

With the help of the tabularray package:

enter image description here

To adjust the space between horizontal line and text, use the abovesep and belowsep and keys. (The default value is 2pt.)

\documentclass[11pt]{article}

\usepackage[margin=20mm]{geometry}

\usepackage{enumitem}
\newlist{tabenum}{enumerate}{1}
\setlist[tabenum]{label*=\arabic*.,
                  leftmargin=*,
                  nosep,
                  before=\begin{minipage}[t]{\hsize},
                  after=\end{minipage}}

\usepackage{tabularray}
\UseTblrLibrary{varwidth}

\begin{document}

\begin{longtblr}{colspec={l X l}, hlines, vlines, measure = vbox}
    {Serial\\ No.} & Assignment Name & Date \\
    1 
    & 
      Foo bar
      \begin{tabenum}
      \item foo
      \item foo
      \item bar
      \item bar
    \end{tabenum}
    & 
    10.01.2022\\

    2
    &
      \begin{tabenum}[label=(\Alph*)]
        \item 
        Given two sequences:
        \[ x_1 = \{\mathbf{2}, 2, 1, 2 \} \]
        \[ x_2 = \{\mathbf{-2}, -1, 3, 2 \} \]
      \end{tabenum} 
       %other items...
      Find their convolution
    &
    17.01.2022\\
\end{longtblr}
\end{document}
4

You're wrong about vertical lines, but that's personal opinion.

Rather than using minipages, you need to remove spurious blank lines before or after a list.

\documentclass[11pt,draft]{article}

\usepackage[margin=20mm]{geometry}
\usepackage{enumitem}
\usepackage{longtable}
\usepackage{amsmath}

\begin{document}

\begin{longtable}{|c|p{.75\textwidth}|l|}
\hline
\begin{tabular}[t]{@{}c@{}}Serial \\ No.\end{tabular} & Assignment Name & Date \\
\hline
1 &
  Foo bar
  \begin{enumerate}[nosep,after=\vspace*{-\baselineskip}]
    \item foo
    \item foo
    \item bar
    \item bar
  \end{enumerate} & 
  10.01.2022\\
\hline
2 & 
  \begin{enumerate}[nosep, wide, label=(\Alph*),before=\vspace*{-\baselineskip}]
    \item Given two sequences:
      \begin{gather*}
        x_1 = \{\mathbf{2}, 2, 1, 2 \} \\
        x_2 = \{\mathbf{-2}, -1, 3, 2 \}
      \end{gather*}
    \item Given two sequences:
      \begin{gather*}
        x_1 = \{\mathbf{2}, 2, 1, 2 \} \\
        x_2 = \{\mathbf{-2}, -1, 3, 2 \}
      \end{gather*}
  \end{enumerate} 
  Find their convolution &
  17.01.2022\\
\hline
\end{longtable}

\end{document}

enter image description here

4

Maybe this solution with the cellspace package will be fine for you. This package ensures a minimal vertical spacing at the top and bottom of cells in columns with specifier prefixed with the letter S by default (or C if you load siunitx, or any letter you please with the column=some letter option).

I also removed the minipage environments which are unnecessary here since you use the p column type.

    \documentclass[11pt]{article}

    \usepackage[margin=20mm]{geometry}
    \usepackage{enumitem}
    \usepackage{longtable}
    \usepackage{cellspace}
    \setlength{\cellspacetoplimit}{8pt}
    \setlength{\cellspacebottomlimit}{8pt}


    \begin{document}

    \begin{longtable}{|p{0.05\textwidth}|S{p{.75\textwidth}}|p{0.10\textwidth}|}
      % \toprule
      \hline
        Serial No.\ & Assignment Name & Date \\
        % \midrule
        \hline
        1
        &
          Foo bar
          \begin{enumerate}[nosep,after=\strut]
          \item foo
          \item foo
          \item bar
          \item bar
        \end{enumerate}
        &
        10.01.2022\\
        \hline
    %
        2
        & \begin{enumerate}[nosep, after=\strut, label=(\Alph*)]
            \item
            Given two sequences:
            \[ x_1 = \{\mathbf{2}, 2, 1, 2 \} \]
            \[ x_2 = \{\mathbf{-2}, -1, 3, 2 \} \]
          \end{enumerate}
          % other items...
          Find their convolution
        &
        17.01.2022 \\
        \hline
    \end{longtable}

    \end{document} 

enter image description here

1

I would (a) get rid of all vertical bars -- they aren't needed, and they won't be missed -- and (b) calculate the width of the middle column as a residual, to assure that the column's width is maximized.

enter image description here

\documentclass[11pt]{article}

\usepackage[margin=20mm]{geometry}
\usepackage{booktabs,enumitem,longtable,amsmath}
\newlength\mylenA
\settowidth\mylenA{Serial No.}
\newlength\mylenB
\settowidth\mylenB{10.01.2022}

\begin{document}

\begin{longtable}{@{} p{\mylenA}
                      p{\dimexpr\textwidth-\mylenA-\mylenB-4\tabcolsep\relax}
                      p{\mylenB} @{}}
  \toprule
  Serial No. & Assignment Name & Date \\
  \midrule
  \endhead
    
  \bottomrule
  \endlastfoot

    1 
    & 
    \begin{minipage}[t]{\linewidth}
      Foo bar
      \begin{enumerate}[nosep,after=\strut]
      \item foo
      \item foo
      \item bar
      \item bar
    \end{enumerate}
    \end{minipage}
    & 
    10.01.2022 \\
    \midrule

    2
    &
    \begin{minipage}[t]{\linewidth}
      \begin{enumerate}[nosep, after=\strut, label=(\Alph*)]
        \item 
        Given two sequences:
        \[ 
        \begin{aligned}
          x_1 &= \{\mathbf{2},   2, 1, 2 \} \\
          x_2 &= \{\mathbf{-2}, -1, 3, 2 \}
          \end{aligned}
        \]
      % other items...
      Find their convolution
      \end{enumerate}
    \end{minipage}
    &
    17.01.2022\\

\end{longtable}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .