4

How do I make two tables with different the same size?

Picture showing the problem

Here is my code:

\begin{table}[]
\resizebox{\columnwidth}{!}{%
\begin{tabular}{ccccc}
\hline
\multicolumn{5}{|c|}{\cellcolor[HTML]{EFEFEF}\textbf{Summary of glioblastoma qualitative radiogenomic results}}                                                                                                                                           \\ \hline
\multicolumn{1}{|c|}{\textbf{Reference}} & \multicolumn{1}{c|}{\textbf{Year}} & \multicolumn{1}{c|}{\textbf{Gene}} & \multicolumn{1}{c|}{\textbf{Method}} & \multicolumn{1}{c|}{\textbf{Qualitative features associated with gene mutations}} \\ \hline
\cite{carillo_table}                                        & 2012                               & IDH1                               & Logistic Regression                  & Frontal lobe, les enhancement, smaller size                                       \\
\cite{paldor_table}                                        & 2016                               & IDH1                               & Chi-square test                      & Frontal Lobe                                                                      \\
\cite{aghi_table}                                        & 2005                               & EGFR                               & Student t-test                       & Increased edema-enhancing tumor ratio; ill-defined T2 margins                     \\ \cite{ellingson_table}
                                         & 2013                              & EGFR                               & Fisher's exact test                  & Left temporal lobe                                                                \\  \cite{young_table} 
                                         & 2013                             & EGFR                               & Wilcoxon signed-rank test            & Lower ADC                                                                         \\ \cite{gupta_table}
                                         & 2015                               & EGFR                               & Wilcoxon signed-rank test            & Increased cerebral blood volume, decreased peak signal recovery                                                       
\end{tabular}
}%
\caption{Radiogenomics studies carried out on glioblastoma that have studied the association between \textit{qualitative} imaging features and gene mutations in IDH and EGFR; source: Chow et. al (2017)\cite{imaging_hetero}}
\label{table:qualitative}
\end{table}

and

\begin{table}[]
\begin{tabular}{cccccc}
\hline
\multicolumn{6}{|c|}{\cellcolor[HTML]{EFEFEF}Summary of glioblastoma quantitative radiogenomic results}                                                                                            \\ \hline
\multicolumn{1}{|c|}{Refrence} & \multicolumn{1}{c|}{Year} & \multicolumn{1}{c|}{Gene} & \multicolumn{1}{c|}{Radiomics features} & \multicolumn{1}{c|}{Classifier} & \multicolumn{1}{c|}{Accuracy} \\ \hline
\cite{zhang_table}                              & 2017                      & IDH1                      & FOS, SOS                                & Random Forest                   & 0.89                          \\
\cite{levner_table}                              & 2009                      & MGMT                      & SOS                                     & Neural Network                  & 0.877                         \\
\cite{korfiatis_table}                              & 2016                      & MGMT                      & SOS                                     & SVM, Random Forest              &                               \\
\cite{kickingereder_table}                              & 2016                      & EGFR                      &      FOS                                   &                                 & 0.63                          \\
\multicolumn{1}{l}{}           & \multicolumn{1}{l}{}      & \multicolumn{1}{l}{}      & \multicolumn{1}{l}{}                    & \multicolumn{1}{l}{}            & \multicolumn{1}{l}{}         
\end{tabular}
\caption{Radiogenomics studies carried out on glioblastoma that have studied the association between \textit{quantitative} imaging features and gene mutations; source: Chow et. al (2017)\cite{imaging_hetero} }
\label{table:quantitative}
\end{table}

I tried solving it with \adjustbox but this didn't help

5
  • Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}.
    – Skillmon
    Jul 31, 2018 at 13:32
  • 1
    Don't resize a tabular using stuff like \resizebox, it leads to inconsistent font sizes. Instead you could refactor your tabulars to not extend the margins, or use \small to slightly reduce the font size in a good manner.
    – Skillmon
    Jul 31, 2018 at 13:34
  • Refactoring could be done with the help of tabularx: use \begin{tabularx}{\linewidth}{ccclX} instead of your \begin{tabular} for the first table. And you shouldn't use c columns for everything. Stuff containing labels or years might look good this way, but columns containing text (even if only few words like your Method or Classifier column) should be set using l or if it contains much text p or X (the latter if tabularx is used).
    – Skillmon
    Jul 31, 2018 at 13:37
  • And don't use vertical rules, ever.
    – Skillmon
    Jul 31, 2018 at 13:38
  • Two tables with different what?
    – Bernard
    Jul 31, 2018 at 14:11

2 Answers 2

7

I would build your tables more like the ones below. I removed the first head row as it seems redundant to the \caption.

\documentclass[]{article}

\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{siunitx}

\newcolumntype{x}[1]{>{\hsize=#1\hsize\linewidth=\hsize}X}

\begin{document}
\begingroup
\small
\noindent
\tabcolsep=.7\tabcolsep
\begin{tabularx}{\linewidth}{ccc>{\raggedright\arraybackslash}x{.7}x{1.3}}
  \toprule
  Reference & Year & Gene & Method
    & Qualitative features associated with gene mutations \\
  \midrule
  \cite{carillo_table}   & 2012 & IDH1 & Logistic Regression
    & Frontal lobe, les enhancement, smaller size \\
  \cite{paldor_table}    & 2016 & IDH1 & Chi-square test
    & Frontal Lobe \\
  \cite{aghi_table}      & 2005 & EGFR & Student t-test 
    & Increased edema-enhancing tumor ratio; ill-defined T2 margins \\
  \cite{ellingson_table} & 2013 & EGFR & Fisher's exact test
    & Left temporal lobe \\  
  \cite{young_table}     & 2013 & EGFR & Wilcoxon signed-rank test
    & Lower ADC \\
  \cite{gupta_table}     & 2015 & EGFR & Wilcoxon signed-rank test
    & Increased cerebral blood volume, decreased peak signal recovery \\
  \bottomrule
\end{tabularx}
\begin{tabular}{cccclS[table-format=1.3]}
  \toprule
  Reference & Year & Gene & Radiomics features & Classifier & {Accuracy} \\
  \midrule
  \cite{zhang_table}         & 2017 & IDH1 & FOS, SOS & Random Forest
    & 0.89 \\
  \cite{levner_table}        & 2009 & MGMT & SOS      & Neural Network
    & 0.877 \\
  \cite{korfiatis_table}     & 2016 & MGMT & SOS      & SVM, Random Forest
    & \\
  \cite{kickingereder_table} & 2016 & EGFR & FOS      &
    & 0.63 \\
  \bottomrule
\end{tabular}
\endgroup
\end{document}

enter image description here

As you can see, the second tabular is slightly smaller. I also left out the table environment, but that shouldn't change much. \tabcolsep=.7\tabcolsep reduces the separation between the columns to 70 %. The \noindent is not necessary inside of table. If the two tabulars end up in different table environments, you should use \small and \tabcolsep=.7\tabcolsep in both of them.

EDIT: One should mention, that the sum of all arguments to the x columns in one tabularx must total the number of x columns in that tabularx. So if you use 2 x columns, the sum must be 2.

6

slightly modified nice Skillmon's answer:

enter image description here

main differences are:

  • both table use tabularx environment
  • the first three columns use the same definition for columns type
  • tablecolsep is determined on more "latex"/usual way by \setlength
  • X column determined by tabularx is redefined more concise and common for all use in tables
  • differences are in code indicated by %<---

mwe:

\documentclass[]{article}

\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{siunitx}
\usepackage{ragged2e}  % <--- new

\newcolumntype{L}[1]{>{\hsize=#1\linewidth\raggedright\arraybackslash}X} % <--- changed

\begin{document}
\begingroup
\small
\setlength\tabcolsep{3pt} % <--- changed
\noindent
\begin{tabularx}{\linewidth}{cc>{\centering}p{4em}L{.7}L{1.3}}  % <--- changed
  \toprule
  Reference & Year & Gene & Method
    & Qualitative features associated with gene mutations \\
  \midrule
  \cite{carillo_table}   & 2012 & IDH1 & Logistic Regression
    & Frontal lobe, les enhancement, smaller size \\
  \cite{paldor_table}    & 2016 & IDH1 & Chi-square test
    & Frontal Lobe \\
  \cite{aghi_table}      & 2005 & EGFR & Student t-test
    & Increased edema-enhancing tumor ratio; ill-defined T2 margins \\
  \cite{ellingson_table} & 2013 & EGFR & Fisher's exact test
    & Left temporal lobe \\
  \cite{young_table}     & 2013 & EGFR & Wilcoxon signed-rank test
    & Lower ADC \\
  \cite{gupta_table}     & 2015 & EGFR & Wilcoxon signed-rank test
    & Increased cerebral blood volume, decreased peak signal recovery \\
  \bottomrule
\end{tabularx}
\begin{tabularx}{\linewidth}{cc>{\centering}p{4em}c L{1} S[table-format=1.3]}  % <--- changed
  \toprule
  Reference & Year & Gene & Radiomics features & Classifier & {Accuracy} \\
  \midrule
  \cite{zhang_table}         & 2017 & IDH1 & FOS, SOS & Random Forest
    & 0.89 \\
  \cite{levner_table}        & 2009 & MGMT & SOS      & Neural Network
    & 0.877 \\
  \cite{korfiatis_table}     & 2016 & MGMT & SOS      & SVM, Random Forest
    & \\
  \cite{kickingereder_table} & 2016 & EGFR & FOS      &
    & 0.63 \\
  \bottomrule
\end{tabularx}
\endgroup
\end{document}
4
  • +1. It would be helpful, I think, if you provided a sentence or two to note how your answer differs from @Skillmon's.
    – Mico
    Jul 31, 2018 at 15:50
  • @Mico, it is indicated in code by % <---. this is for me simpler than my tourture of english language :-). i will give my best to add some comments asap.
    – Zarko
    Jul 31, 2018 at 15:55
  • 1
    @Mico, done ...
    – Zarko
    Jul 31, 2018 at 16:03
  • Nice modifications (though I liked my x as a more general column specifier than your L). Note that you should set \linewidth in L, so a better definition would be the one I provided plus \raggedright\arraybackslash (see section 4.3 of the tabularx documentation).
    – Skillmon
    Jul 31, 2018 at 16:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.