Проблемы с интервалами в сложной таблице

Проблемы с интервалами в сложной таблице

У меня есть таблица, в которой я включаю списки в каждую ячейку столбца, и я настаиваю на использовании вертикальных линий. В настоящее время у меня есть следующий 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}

У меня есть две версии:

  1. с помощью booktabsкоторого я получаю более или менее правильный интервал между линиями строк, но прерывистые вертикальные линии (ожидаемые от booktabs) введите описание изображения здесь

  2. без booktabsкоторого удаляется прерывистая вертикальная линия, но нарушается межстрочный интервал (строки располагаются слишком близко к разделяющим их горизонтальным линиям): введите описание изображения здесь

Я ищу нечто среднее, что:

  1. дает мне правильный интервал
  2. удаляет прерывистые вертикальные линии.

(Таблица должна быть длинной, поскольку в ней гораздо больше записей, которые в совокупности займут не менее 3 страниц.)

решение1

С помощью пакета tabularray:

введите описание изображения здесь

Чтобы отрегулировать расстояние между горизонтальной линией и текстом, используйте клавиши abovesepи belowsepи . (Значение по умолчанию — 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}

решение2

Вы не правы насчет вертикальных линий, но это личное мнение.

Вместо использования мини-страниц вам необходимо удалить лишние пустые строки до или после списка.

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

введите описание изображения здесь

решение3

Возможно, это решение с cellspaceпакетом подойдет вам. Этот пакет обеспечивает минимальный вертикальный интервал сверху и снизу ячеек в столбцах с префиксом спецификатора в виде буквы Sпо умолчанию (или Cесли вы загрузите siunitx, или любую букву, которую вы пожелаете с column=some letterопцией).

Я также удалил minipageокружения, которые здесь не нужны, поскольку вы используете pтип столбца.

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

введите описание изображения здесь

решение4

Я бы (а) избавился от всех вертикальных полос — они не нужны, и их не будет не хватать — и (б) рассчитал бы ширину среднего столбца как остаток, чтобы гарантировать, что ширина столбца максимальна.

введите описание изображения здесь

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

Связанный контент