Como posso criar uma tabela que se estende pela largura de duas páginas A4 verticais (e opostas)?

Como posso criar uma tabela que se estende pela largura de duas páginas A4 verticais (e opostas)?

Eu tenho uma mesa grande (larga) para compor. Normalmente uso o código abaixo para minhas tabelas, o que me permite especificar a largura de cada coluna da tabela. No entanto, cabe a mim garantir que a soma das larguras das colunas caiba em uma página.

\documentclass[12pt, a4paper]{article} 
\usepackage{booktabs, array}

\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}

\begin{document}
\begin{table}
\begin{tabular}{C{2cm}  C{2cm} C{2cm} C{2cm}  C{2cm} C{2cm}}
\toprule

~ & \textbf{Column 1} & \textbf{Column 2} & \textbf{Column 3} & \textbf{Column 4} & \textbf{Column 5}  \\
\textbf{Row 1} & Text (1,1) & Text (1,2) & Text (1,3) & Text (1,4) & Text (1,5)  \\
\textbf{Row 2} & Text (2,1) & Text (2,2) & Text (2,3) & Text (2,4) & Text (2,5)  \\
\textbf{Row 3} & Text (3,1) & Text (3,2) & Text (3,3) & Text (3,4) & Text (3,5)  \\
\textbf{Row 4} & Text (4,1) & Text (4,2) & Text (4,3) & Text (4,4) & Text (4,5)  \\
\textbf{Row 5} & Text (5,1) & Text (5,2) & Text (5,3) & Text (5,4) & Text (5,5)  \\
\textbf{Row 6} & Text (6,1) & Text (6,2) & Text (6,3) & Text (6,4) & Text (6,5)  \\

 \bottomrule

\end{tabular}
\caption{This is a table}
\end{table}
\end{document}

Gostaria de criar uma tabela muito ampla que abrangesse a largura de 2 páginas A4 verticais

(Estou escrevendo um documento usando os 2 lados de uma página e gostaria que o canto esquerdo da minha tabela estivesse em um número de página par e o canto direito da tabela na página oposta).

Portanto, não deve haver margem direita na página esquerda nem margem esquerda na página direita, para que a tabela seja contínua ao longo da largura das duas páginas A4.

Isso é possível?

Responder1

Comecei com minha resposta emComo faço para criar 6 textos paralelos alinhados por parágrafo, com 3 textos em cada página?como base, mas teve que fazer uma série de alterações.

Pelo lado mais fácil, não preciso me preocupar com entradas de linha de alturas diferentes para a consulta deste OP. Mas, pelo lado negativo, tive que reescrever significativamente o código para lidar com 10 ou mais entradas de coluna (já que #10não funciona). Para esse fim, não passei diferentes entradas de coluna como argumentos, mas escrevi meu próprio código de análise de tabulação, para que a linha pudesse ser inserida como se fosse uma linha tabular.

Ainda usei o trecho de código de Herbert para processar tokens tabulares dentro de a \whiledoe adicionei um trecho de Stephan Lehmke para iniciar a tabela em um número de página par quando estiver no twosidemodo.

Como recurso bônus, não apenas permito que o código seja quebrado nas páginas esquerda/direita, mas também pode ser quebrado verticalmente, para tabelas extra longas. A sintaxe é \newtwopagetableinicializar o processo. Em seguida, linhas individuais são adicionadas \tenbyrow{}onde o argumento é uma &lista separada de dez entradas (é uma pequena reescrita para outras entradas de número de coluna). Finalmente, quando todos os dados são inseridos desta forma, você tem duas opções:

\newtwopagetable{caption}

produzirá a tabela inteira em duas páginas; ou

\maketwopagetable[4]{caption}
\maketwopagetable[4]{caption}

também dividirá a tabela frente e verso em partes verticais, mostradas acima como quatro linhas na primeira página dupla e quatro linhas na segunda página dupla.

Aqui está o código fonte:

\documentclass[twoside]{article}% TABLE CLEARS TO EVEN PAGE
%\documentclass{article}% TABLE CLEARS TO NEXT PAGE
\usepackage{booktabs, array}
\usepackage{ifthen}
\usepackage{etoolbox}

\makeatletter%%%%%%%%%%% My own tab parsing code

\newcounter{TABcellindex@}

\newcommand\readTABrow[2]{%
  \def\doneTABread{F}%
  \def\postTAB{#2}%
  \setcounter{TABcellindex@}{0}%
  \whiledo{\equal{\doneTABread}{F}}{%
    \stepcounter{TABcellindex@}%
    \expandafter\processTAB\postTAB&\\%
    \ifthenelse{\equal{\preTAB}{}}{%
      \addtocounter{TABcellindex@}{-1}%
      \def\doneTABread{T}%
    }{%
      \expandafter\protected@edef\csname #1\alph{TABcellindex@}\endcsname{%
        \preTAB}%
    }%
  }%
% \#1TABcells GIVES HOW MANY TAB COLUMNS WERE PROCESSED
%  \expandafter\xdef\csname #1TABcells\endcsname{\arabic{TABcellindex@}}%
}

\def\processTAB#1&#2\\{%
  \protected@edef\preTAB{#1}%
  \protected@edef\postTAB{#2}%
}

\makeatother%%%%%%%%%%% END My own tab parsing code

\makeatletter%%%%%%%%%%% Herbert's tabular token code
\newcounter{tabindex}
\newtoks\@tabtoks
\newcommand\addtabtoks[1]{%
  \@tabtoks\expandafter{\the\@tabtoks\stepcounter{tabindex}#1}}
\newcommand*\resettabtoks{\@tabtoks{}}
\newcommand*\synctabindex[1]{\setcounter{tabindex}{\value{#1}}}
\newcommand*\printtabtoks{\the\@tabtoks}
\makeatother%%%%%%%%%%% END Herbert's tabular token code

\makeatletter%%%%%%% Lehmke's \cleartoleftpage
\def\cleartoleftpage{\clearpage\if@twoside \ifodd\c@page
\hbox{}\newpage\if@twocolumn\hbox{}\newpage\fi\fi\fi}
\makeatother
\makeatother%%%%%%%% END Lehmke's \cleartoleftpage


\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}

\newcounter{sptstartrow}
\newcounter{sptendrow}
\newcounter{entries}

\newcommand\newtwopagetable{%
  \setcounter{sptendrow}{0}%
  \setcounter{entries}{0}%
  \cleartoleftpage%
}

\makeatletter
\newcommand\tenbyrow[1]{%
  \stepcounter{entries}%
  \readTABrow{entryX\roman{entries}X}{#1}%
}
\makeatother
\newcounter{index}
\newcommand\maketwopagetable[2][\theentries]{%
  \setcounter{sptstartrow}{\thesptendrow}%
  \ifthenelse{\thesptstartrow > 1}%
    {\addtocounter{table}{-1}\def\conttext{, continued}}%
    {\def\conttext{}}%
  \addtocounter{sptendrow}{#1}%
  \ifthenelse{\thesptendrow > \theentries}{\setcounter{sptendrow}{\theentries}}{}%
  \clearpage
  \setcounter{index}{\thesptstartrow}%
  \synctabindex{index}
  \resettabtoks%
  \whiledo{\theindex < \thesptendrow}{%
    \stepcounter{index}%
    \addtabtoks{%
      \csname entryX\roman{tabindex}Xa\endcsname &
      \csname entryX\roman{tabindex}Xb\endcsname &
      \csname entryX\roman{tabindex}Xc\endcsname & 
      \csname entryX\roman{tabindex}Xd\endcsname &
      \csname entryX\roman{tabindex}Xe\endcsname 
      \\%
    }%
  }%
  \begin{table}
  \centering
  \begin{tabular}{C{2cm}  C{2cm} C{2cm} C{2cm} C{2cm}}
   \toprule

   \printtabtoks%

   \bottomrule
  \end{tabular}%
  \caption{#2 (left half\conttext)}
  \end{table}%
  \addtocounter{table}{-1}%
  \clearpage
  \setcounter{index}{\thesptstartrow}%
  \synctabindex{index}
  \resettabtoks%
  \whiledo{\theindex < \thesptendrow}{%
    \stepcounter{index}%
    \addtabtoks{%
      \csname entryX\roman{tabindex}Xf\endcsname &
      \csname entryX\roman{tabindex}Xg\endcsname &
      \csname entryX\roman{tabindex}Xh\endcsname &
      \csname entryX\roman{tabindex}Xi\endcsname &
      \csname entryX\roman{tabindex}Xj\endcsname 
      \\%
    }%
  }%
  \begin{table}
  \centering
  \begin{tabular}{C{2cm}  C{2cm} C{2cm} C{2cm} C{2cm}}
   \toprule

   \printtabtoks%

   \bottomrule
  \end{tabular}%
  \caption{#2 (right half\conttext)}
  \end{table}%
}

\begin{document}
\newtwopagetable
\tenbyrow%
{~ & \textbf{Column 1} & \textbf{Column 2} & \textbf{Column 3} &
\textbf{Column 4} & \textbf{Column 5} & \textbf{Column 6} &
\textbf{Column 7} & \textbf{Column 8} & \textbf{Column 9}}
\tenbyrow%
{\textbf{Row 1} & Text (1,1) & Text (1,2) & Text (1,3) & Text (1,4)
& Text (1,5) & Text (1,6) & Text (1,7) & Text (1,8) & Text (1,9)}
\tenbyrow%
{\textbf{Row 2} & Text (2,1) & Text (2,2) & Text (2,3) & Text (2,4)
& Text (2,5) & Text (2,6) & Text (2,7) & Text (2,8) & Text (2,9)}
\tenbyrow%
{\textbf{Row 3} & Text (3,1) & Text (3,2) & Text (3,3) & Text (3,4)
& Text (3,5) & Text (3,6) & Text (3,7) & Text (3,8) & Text (3,9)}
\tenbyrow%
{\textbf{Row 4} & Text (4,1) & Text (4,2) & Text (4,3) & Text (4,4)
& Text (4,5) & Text (4,6) & Text (4,7) & Text (4,8) & Text (4,9)}
\tenbyrow%
{\textbf{Row 5} & Text (5,1) & Text (5,2) & Text (5,3) & Text (5,4)
& Text (5,5) & Text (5,6) & Text (5,7) & Text (5,8) & Text (5,9)}
\tenbyrow%
{\textbf{Row 6} & Text (6,1) & Text (6,2) & Text (6,3) & Text (6,4)
& Text (6,5) & Text (6,6) & Text (6,7) & Text (6,8) & Text (6,9)}
\tenbyrow%
{\textbf{Row 7} & Text (7,1) & Text (7,2) & Text (7,3) & Text (7,4)
& Text (7,5) & Text (7,6) & Text (7,7) & Text (7,8) & Text (7,9)}
\maketwopagetable{This is a table}

\newtwopagetable
\setcounter{entries}{8}% THIS IS TO FOOL LaTeX INTO THINKING I RE-ENTERED THE TABLE DATA
\maketwopagetable[4]{This is a vertically split table}
\maketwopagetable[4]{This is a vertically split table}

\end{document}

Aqui está a saída completa da tabela em uma página dupla:

insira a descrição da imagem aqui

Enquanto aqui está a tabela, dividida na largura e no comprimento, como saída nas próximas quatro páginas. Observe que o (left/right half, continued)comentário é fornecido por \maketwopagetablee não faz parte do argumento de legenda do usuário.

insira a descrição da imagem aqui

insira a descrição da imagem aqui

insira a descrição da imagem aqui

insira a descrição da imagem aqui

informação relacionada