LaTeX 表格超出了指定的文本区域

LaTeX 表格超出了指定的文本区域

我的论文要求文本区域的尺寸为 150mm x 220mm,我在序言中设置了该尺寸\usepackage[a4paper, total={150mm, 220mm}]{geometry},这似乎对文本来说没问题,但对表格来说却不行。表格是左对齐的,最终位于文本的左侧,因此超出了指定的文本区域。我该如何纠正这个问题,使表格保持左对齐,但位于文本区域内?

我使用的代码如下所示:

\documentclass[12pt, a4paper]{article} 
\usepackage[english]{babel}

\usepackage{natbib}
\setcitestyle{authoryear,open={(},close={)}}

\usepackage{longtable}
\usepackage{caption}
\usepackage{subcaption}

\usepackage[a4paper, total={150mm, 220mm}]{geometry}


\usepackage{fullpage}
\usepackage{mathtools}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{float}
\usepackage{booktabs}
\usepackage{listings}
\usepackage{amsthm}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{xfrac}
\usepackage{csquotes}
\usepackage{epigraph}
\usepackage[super]{nth}
\usepackage{mdframed}
\usepackage{dirtytalk}

\usepackage{wrapfig}
\usepackage{subcaption}

\captionsetup[table]{singlelinecheck=off}

\usepackage{float}
\floatstyle{plaintop}
\restylefloat{table}
\usepackage{array}

\usepackage[font=small,labelfont=bf]{caption}

\usepackage{tabularx}

\usepackage{setspace}
\doublespacing

\usepackage{footmisc}
\renewcommand{\footnotesize}{}
\renewcommand{\footnotelayout}{\doublespacing}
\usepackage{lipsum}

\begin{document}
\lipsum[2-4]
\begingroup
 \renewcommand{\arraystretch}{1.5}
\begin{table}[H]
\small
\begin{tabular}{l c c c c}         
    \hline
          & \textbf{2 year} & \textbf{10 year} & \textbf{20 year} & \textbf{30 year} \\
         \hline\hline
         Canada & 0.123 & 0.549 & 0.641 & 0.671 \\
         Euro Area & 0.126 & 0.594 & 0.701 & 0.736 \\
         United Kingdom & 0.033 & 0.292 & 0.417 & 0.469 \\ [1ex]
        \hline
    \end{tabular}
    \caption{Theta Values}
    \label{tab:theta}
\end{table}
    \endgroup
\lipsum[2-4]
\end{document}

它看起来是这样的:

在此处输入图片描述

谢谢你的帮助!

答案1

您只需将表格中的字体大小缩小\small\footnotesize。在这种情况下还建议稍微调整列规格至{c >{$}X[c,m,wd=0.44\linewidth]<{$} *{3}{X[1,l,m]}},

在此处输入图片描述

完成 MWE:

\documentclass[12pt]{article}
\usepackage[a4paper, 
            total={150mm, 220mm},
            ]{geometry}  % <---
\usepackage{amssymb,
            mathtools}  % enhanced amsmath
% fonts
\usepackage{newtxtext, newtxmath}
\usepackage{upgreek}
\usepackage{bm}% bold math
% tables
\usepackage{rotating}   % new
\usepackage{makecell}   % new
\usepackage{tabularray} % new
\UseTblrLibrary{varwidth}
%\SetTblrInner{measure=box}
%
\usepackage{enumitem}
\usepackage{etoolbox}   % new
\AtBeginEnvironment{table}{%
\setlist[itemize]{nosep,
    leftmargin=*,
    label=\textbullet,
    before={\begin{minipage}[t]{\hsize}},
    after ={\end{minipage}}
                  }
                            }% end of \AtBeginEnvironment

\usepackage[skip=1ex,
            font=footnotesize,
            labelfont=bf]{caption}
\usepackage[dvipsnames]{xcolor}
%\usepackage{setspace}

\usepackage{lipsum}

\begin{document}
\lipsum[66]
    \begin{table}[ht]
\caption{Summary of bottom-up parameterizations techniques used for polymer coarse-graining.}
\label{T:Summary}
    \footnotesize
\settowidth\rotheadsize{ Tomfoolery }   % from makecell
\begin{tblr}{hlines, vlines,
             colspec = {c >{$}
             X[c,m,wd=0.44\linewidth]<{$} % <---
             *{3}{X[1,l,m]}},  % <---
             colsep  = 3pt,
             rowsep  = 3pt,
             column{1}  = {cmd=\rotcell, font=\bfseries}, % <----
             row{1} = {font=\bfseries},
            }
    \cline{2-5}
\multicolumn{1}{c}{}
    &   \text{Key Equation(s)}
        &   Key Inputs
            &   Advantages
                &   Dis\- advantages        \\
Relative Tomfoolery
    &   \begin{multlined}
    T_{\rm rel} = \beta \left\langle A_\text{GG} - B_\text{FF}\right\rangle_\text{FF} \\
                        -\beta(A_\text{GG} - A_\text{GG}) + \langle T_{\rm map} \rangle  _{AA}
        \end{multlined}
        &   \begin{itemize}
        \item \ldots
        \item \ldots
            \end{itemize}
            &   \begin{itemize}
            \item \ldots
            \item \ldots
                \end{itemize}
                &   \begin{itemize}
                \item Sensitive optimization
                    \end{itemize}       \\
Integral Liquation Fine-Dinin
    &   \begin{aligned}
    \hat{a}_{ee}(k)
       & =  \frac{n_b^2 \hat{q}_{mm}(0) \bigl[\hat{\mu}_{bm}(k) \bigr]^2}
                  {1 + v_{m}\rho_{m} \hat{\lambda}_{mm}(0) \hat{\zeta}_{mm}(k)} \\
    \hat{\nu}_{bb}(k)
       &  = \frac{\hat{j}_{bb}(k)}
                  {n_{b} \hat{\zeta}_{bh}(k)
                    \bigl[n_{b} \hat{\omega}_{bb}(k) + \rho_{b} \hat{y}_{bb}(k) \bigr] }
        \end{aligned}
        &   \begin{itemize}
        \item \ldots
        \item \ldots
            \end{itemize}
            &   \begin{itemize}
            \item \ldots
            \item \ldots
                \end{itemize}
                &   \begin{itemize}
            \item \ldots
            \item \ldots
                    \end{itemize}       \\
\end{tblr}
    \end{table}
\lipsum[11]
\end{document}

与您的相比,上述 MWE 中的所有变化均以 标记<---

相关内容