
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:
com
booktabs
o qual me dá um espaçamento mais ou menos adequado entre as linhas das linhas, mas linhas verticais descontínuas (esperado debooktabs
)sem
booktabs
o 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):
Estou procurando um meio-termo que:
- me dá espaçamento adequado
- 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 tabularray
pacote:
Para ajustar o espaço entre a linha horizontal e o texto, use as teclas abovesep
e belowsep
e. (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}
Responder3
Talvez esta solução com o cellspace
pacote 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 S
por padrão (ou C
se você carregar siunitx
, ou qualquer letra que desejar com a column=some letter
opção).
Também removi os minipage
ambientes desnecessários aqui, pois você usa o p
tipo 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}
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.
\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}