
我需要在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
主要問題是您的表格太大,並且會發生這種情況,因為對於您擁有的文字寬度,其中的數據太多:)因此,我看到解決該問題的不同可能性:
更改表格的格式。例如,您可以將這些對顯示在兩行上,而不是使用
(... , ...)
.或寫成.123
而不是0.123
,取決於您所在網域中使用的約定。另一種方法是使用不同的縮放單位,例如,2.716
而不是使用列標題中寫入的0.02716
因子。$10^{-2}$
同樣,這可能可行,也可能不可行。使用
\small
字體大小。這將要讓你的桌子變小。但是,根據您擁有的實際內容,它可能會變得更難以閱讀。使用浮動環境
table
,將表格放在單獨的頁面上並以橫向格式排版。
如果這些可能性(或它們的組合)都不適合您,您可以嘗試強制 LaTeX 讓表格突出到外邊距而不是右邊距。在寫這篇文章時,我可以看到維爾納已經向您展示瞭如何做到這一點。
答案4
基於tabularx
和的解決方案\arraycolsep
顯示表格可以恰好是 textwidth 寬。我添加了該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}