1

I have been trying to put a table in a multicolumn document. But it's being compressed vertically. Not sure what i am doing wrong... enter image description here

Below is the code I have to put the table:

\begin{table}[h!]
\centering
\resizebox{\columnwidth}{!}{
\begin{tabular}{|| p{1cm} | c | c ||} 
\hline
Question & Explanation \\ [0.5ex] 
\hline\hline
1 & ... \\
2 & ... \\
3 & ... \\
4 & ... \\
5 & ... \\
6 & ... \\ [1ex] 
\hline
\end{tabular}
}
\caption{Table Showing the Questions for Visualisations with their 
Explanations}
\label{table:questions}
\end{table}

Please note that the "..." in the code are actually long sentences.

Any help is much appreciated.

  • 3
    don't scale tables \resizebox{\columnwidth}{!}{ otherwise you get bad results, as you show. – David Carlisle Sep 16 '18 at 17:30
  • 2
    welcome to tex.se! cause of you problem is use of \resizebox. to prove this suspiction, pleas extend your code sniped to small but complete document with your table. with your code snippet is not possible to reproduce your proble,. btw, you define three columns but use only two ... – Zarko Sep 16 '18 at 17:30
0

You need to use column types that allow line-breaking for columns 2 and 3. I suggest you load the tabularx package and use (suitably modified versions of the) X column type. Oh, and don't use \resizebox -- it's virtually guaranteed not to deliver what you're trying to obtain.

enter image description here

\documentclass[twocolumn]{article}
\usepackage{tabularx,ragged2e,booktabs,lipsum}
\newcolumntype{L}{>{\RaggedRight\arraybackslash\hspace{0pt}}X}
\begin{document}
\begin{table}[ht!]
\begin{tabularx}{\columnwidth}{@{}lLL@{}} 
\toprule
\multicolumn{2}{@{}l}{Question} & Explanation \\ 
\midrule
1 & \dots & \dots  \\
2 & \dots & \dots  \\
3 & \dots & \dots  \\
4 & \dots & \dots  \\
5 & \dots & \dots  \\
6 & \dots & \dots  \\
\bottomrule
\end{tabularx}
\caption{Table Showing the Questions for 
   Visualisations with their Explanations}
\label{table:questions}
\end{table}
\lipsum[1-8] % some paragraphs of filler text
\end{document}
0

you are using c columns which force the text on one long line, and then scaling the entire table to use an unreadably small font (never use \resizebbox with tables). Instead specify reasonable column widths to allow line breaking within the cells. Also don't use [h!] usually latex warns and changes it to [ht] but including p makes it more likely that the table can be positioned.

so replace

\begin{table}[h!]
\centering
\resizebox{\columnwidth}{!}{
\begin{tabular}{|| p{1cm} | c | c ||} 

by

\begin{table}[htbp]
\centering
\begin{tabular}{|| p{1cm} | p{4cm} | p{6cm} ||} % or whatever widths you need
  • 1
    from table code sniped i see that op from three defined columns use only two :-) and he use two column document so table had to narrower than column width. actually this is not clear so i asked op to provide mwe ... – Zarko Sep 16 '18 at 18:18

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.