LaTex 表格超出页面宽度

LaTex 表格超出页面宽度

我的表格太宽,超出了右侧页面的范围,我尝试使用 tabularx,但遇到了同样的问题。当我使用此命令 \resizebox{\textwidth}{!}{} 时,它修复了这个问题,但在使用命令 \resizebox{\textwidth}{!}{} 之前它看起来很小

在此处输入图片描述

在命令 \resizebox{\textwidth}{!}{} 之后 在此处输入图片描述

代码

\begin{table}[H]
\centering
    \caption{Differences between the IGA and FEA.
        \label{tabLabel}}
  \resizebox{\textwidth}{!}
  {
\begin{tabular}{lll}
\hline Feature & Finite element analysis & Isogeometric analysis \\
\hline Geometry & Not available & Represented by control points \\
Mesh & Defined by nodal points & Defined by knot spans \\
Mesh & Approximates geometry & Represents exact geometry \\
Solution & Defined by nodal variables & Defined by control variables \\
Basis & Formed by polynomials & Formed by NURBS functions \\
Basis & Interpolates nodal points and variables & Does not interpolate control points and variables \\
Basis & Satisfies Kronecker delta property & Does not satisfy Kronecker delta property \\
Basis support & Over a patch of elements sharing a common node & Over a rectangular array of knot spans size of which depends on continuity of the basis \\
Dirichlet BC & Straightforward & Approximated within NURBS space \\
\hline
\end{tabular}
}
\end{table}

答案1

  1. 永远不要\resizebox在表格中使用较小的字体,就像\footnotesize在表格之前一样。原因是你不希望表格的字体大小与文本或其他表格不匹配,也不希望每个表格的字体粗细规则不同。太丑了。

  2. 使用该包booktabs获得更好的水平规则(参见 MWE)。

  3. 永远不要用 来固定绝对位置[H],除非是在最终稿中。相反,在文本中始终使用交叉引用(例如 table \ref{tabLabel} in page \pageref{tabLabel})。使用hyperref此包,相关引用将成为表格和打印页面的链接,因此浮动移动到下一页甚至更多页实际上并不重要。考虑到这一点,请考虑甚至避免使用 [ h](小写)选项,因为表格在顶部和底部位置看起来总是比在文本中间好看。

  4. 您应该了解将宽l列更改为某些列类型(如p{0.2\linewidth}p{5cm}和某些其他列类型)的效果。运行texdoc array以获取更多信息。

  5. tabulary类似于的包tabularx允许您根据内容使用L 宽度不等的列(大写),在这种情况下可能会更方便。如果自动分配的列空间L不是您想要的,您可以混合Lp以重新分配空间。另请参阅包手册。请注意,与 tabularx 不同,全局宽度为最大宽度,而不是固定的,因此如果您将内容减少到足够少,表格将自动变窄,然后您应该在前面添加\centering

平均能量损失

\documentclass{article}
\usepackage{lipsum} % just for dummy text
\usepackage[colorlinks,linkcolor=blue]{hyperref}
\usepackage{tabulary,booktabs}
\setlength{\belowcaptionskip}{1ex}
\begin{document}
See the nice table{}  \ref{tabLabel} below. \lipsum[1][1-4] 

\begin{table}[hbp!]
\caption{Differences between the IGA and FEA. \label{tabLabel}}
\footnotesize    
\begin{tabulary}{\linewidth}{@{}lLL@{}}\toprule
Feature & Finite element analysis & Isogeometric analysis \\\midrule
Geometry & Not available & Represented by control points \\
Mesh & Defined by nodal points & Defined by knot spans \\
Mesh & Approximates geometry & Represents exact geometry \\
Solution & Defined by nodal variables & Defined by control variables \\
Basis & Formed by polynomials & Formed by NURBS functions \\
Basis & Interpolates nodal points and variables & Does not interpolate control points and variables \\
Basis & Satisfies Kronecker delta property & Does not satisfy Kronecker delta property \\
Basis support & Over a patch of elements sharing a common node & Over a rectangular array of knot spans size of which depends on continuity of the basis \\
Dirichlet BC & Straightforward & Approximated within NURBS space \\\bottomrule
\end{tabulary}
\end{table}

\lipsum[2]
\end{document}

答案2

tabularx应该能给你一个很好的解决方案。

\documentclass{article}
\usepackage{float}
\usepackage{tabularx}
\renewcommand{\tabularxcolumn}[1]{>{\raggedright\arraybackslash}p{#1}}

\begin{document}
\begin{table}[H]
\centering
    \caption{Differences between the IGA and FEA.
        \label{tabLabel}}
\begin{tabularx}{\textwidth}{lXX}
\hline Feature & Finite element analysis & Isogeometric analysis \\
\hline Geometry & Not available & Represented by control points \\
Mesh & Defined by nodal points & Defined by knot spans \\
Mesh & Approximates geometry & Represents exact geometry \\
Solution & Defined by nodal variables & Defined by control variables \\
Basis & Formed by polynomials & Formed by NURBS functions \\
Basis & Interpolates nodal points and variables & Does not interpolate control points and variables \\
Basis & Satisfies Kronecker delta property & Does not satisfy Kronecker delta property \\
Basis support & Over a patch of elements sharing a common node & Over a rectangular array of knot spans size of which depends on continuity of the basis \\
Dirichlet BC & Straightforward & Approximated within NURBS space \\
\hline
\end{tabularx}
\end{table}

\end{document}

在此处输入图片描述

相关内容