Como tornar esta tabela quebrável?

Como tornar esta tabela quebrável?

Atualmente tenho uma mesa que cresceu um pouco e não cabe mais no espaço pretendido. Como espero que esta tabela continue crescendo no futuro, preciso torná-la quebrável, mantendo seu estilo atual. Existem muitas postagens por aí sobre como obter tabelas quebráveis ​​​​de página, mas não consegui usar nenhuma das soluções que encontrei porque recebi erros que não consegui entender ou o resultado final não parecia como pretendido.

Compartilho abaixo um MWE que mostra minha tabela atual (inquebrável), bem como uma captura de tela da saída que ela produz. O que o MWE faz é criar um ambiente de lista que eu invoco sempre que necessário. Minha meta épara replicar esta saída, mas certificando-se de que a tabela será quebrada corretamente (em vez de saltar) sempre que atingir uma quebra de página.

\documentclass[a4paper]{article}

\begin{document}

\newenvironment{entrylist}{%
  \noindent
  \begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}rl}
}{%
  \end{tabular*}
}
\newcommand{\entry}[4]{%
    \parbox[t]{1.75cm}{#1\raggedleft}&\parbox[t]{\dimexpr\textwidth-2\tabcolsep-1.75cm}{\strut%
    \textbf{#2}%
    \hfill%
    {\footnotesize #3\par\strut}%
    #4\vspace{\parsep}%
  }\\}

\begin{entrylist}

  \entry
    {XXXX}
    {Fancy stuff 1}
    {Fancy stuff 1}
    {Fancy stuff 1}

  \entry
    {YYYY}
    {Fancy stuff 2}
    {Fancy stuff 2}
    {Fancy stuff 2}

  \entry
    {ZZZZ}
    {Fancy stuff 3}
    {Fancy stuff 3}
    {Fancy stuff 3}
    
\end{entrylist}

\end{document}

insira a descrição da imagem aqui

Muito obrigado a todos pelo seu tempo.

Responder1

Você não precisa encapsular tudo em um ambiente tabular. Você pode definir o formato de cada um \entrypor suas macros. A página \smallskipseguinte \hboxpode ser quebrada, é claro.

\newdimen\colsep \colsep=1em
\def\topbox#1#2{\vtop{\parindent=0pt \hsize=\dimexpr#1\relax #2}}
\def\entry#1#2#3#4{\par
   \hbox{\topbox{1.75cm}{#1\raggedleft}\kern\colsep
         \topbox{\hsize-2\colsep-1.75cm}{{\bf#2}\hfill {\footnotesize#3}\endgraf#4\strut}}
   \smallskip
}

  \entry
    {XXXX}
    {Fancy stuff 1}
    {Fancy stuff 1}
    {Fancy stuff 1}

  \entry
    {YYYY}
    {Fancy stuff 2}
    {Fancy stuff 2}
    {Fancy stuff 2}

  \entry
    {ZZZZ}
    {Fancy stuff 3}
    {Fancy stuff 3}
    {Fancy stuff 3}

Responder2

Eu acho que tudo que você precisa fazer é

  • carregue o longtablepacote e emita as instruções \setlength\LTleft{0pt}e \setlength\LTright{0pt}no preâmbulo e

  • substitua \begin{tabular*}{\textwidth}por \begin{longtable}e \end{tabular*}com \end{longtable}na definição de entrylistmeio ambiente.

Opcionalmente, você pode excluir a \noindentdiretiva no início da definição do entrylistambiente.

Consulte a seção 5, intitulada "Ajuste", do longtableguia do usuário para obter mais informações sobre o que os parâmetros de comprimento \LTlefte \LTrightfazem.

Responder3

Usar longtable.

\documentclass[a4paper]{article}
\usepackage{longtable,array}

\usepackage{lipsum} % for nonsense text
\usepackage{showframe} % for showing the page boundaries

\newlength{\entrylistwidth}
\setlength{\entrylistwidth}{1.75cm}
\newenvironment{entrylist}{%
  \begin{longtable}{
    @{}
    w{l}{\entrylistwidth}
    p{\dimexpr\textwidth-2\tabcolsep-\entrylistwidth}
    @{}
  }
}{\end{longtable}}

\newcommand{\entry}[4]{%
  #1 & \textbf{#2}\hfill{\footnotesize #3\par}#4\\\noalign{\vspace{\parsep}}%
}

\begin{document}

\begin{entrylist}

  \entry
    {XXXX}
    {Fancy stuff 1}
    {Fancy stuff 1}
    {\lipsum[1][1-3]}

  \entry
    {YYYY}
    {Fancy stuff 2}
    {Fancy stuff 2}
    {\lipsum[2][1-3]}

  \entry
    {ZZZZ}
    {Fancy stuff 3}
    {Fancy stuff 3}
    {\lipsum[3][1-3]}
    
  \entry
    {ZZZZ}
    {Fancy stuff 3}
    {Fancy stuff 3}
    {\lipsum[3][1-3]}
    
  \entry
    {ZZZZ}
    {Fancy stuff 3}
    {Fancy stuff 3}
    {\lipsum[3][1-3]}
    
  \entry
    {ZZZZ}
    {Fancy stuff 3}
    {Fancy stuff 3}
    {\lipsum[3][1-3]}
    
  \entry
    {ZZZZ}
    {Fancy stuff 3}
    {Fancy stuff 3}
    {\lipsum[3][1-3]}
    
  \entry
    {ZZZZ}
    {Fancy stuff 3}
    {Fancy stuff 3}
    {\lipsum[3][1-3]}
    
  \entry
    {ZZZZ}
    {Fancy stuff 3}
    {Fancy stuff 3}
    {\lipsum[3][1-3]}
    
  \entry
    {ZZZZ}
    {Fancy stuff 3}
    {Fancy stuff 3}
    {\lipsum[3][1-3]}
    
  \entry
    {ZZZZ}
    {Fancy stuff 3}
    {Fancy stuff 3}
    {\lipsum[3][1-3]}
    
  \entry
    {ZZZZ}
    {Fancy stuff 3}
    {Fancy stuff 3}
    {\lipsum[3][1-3]}
    
  \entry
    {ZZZZ}
    {Fancy stuff 3}
    {Fancy stuff 3}
    {\lipsum[3][1-3]}
    
  \entry
    {ZZZZ}
    {Fancy stuff 3}
    {Fancy stuff 3}
    {\lipsum[3][1-3]}
    
  \entry
    {ZZZZ}
    {Fancy stuff 3}
    {Fancy stuff 3}
    {\lipsum[3][1-3]}
    
  \entry
    {ZZZZ}
    {Fancy stuff 3}
    {Fancy stuff 3}
    {\lipsum[3][1-3]}
    
  \entry
    {ZZZZ}
    {Fancy stuff 3}
    {Fancy stuff 3}
    {\lipsum[3][1-3]}
    
  \entry
    {ZZZZ}
    {Fancy stuff 3}
    {Fancy stuff 3}
    {\lipsum[3][1-3]}
    
  \entry
    {ZZZZ}
    {Fancy stuff 3}
    {Fancy stuff 3}
    {\lipsum[3][1-3]}
    
  \entry
    {ZZZZ}
    {Fancy stuff 3}
    {Fancy stuff 3}
    {\lipsum[3][1-3]}
    
  \entry
    {ZZZZ}
    {Fancy stuff 3}
    {Fancy stuff 3}
    {\lipsum[3][1-3]}
    
  \entry
    {ZZZZ}
    {Fancy stuff 3}
    {Fancy stuff 3}
    {\lipsum[3][1-3]}
    
  \entry
    {ZZZZ}
    {Fancy stuff 3}
    {Fancy stuff 3}
    {\lipsum[3][1-3]}
    
\end{entrylist}

\end{document}

insira a descrição da imagem aqui

informação relacionada