2

I have checked all over the web but I'm trying to autofit column in table based on content. From below:

enter image description here

to:

enter image description here

The code is:

\documentclass[conference]{IEEEtran}
\IEEEoverridecommandlockouts
\usepackage{booktabs, tabularx}
\usepackage{textcomp}
\usepackage{xcolor}
\usepackage{multirow}
\usepackage[utf8]{inputenc}

\begin{document}

\maketitle

\section{Introduction}
\begin{table}[htbp]
\caption{Query list for the word 'wooden' at the start of the game and 
 during the game}
\begin{tabular}{|c|c|c|}
\hline
\textbf{Generation No.}&{\textbf{The noun which is being queried}}& {\textbf{Nearest Neighbor using analogy function}} \\
\hline
0  (Start of the game) & \multirow{2}{*}{wooden} & ['get_VBP', 'reply_VBP', 'repaint_VB', 
'publicity_NN', 'of_IN', 'adorn_VB', 'hands_VBZ', 'stiffen_VB', 'has_VBZ', 
'before_IN', 'solve_VB', 'west_JJS', 'are_VBP', 'hoist_VB', 'decorate_VB', 
'he_PRP', 'you_PRP', 'want_VBP', 'to_TO', 'bad_JJ', 'erect_VB', 'once_RB', 
'go_VB', 'buckle_VB', 'read_VBN', 'sheet_NN', 'it_PRP', 'carrying_VBG', 
'have_VBP', 'pound_VB']\\ \cline{2}
\hline

100 & & ['reply_VBP', 'stiffen_VB', 'before_IN', 'i_PRP', 'adorn_VB', 
'repaint_VB', 'any_DT', 'erect_VB', 'lift_VB', 'in_IN', 'publicity_NN', 
'decorate_VB', 'paper_NN', 'or_CC', 'he_PRP', 'drape_VB', 'once_RB', 
'fbi_NNP', 'go_VB', 'weld_VB', 'buckle_VB', 'come_VB', 'west_JJS', 
'are_VBP', 
'hoist_VB', 'fasten_VB', 'you_PRP', 'to_TO', 'bad_JJ', 'pound_VB'] \\
\hline
\end{tabular}
\label{tab1}
\end{table}

\end{document}
  • 2
    welcome to tex.se! please not insert image of code but copy code from your editor to here (that we can copy to our editors and test it). code should be complete document with preamble, where you define columns type. as fa as can see now, problem is in definition of column types. please help us to help you – Zarko Oct 10 '18 at 6:49
  • @Zarko i have edited the question. – djack Oct 10 '18 at 8:44
  • @djack the provided code should be complete so that we can copy&paste it in our editor and being able to compile it. You should therefore include the whole document including the documentclass, all loaded packages and the complete document-environment. – Raven Oct 10 '18 at 9:02
  • And another question: Am I understanding you correctly that you want the table to overflow the page border instead of wrapping around? – Raven Oct 10 '18 at 9:02
  • @djack, i ask you for complete (small) document with your table (beginning with \documentclas and ending with \end{document}. problems seems to lay on preamble, where you define columns type. beside this, your table has errors and as such can not be compiled. please provide complete code, by which you generate showed image. – Zarko Oct 10 '18 at 9:14
3
  • for table environment i suggest to use tabularx environment. it allows you to break text into multiple lines
  • used fonts haven't bold face shapes
  • table can be in one column and positioned nearby where is inserted:

enter image description here

or span over two columns on the top of the next page where is inserted

enter image description here

  • for more vertical space around text in cells is used macro \makegapedcells from the package makecell

    \documentclass[conference]{IEEEtran}
    \IEEEoverridecommandlockouts
    \usepackage{booktabs, makecell, multirow, tabularx}
    \newcolumntype{L}{>{\raggedright\arraybackslash}X}
    \usepackage{textcomp}
    \usepackage{xcolor}
    \usepackage[utf8]{inputenc}
    
    \usepackage{lipsum}
    
    \begin{document}
        \lipsum[1]
    \begin{table}[htbp]
    \caption{Query list for the word 'wooden' at the start of the game and
     during the game}
        \setlength{\tabcolsep}{2pt}
        \setcellgapes{3pt}\makegapedcells
    \begin{tabularx}{\linewidth}{|*{2}{>{\hsize=0.21\hsize}L|}
                                       >{\hsize=0.58\hsize}L|}
        \hline
    Generation No.
        &   The noun which is being queried
            &   Nearest Neighbor using analogy function        \\
        \hline
    0  (Start of the game)
        &   wooden
            &   ['get\_VBP', 'reply\_VBP', 'repaint\_VB',
                 'publicity\_NN', 'of\_IN', 'adorn\_VB', 'hands\_VBZ', 'stiffen\_VB', 'has\_VBZ',
                 'before\_IN', 'solve\_VB', 'west\_JJS', 'are\_VBP', 'hoist\_VB', 'decorate\_VB',
                 'he\_PRP', 'you\_PRP', 'want\_VBP', 'to\_TO', 'bad\_JJ', 'erect\_VB', 'once\_RB',
                 'go\_VB', 'buckle\_VB', 'read\_VBN', 'sheet\_NN', 'it\_PRP', 'carrying\_VBG',
                 'have\_VBP', 'pound\_VB']                                \\
        \cline{1-3}
    100 &   &   ['reply\_VBP', 'stiffen\_VB', 'before\_IN', 'i\_PRP', 'adorn\_VB',
                 'repaint\_VB', 'any\_DT', 'erect\_VB', 'lift\_VB', 'in\_IN', 'publicity\_NN',
                 'decorate\_VB', 'paper\_NN', 'or\_CC', 'he\_PRP', 'drape\_VB', 'once\_RB',
                 'fbi\_NNP', 'go\_VB', 'weld\_VB', 'buckle\_VB', 'come\_VB', 'west\_JJS',
                 'are\_VBP', 'hoist\_VB', 'fasten\_VB', 'you\_PRP', 'to\_TO', 'bad\_JJ',
                 'pound\_VB']                                            \\
        \hline
    \end{tabularx}
    \label{tab1}
    \end{table}
        \lipsum[2]
    \begin{table*}[htbp]
    \caption{Query list for the word 'wooden' at the start of the game and
     during the game}
        \setcellgapes{3pt}\makegapedcells
    \begin{tabularx}{\linewidth}{|*{2}{>{\hsize=0.15\hsize}L|}
                                       >{\hsize=0.70\hsize}L|}
        \hline
    Generation No.
        &   The noun which is being queried
            &   Nearest Neighbor using analogy function        \\
        \hline
    0  (Start of the game)
        &   wooden
            &   ['get\_VBP', 'reply\_VBP', 'repaint\_VB',
                 'publicity\_NN', 'of\_IN', 'adorn\_VB', 'hands\_VBZ', 'stiffen\_VB', 'has\_VBZ',
                 'before\_IN', 'solve\_VB', 'west\_JJS', 'are\_VBP', 'hoist\_VB', 'decorate\_VB',
                 'he\_PRP', 'you\_PRP', 'want\_VBP', 'to\_TO', 'bad\_JJ', 'erect\_VB', 'once\_RB',
                 'go\_VB', 'buckle\_VB', 'read\_VBN', 'sheet\_NN', 'it\_PRP', 'carrying\_VBG',
                 'have\_VBP', 'pound\_VB']                                \\
        \cline{1-3}
    100 &   &   ['reply\_VBP', 'stiffen\_VB', 'before\_IN', 'i\_PRP', 'adorn\_VB',
                 'repaint\_VB', 'any\_DT', 'erect\_VB', 'lift\_VB', 'in\_IN', 
    
  • thx. it worked well! – djack Oct 10 '18 at 13:34

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.