Problemas de espaçamento em uma tabela complicada

Problemas de espaçamento em uma tabela complicada

Tenho uma tabela na qual incluo listas em cada célula de uma coluna e insisto em usar linhas verticais. Atualmente, tenho o seguinte 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}

Tenho duas versões:

  1. com booktabso qual me dá um espaçamento mais ou menos adequado entre as linhas das linhas, mas linhas verticais descontínuas (esperado de booktabs) insira a descrição da imagem aqui

  2. sem booktabso qual remove a linha vertical descontínua, mas atrapalha o espaçamento entre linhas (as linhas estão muito próximas das linhas horizontais que as separam): insira a descrição da imagem aqui

Estou procurando um meio-termo que:

  1. me dá espaçamento adequado
  2. remove as linhas verticais descontínuas.

(Precisa ser uma tabela longa porque há muito mais entradas que juntas ocuparão pelo menos 3 páginas.)

Responder1

Com a ajuda do tabularraypacote:

insira a descrição da imagem aqui

Para ajustar o espaço entre a linha horizontal e o texto, use as teclas abovesepe belowsepe. (O valor padrão é 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}

Responder2

Você está errado sobre as linhas verticais, mas isso é opinião pessoal.

Em vez de usar minipáginas, você precisa remover linhas em branco falsas antes ou depois de uma lista.

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

insira a descrição da imagem aqui

Responder3

Talvez esta solução com o cellspacepacote seja adequada para você. Este pacote garante um espaçamento vertical mínimo na parte superior e inferior das células em colunas com especificador prefixado com a letra Spor padrão (ou Cse você carregar siunitx, ou qualquer letra que desejar com a column=some letteropção).

Também removi os minipageambientes desnecessários aqui, pois você usa o ptipo de coluna.

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

insira a descrição da imagem aqui

Responder4

Eu (a) me livraria de todas as barras verticais - elas não são necessárias e não serão perdidas - e (b) calcularia a largura da coluna do meio como um resíduo, para garantir que a largura da coluna seja maximizado.

insira a descrição da imagem aqui

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

informação relacionada