1

My table is too wide and is out of page on the right, I tried to use tabularx, but I had the same problem. when I use this command \resizebox{\textwidth}{!}{} it fix it but it look small before command \resizebox{\textwidth}{!}{}

enter image description here

after command \resizebox{\textwidth}{!}{} enter image description here

the code

\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}
farid1889
  • 13
  • 2
  • tabularx would help, but you also need to use X-column type. See, e.g. the example in section 2 of the tabularx manual. – cabohah Mar 26 '24 at 09:21
  • 1
    (1) Never use \resizebox with tables but a smaller font as \footnotesize before the tabular (2) Never fix absolutely positions with [H] and use (table \ref{tabLabel}) in text. (3) You should we aware of the effect of change the wide l columns with some like p{0.2\linewidth} or p{5cm}, and (4)See also the package tabulary that is similar to tabularx but allow to use L (uppercase) columns. – Fran Mar 26 '24 at 09:30

2 Answers2

2

tabularx should give you a good solution.

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

enter image description here

  • not help , this for thesis not article \documentclass[12pt,a4paper,oneside]{report} I use this parameter in the preamble %% Page layout '\usepackage[left=25mm,right=25mm,top=35mm,bottom=30mm]{geometry}' % Control the width the entire table '\usepackage{multirow} % Merged rows and columns' \usepackage{longtable} % Insert a very long table, \usepackage{booktabs} % To thicken table lines \usepackage{tabularx} \usepackage{float} \renewcommand{\tabularxcolumn}[1]{>\raggedright\arraybackslash}p{#1}} – farid1889 Mar 26 '24 at 09:49
  • 1
    This should work with report and your geometry the same. – Pieter van Oostrum Mar 26 '24 at 13:33
2
  1. Never ever use \resizebox with tables,but a smaller font as \footnotesize before the tabular. The reason is that you do not want a table with a font size that does not match with the text nor the other tables, nor different rules thickness in each tables. Just ugly.

  2. Use the package booktabs for nicer horizontal rules (see the MWE).

  3. Never fix absolutely positions with [H], except maybe in a very final draft. Instead, use always cross-references in text (e.g., table \ref{tabLabel} in page \pageref{tabLabel}). Using hyperref package this corr-references will become links to your table and the page where it really is printed, so really it does not matter if the float move to the next page or even more. Taking this into account, consider even avoid the option [h] (in lowercase) as tables always look nicer in top-bottom positions than in the middle of text.

  4. You should be aware of the effect of change the wide l columns with some like p{0.2\linewidth} or p{5cm} and some other column types. Run texdoc array for more information.

  5. The package tabulary, similar to tabularx allow you to use L columns (in uppercase) of unequal width according to the content, that in this case could be more convenient. In case that the automatic space distribution of L columns is not what you want exactly, you can mix L and p columns to redistribute the space. See also the package manual. Note that unlike in tabularx, the global width in a maximum width, not a fixed with, so if you reduce the content enough, the tabular will become narrower automatically and then you should add \centering before.

MWE

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

Fran
  • 80,769