Mover tabela em documentos da classe `book`

Mover tabela em documentos da classe `book`

Preciso adicionar algumas tabelas no bookdocumento da classe. Às vezes a tabela é mais larga que o texto. Isso não é problema quando acontece em páginas ímpares, pois elas têm margens direitas maiores e irei encadernar a partir da esquerda, conforme mostrado abaixo.

insira a descrição da imagem aqui

Porém, torna-se um problema quando a tabela tem que estar em páginas pares como mostrado abaixo porque a encadernação acontece no lado direito e parte da tabela será afetada. Portanto, seria melhor deixar a tabela extra ocupar espaço no lado esquerdo em vez de no direito nas páginas pares. Como conseguir isso, por favor? Obrigado! Meu exemplo está anexado abaixo.

insira a descrição da imagem aqui

    \documentclass[a4paper, twoside, hidelinks, 11pt]{book}

  \usepackage{booktabs}
  \usepackage{lipsum}

\begin{document}

\begin{table}[h]
\centering
\begin{tabular}{rccccc}
\toprule
Blah & Blah     & Blah & Blah     & Blah & Blah Blah Blah Blah \\ \midrule
-0.4    & -0.00495 & 0.02716  & 0.02719 & (0.70525, 1.34978) & (0.67622, 1.32378) \\
-0.3    & -0.00558 & 0.02534  & 0.02537 & (0.71227, 1.33488) & (0.68681, 1.31319) \\
-0.2    & -0.00616 & 0.02362  & 0.02366 & (0.71923, 1.32050) & (0.69718, 1.30282) \\
-0.1    & -0.00669 & 0.02201  & 0.02206 & (0.72613, 1.30662) & (0.70732, 1.29268) \\
0.1     & -0.00762 & 0.01909  & 0.01915 & (0.73968, 1.28034) & (0.72692, 1.27308) \\
0.2     & -0.00802 & 0.01776  & 0.01783 & (0.74636, 1.26790) & (0.73638, 1.26362) \\
0.3     & -0.00838 & 0.01652  & 0.01659 & (0.75294, 1.25591) & (0.74561, 1.25439) \\
0.4     & -0.00870 & 0.01536  & 0.01543 & (0.75945, 1.24439) & (0.75462, 1.24538) \\ \bottomrule
\end{tabular}
\end{table}

\lipsum[1-5]

\begin{table}[h]
\centering
\begin{tabular}{rccccc}
\toprule
Blah & Blah     & Blah & Blah     & Blah & Blah Blah Blah Blah \\ \midrule
-0.4    & -0.00495 & 0.02716  & 0.02719 & (0.70525, 1.34978) & (0.67622, 1.32378) \\
-0.3    & -0.00558 & 0.02534  & 0.02537 & (0.71227, 1.33488) & (0.68681, 1.31319) \\
-0.2    & -0.00616 & 0.02362  & 0.02366 & (0.71923, 1.32050) & (0.69718, 1.30282) \\
-0.1    & -0.00669 & 0.02201  & 0.02206 & (0.72613, 1.30662) & (0.70732, 1.29268) \\
0.1     & -0.00762 & 0.01909  & 0.01915 & (0.73968, 1.28034) & (0.72692, 1.27308) \\
0.2     & -0.00802 & 0.01776  & 0.01783 & (0.74636, 1.26790) & (0.73638, 1.26362) \\
0.3     & -0.00838 & 0.01652  & 0.01659 & (0.75294, 1.25591) & (0.74561, 1.25439) \\
0.4     & -0.00870 & 0.01536  & 0.01543 & (0.75945, 1.24439) & (0.75462, 1.24538) \\ \bottomrule
\end{tabular}
\end{table}

\end{document}

Responder1

Tente este. É semelhante à resposta do @Werner, mas eu automatizo tabularo alinhamento.

\documentclass[a4paper, twoside, hidelinks, 11pt]{book}

\usepackage{booktabs}
\usepackage{lipsum}
\makeatletter
\newcommand*\mytabalign{%
    \edef\sk@align{\ifodd\c@page l\else r\fi}
    \makebox[\textwidth][\sk@align]}
\makeatother
\begin{document}

\begin{table}[h]
\centering
\mytabalign{\begin{tabular}{rccccc}
\toprule
Blah & Blah     & Blah & Blah     & Blah & Blah Blah Blah Blah \\ \midrule
-0.4    & -0.00495 & 0.02716  & 0.02719 & (0.70525, 1.34978) & (0.67622, 1.32378) \\
-0.3    & -0.00558 & 0.02534  & 0.02537 & (0.71227, 1.33488) & (0.68681, 1.31319) \\
-0.2    & -0.00616 & 0.02362  & 0.02366 & (0.71923, 1.32050) & (0.69718, 1.30282) \\
-0.1    & -0.00669 & 0.02201  & 0.02206 & (0.72613, 1.30662) & (0.70732, 1.29268) \\
0.1     & -0.00762 & 0.01909  & 0.01915 & (0.73968, 1.28034) & (0.72692, 1.27308) \\
0.2     & -0.00802 & 0.01776  & 0.01783 & (0.74636, 1.26790) & (0.73638, 1.26362) \\
0.3     & -0.00838 & 0.01652  & 0.01659 & (0.75294, 1.25591) & (0.74561, 1.25439) \\
0.4     & -0.00870 & 0.01536  & 0.01543 & (0.75945, 1.24439) & (0.75462, 1.24538) \\ \bottomrule
\end{tabular}}
\end{table}

\lipsum[1-5]

\begin{table}[h]
\centering

\mytabalign{\begin{tabular}{rccccc}
\toprule
Blah & Blah     & Blah & Blah     & Blah & Blah Blah Blah Blah \\ \midrule
-0.4    & -0.00495 & 0.02716  & 0.02719 & (0.70525, 1.34978) & (0.67622, 1.32378) \\
-0.3    & -0.00558 & 0.02534  & 0.02537 & (0.71227, 1.33488) & (0.68681, 1.31319) \\
-0.2    & -0.00616 & 0.02362  & 0.02366 & (0.71923, 1.32050) & (0.69718, 1.30282) \\
-0.1    & -0.00669 & 0.02201  & 0.02206 & (0.72613, 1.30662) & (0.70732, 1.29268) \\
0.1     & -0.00762 & 0.01909  & 0.01915 & (0.73968, 1.28034) & (0.72692, 1.27308) \\
0.2     & -0.00802 & 0.01776  & 0.01783 & (0.74636, 1.26790) & (0.73638, 1.26362) \\
0.3     & -0.00838 & 0.01652  & 0.01659 & (0.75294, 1.25591) & (0.74561, 1.25439) \\
0.4     & -0.00870 & 0.01536  & 0.01543 & (0.75945, 1.24439) & (0.75462, 1.24538) \\ \bottomrule
\end{tabular}}
\end{table}

\end{document}

Não tenho certeza se funciona corretamente em todas as situações, mas parece funcionar bem neste caso ( tableambiente interno).

Responder2

Eu sugeriria compilar o seu booke esperar para ajustar essas coisas bem no final. Nesse momento, você pode evitar \hboxavisos muito completos para páginas ímpares muito grandes tabularusando

\makebox[0pt][l]{\begin{tabular}{..}
  ...
\end{tabular}}

e páginas pares tabularusando

\raggedleft
\makebox[0pt][r]{\begin{tabular}{..}
  ...
\end{tabular}}

Aqui está o seu exemplo em ação:

insira a descrição da imagem aqui

\documentclass[a4paper, twoside]{book}

\usepackage{booktabs,lipsum}

\begin{document}

\begin{table}[h]
  \makebox[0pt][l]{%
    \begin{tabular}{rccccc}
      \toprule
      Blah & Blah     & Blah & Blah     & Blah & Blah Blah Blah Blah \\ \midrule
      -0.4    & -0.00495 & 0.02716  & 0.02719 & (0.70525, 1.34978) & (0.67622, 1.32378) \\
      -0.3    & -0.00558 & 0.02534  & 0.02537 & (0.71227, 1.33488) & (0.68681, 1.31319) \\
      -0.2    & -0.00616 & 0.02362  & 0.02366 & (0.71923, 1.32050) & (0.69718, 1.30282) \\
      -0.1    & -0.00669 & 0.02201  & 0.02206 & (0.72613, 1.30662) & (0.70732, 1.29268) \\
      0.1     & -0.00762 & 0.01909  & 0.01915 & (0.73968, 1.28034) & (0.72692, 1.27308) \\
      0.2     & -0.00802 & 0.01776  & 0.01783 & (0.74636, 1.26790) & (0.73638, 1.26362) \\
      0.3     & -0.00838 & 0.01652  & 0.01659 & (0.75294, 1.25591) & (0.74561, 1.25439) \\
      0.4     & -0.00870 & 0.01536  & 0.01543 & (0.75945, 1.24439) & (0.75462, 1.24538) \\
      \bottomrule
    \end{tabular}}
\end{table}

\lipsum[1-5]

\begin{table}[h]
  \raggedleft
  \makebox[0pt][r]{%
    \begin{tabular}{rccccc}
      \toprule
      Blah & Blah     & Blah & Blah     & Blah & Blah Blah Blah Blah \\ \midrule
      -0.4    & -0.00495 & 0.02716  & 0.02719 & (0.70525, 1.34978) & (0.67622, 1.32378) \\
      -0.3    & -0.00558 & 0.02534  & 0.02537 & (0.71227, 1.33488) & (0.68681, 1.31319) \\
      -0.2    & -0.00616 & 0.02362  & 0.02366 & (0.71923, 1.32050) & (0.69718, 1.30282) \\
      -0.1    & -0.00669 & 0.02201  & 0.02206 & (0.72613, 1.30662) & (0.70732, 1.29268) \\
      0.1     & -0.00762 & 0.01909  & 0.01915 & (0.73968, 1.28034) & (0.72692, 1.27308) \\
      0.2     & -0.00802 & 0.01776  & 0.01783 & (0.74636, 1.26790) & (0.73638, 1.26362) \\
      0.3     & -0.00838 & 0.01652  & 0.01659 & (0.75294, 1.25591) & (0.74561, 1.25439) \\
      0.4     & -0.00870 & 0.01536  & 0.01543 & (0.75945, 1.24439) & (0.75462, 1.24538) \\
      \bottomrule
    \end{tabular}}
\end{table}

\end{document}

A automação deste procedimento pode de fato ser possível, mas depende muito do seu uso típico tabular(dentro de flutuadores e/ou fora, por exemplo).

Responder3

O principal problema é que sua tabela é muito grande e isso acontece porque há muitos dados nela para a largura do texto que você tem :) Como consequência, vejo diferentes possibilidades para resolver o problema:

  1. Altere a formatação da sua tabela. Você poderia, por exemplo, exibir os pares em duas linhas em vez de usar (... , ...). Ou escreva .123em vez de 0.123, dependendo das convenções usadas no seu domínio. Outra forma seria usar unidades de escala diferentes, por exemplo, 2.716em vez 0.02716do fator $10^{-2}$escrito no título da coluna. Novamente, isso pode ou não ser viável.

  2. Use \smallo tamanho da fonte. Essevaitorne sua mesa menor. No entanto, pode se tornar mais difícil de ler, dependendo do conteúdo real que você possui.

  3. Use o ambiente float table, coloque a tabela em uma página separada e digite-a no formato paisagem.

Se nenhuma dessas possibilidades (ou combinações delas) funcionar para você, você pode tentar forçar o LaTeX a fazer com que a tabela se projete noexteriormargem em vez da margem direita. Enquanto escrevo isso, posso ver que Werner já mostrou como fazer isso.

Responder4

Uma solução baseada em tabularxe brincando com \arraycolsepmostra que a tabela pode ter exatamente a largura do texto. Adicionei o siunitxpacote para formatar os números nas primeiras quatro colunas.

\documentclass[a4paper, twoside]{book}

\usepackage{booktabs, tabularx, siunitx, lipsum}
\renewcommand{\tabularxcolumn}[1]{>{\centering\arraybackslash$}m{#1}<{$}}
\begin{document}

\lipsum[1]

\begin{table}[h]\setlength\extrarowheight{1.5pt}
  \begin{tabularx}{\linewidth}{@{\,}S[table-format=-1.1]S[table-format=-1.5]S[table-format=1.5]S[table-format=1.5]XX @{\,}}
    \toprule
    {Blah} & Blah & Blah & Blah & \text{Blah} & \parbox{\hsize}{\centering Blah Blah Blah Blah} \\[1ex]
    \midrule
    -0.4 & -0.00495 & 0.02716 & 0.02719 & (0.70525, 1.34978) & (0.67622, 1.32378) \\
    -0.3 & -0.00558 & 0.02534 & 0.02537 & (0.71227, 1.33488) & (0.68681, 1.31319) \\
    -0.2 & -0.00616 & 0.02362 & 0.02366 & (0.71923, 1.32050) & (0.69718, 1.30282) \\
    -0.1 & -0.00669 & 0.02201 & 0.02206 & (0.72613, 1.30662) & (0.70732, 1.29268) \\
    0.1 & -0.00762 & 0.01909 & 0.01915 & (0.73968, 1.28034) & (0.72692, 1.27308) \\
    0.2 & -0.00802 & 0.01776 & 0.01783 & (0.74636, 1.26790) & (0.73638, 1.26362) \\
    0.3 & -0.00838 & 0.01652 & 0.01659 & (0.75294, 1.25591) & (0.74561, 1.25439) \\
    0.4 & -0.00870 & 0.01536 & 0.01543 & (0.75945, 1.24439) & (0.75462, 1.24538) \\
    \bottomrule
  \end{tabularx}
\end{table}

\end{document} 

insira a descrição da imagem aqui

informação relacionada