1

seems like an easy problem, but I'm really a newbie to LaTeX and cannot come up with solution even with some QAs on this forum I found. Can you please help? As the picture shows, the table is wider than the text column and collides with the other column. I understand the text in the table is too long, but is there a simple way to force the table to be same width as the text and wrap the text into two lines in the same table row without using different packages?enter image description here

\usepackage[table]{hypcap}
\begin{table}[ht]
    \centering
    \renewcommand{\arraystretch}{1.8}
    \begin{tabular}{c|c|c|l}
        Parameter & Value & Units & Description\\
\toprule \midrule
        E & 200 & GPa & Young's modulus\\
        $f_{c}$ & 30 & MPa & Ultimate compressive strength\\
        $\varepsilon_{t0}$ & 805 $\cdot 10^{-4}$ & - & Initial threshold of damage for $\varepsilon_t$\\ 
\hline
    \end{tabular}
    \caption{a}
\end{table}
2
  • Use a table* environment. Can you provide some feedback on what happens?
    – Werner
    Mar 2, 2023 at 22:24
  • 1
    @Werner yes, i have tried that, but the table* environment expands the table along full page width, not respecting the text columns.
    – MadyDollar
    Mar 3, 2023 at 21:55

2 Answers 2

0

Without a different package, I don't know how to do this automatically (but I have added the missing package booktabs from your code in order to use the \toprule and \midrule from your code).

You could use the p{<length>} column specification to give to your last column a width. You need to find the value for the length with trials and errors (in this code, I have expand the size from 2cm until I obtain a overfull hbox warning; in this particular example, I got a warning with the value 2.5cm, but not with the value 2.49cm).

I have removed the hypcap package, not relevant here, and added lipsum for filling the page with text.

In this code, I have also added explicitly the letterpaper paper format in the document class, because the value to use for the type p column depend on the width of the page, and by default for some Europeans users, it's the a4paper format when no paper format is explicitly given.

\documentclass[10pt,twocolumn]{article}
\usepackage{lipsum}
\usepackage{booktabs}
\begin{document}
\lipsum[1-7]

\begin{table}[ht]
    \centering
    \renewcommand{\arraystretch}{1.8}
    \begin{tabular}{c|c|c|p{2.49cm}}
        Parameter & Value & Units & Description\\
\toprule \midrule
        E & 200 & GPa & Young's modulus\\
        $f_{c}$ & 30 & MPa & Ultimate compressive strength\\
        $\varepsilon_{t0}$ & 805 $\cdot 10^{-4}$ & - & Initial threshold of damage for $\varepsilon_t$\\ 
\hline
    \end{tabular}
    \caption{a}
\end{table}

\lipsum[8-14]
\end{document}

With the original {c|c|c|l} tabular specification: enter image description here

With the {c|c|c|p{2.49cm}} tabular specification: enter image description here

1
  • Thank you so much, exactly what I was looking for. :)
    – MadyDollar
    Mar 3, 2023 at 21:53
0
  • Welcome to TeX:SE!
  • Please, next time instead code fragment provide MWE (Minimal Working Example). Now we had to guessing about document class and (by it) defined page layout. Both influence on table formatting
  • For your table I would emplox tabularray package with libraries/packages booktabs, siunitx and ragged2e:
\documentclass[twocolumn]{article}
\usepackage{lipsum}

\usepackage{ragged2e}
\usepackage{xcolor}
\usepackage{tabularray}
\UseTblrLibrary{booktabs, siunitx}

\begin{document}
\lipsum[1]

    \begin{table}[ht]
\begin{tblr}{
             colsep=3pt,
             colspec={@{} c Q[c,si={table-format=3.0}] Q[c,si] X[j, appto=\RaggedRight] @{}},
             cell{3-Z}{1} = {mode=math},
             cell{1,Z}{2,3}  = {guard}
             }
    \toprule
Parameter   & Value & Units & Description\\
    \midrule
E           & 200   & \unit{\giga\pascal} 
                            & Young's modulus\\
f_{c}       & 30    & \unit{\mega\pascal} 
                            & Ultimate compressive strength\\
\varepsilon_{t_0}
            & \num{805E-4}
                    & --    & Initial threshold of damage for $\varepsilon_t$   \\
    \bottomrule
\end{tblr}
\caption{a}
\label{tab:?}
    \end{table}
\lipsum[2-6]
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .