在“书籍”类文档中移动表格

在“书籍”类文档中移动表格

我需要在book课堂文档中添加一些表格。有时表格比文本宽。如果奇数页上有这种情况,则没有问题,因为它们的右边距较大,我将从左侧装订,如下所示。

在此处输入图片描述

但是,当表格必须放在偶数页上时,就会出现问题,如下所示,因为装订发生在右侧,表格的一部分会受到影响。因此,最好让额外的表格占用偶数页左侧的空间,而不是右侧的空间。请问如何实现这一点?谢谢!我的示例附在下面。

在此处输入图片描述

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

答案1

试试这个。它与@Werner 的答案类似,但我自动tabular对齐。

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

我不确定它在所有情况下都能正常工作,但在这种情况下(内部table环境)它似乎运行良好。

答案2

我建议编译你的book,然后等到最后再调整这些事情。那时你可以使用以下方法避免\hbox奇数页过大而出现过满警告:tabular

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

和偶数页tabular使用

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

以下是实际示例:

在此处输入图片描述

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

该过程的自动化确实是可能的,但它在很大程度上取决于您的典型用途tabular(例如,内部浮点数和/或外部)。

答案3

主要问题是您的表格太大,发生这种情况是因为表格中的数据对于您的文本宽度来说太多了:)因此,我看到了解决该问题的不同可能性:

  1. 更改表格的格式。例如,您可以将对显示在两行上,而不是使用(... , ...)。或者根据域中使用的约定,写.123而不是。另一种方法是使用不同的缩放单位,例如而不是 ,并在列标题中写上因子。同样,这可以或不可以行。0.1232.7160.02716$10^{-2}$

  2. 使用\small字体大小。这将要缩小表格。但是,根据实际内容,表格可能会变得更难阅读。

  3. 使用浮动环境table,将表格放在单独的页面上,并以横向格式排版。

如果这些可能性(或组合)都不适合您,您可以尝试强制 LaTeX 将表格突出到边距而不是右边距。在写这篇文章时,我发现 Werner 已经向你展示了如何做到这一点。

答案4

基于的解决方案tabularx,并进行游戏\arraycolsep显示表格的宽度可以恰好是文本宽度。我添加了siunitx包来格式化前四列中的数字。

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

在此处输入图片描述

相关内容