3

Is it possible to make the columns the same width without it being to complicated?

\begin{table}[h]
\centering
\label{my-label}
\begin{tabular}{@{}c|c@{}}
\toprule
\textbf{Injection Pressure {[}bar{]}} & \textbf{Time {[}s{]}} \\ \hline
1.0                                   & 120                   \\
1.5                                   & 120                   \\
2.0                                   & 90                    \\
2.5                                   & 90                    \\
3.0                                   & 90                    \\
4.0                                   & 60                    \\
5.0                                   & 60                    \\
6.0                                   & 60                    \\ \bottomrule
\end{tabular}
\caption{Various injection pressures and time setting}
\end{table}
campa
  • 31,130

3 Answers3

4

Depends on your definition of "too complicated". You can simply specify the width of the columns with p{5cm}. Or if you want them to be centred:

\documentclass{article}

\usepackage{booktabs}

\usepackage{array}
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}

\begin{document}

\begin{table}[h]
\centering
\begin{tabular}{@{}P{5cm}P{5cm}@{}}
\toprule
\textbf{Injection Pressure [bar]} & \textbf{Time {[}s{]}} \\ \hline
1.0                                   & 120                   \\
1.5                                   & 120                   \\
2.0                                   & 90                    \\
2.5                                   & 90                    \\
3.0                                   & 90                    \\
4.0                                   & 60                    \\
5.0                                   & 60                    \\
6.0                                   & 60                    \\ \bottomrule
\end{tabular}
\caption{Various injection pressures and time setting}
\label{my-label}
\end{table}

\end{document}

enter image description here

(based on How to center column values in a table?)

4

or by use of tabularx on "very complicated/sophisticated" way:

\documentclass{article}
    \usepackage{tabularx}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\newcommand\mcxl[1]{\multicolumn{1}{C|}{\bfseries #1}}
 \newcommand\mcx[1]{\multicolumn{1}{C }{\bfseries #1}}
    \usepackage{siunitx}

\begin{document}
    \begin{table}[h]
\centering
\renewcommand\arraystretch{1.2}
\begin{tabularx}{0.5\linewidth}{S[table-format=1.1] | S[table-format=3.0] }
    \hline
\mcxl{Injection\par Pressure [bar]}
            & \mcx{Time\par [s]}    \\  \hline
1.0         & 120                   \\
1.5         & 120                   \\
2.0         & 90                    \\
2.5         & 90                    \\
3.0         & 90                    \\
4.0         & 60                    \\
5.0         & 60                    \\
6.0         & 60                    \\  \hline
\end{tabularx}
\caption{Various injection pressures and time setting}
\label{my-label}
    \end{table}
\end{document}

enter image description here

Zarko
  • 296,517
4

Using siunitx you simply can set the S column width. I also loaded makecell for the common formatting of columnheads. The \thead (and \makecell, not used here) commmand allows for line breaks in their contents:

\documentclass{article}

\usepackage{makecell}
\renewcommand\theadfont{\normalsize\bfseries}
\usepackage{siunitx}

\begin{document}

\begin{table}[!htb]
  \centering\sisetup{table-number-alignment=center, table-column-width=3cm}
  \setlength\extrarowheight{2pt}
  \label{my-label}
  \begin{tabular}{S[table-format=1.1] | S[table-format=3.0] }
    \Xhline{1pt}
    {\thead{Injection \\ Pressure [bar]}} & {\thead{Time [s]}} \\
    \hline
    1.0 & 120 \\
    1.5 & 120 \\
    2.0 & 90 \\
    2.5 & 90 \\
    3.0 & 90 \\
    4.0 & 60 \\
    5.0 & 60 \\
    6.0 & 60 \\
    \Xhline{1pt}
  \end{tabular}
  \caption{Various injection pressures and time setting}
\end{table}

\end{document} 

enter image description here

Bernard
  • 271,350