2

New to latex so apologies if this has been asked, I haven't found this specific question on SO.

I have a table that I'm trying to fit into a 2 column page format. The actual link for the full packages on overleaf from the publisher is here, though I believe I added all the packages and document type. I'm using this website to generate my table. I learned from this SO that I need to add * to the table to make it fit the 2 column, however, one of my columns in my table is very long:

\documentclass[11pt,a4paper]{article}
\usepackage{times,latexsym}
\usepackage{url}
\usepackage[T1]{fontenc}

\usepackage{tacl2021v1}
% \setlength\titlebox{10cm} % <- for Option 2 below

%%%% Material in this block is specific to generating TACL instructions
\usepackage{xspace,mfirstuc,tabulary}
\newcommand{\dateOfLastUpdate}{Dec. 15, 2021}
\newcommand{\styleFileVersion}{tacl2021v1}

\newcommand{\ex}[1]{{\sf #1}}

\newif\iftaclinstructions
\taclinstructionsfalse % AUTHORS: do NOT set this to true
\iftaclinstructions
\renewcommand{\confidential}{}
\renewcommand{\anonsubtext}{(No author info supplied here, for consistency with
TACL-submission anonymization requirements)}
\newcommand{\instr}
\fi

%
\iftaclpubformat % this "if" is set by the choice of options
\newcommand{\taclpaper}{final version\xspace}
\newcommand{\taclpapers}{final versions\xspace}
\newcommand{\Taclpaper}{Final version\xspace}
\newcommand{\Taclpapers}{Final versions\xspace}
\newcommand{\TaclPapers}{Final Versions\xspace}
\else
\newcommand{\taclpaper}{submission\xspace}
\newcommand{\taclpapers}{{\taclpaper}s\xspace}
\newcommand{\Taclpaper}{Submission\xspace}
\newcommand{\Taclpapers}{{\Taclpaper}s\xspace}
\newcommand{\TaclPapers}{Submissions\xspace}
\fi

\begin{document}

\begin{table*}
\small
\begin{tabular}{ll}
\textbf{Name} & \textbf{Method} \\
Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference,  & Some method     \\
Reference,Reference & \\
& \\
& \\
& \\
& \\
& \\
& \\
& \\
& \\
& \\
& \\
& \\
& \\
& \\
& \\
\end{tabular}
\end{table*}

\fi

\end{document}

Following this SO I tried using \small but it didn't make it much better. One possible solution that I see would be to change how the text in the row look (instead of one long row be in multiple rows under one row). But I'm not sure how to do that or if that's the best / neatest approach.

8
  • Should the first column be a made a lot wider than the second, should both columns be equally wide, or should maybe some other schema apply? Please advise.
    – Mico
    Commented Aug 18, 2022 at 14:38
  • @Mico It doesn't matter as long as the table fit the page. I have several of these table where one or two of these columns are very long. So a general solution would be optimal.
    – Penguin
    Commented Aug 18, 2022 at 14:43
  • You could take a look at overleaf.com/learn/latex/Tables#Tables_with_fixed_length
    – Teepeemm
    Commented Aug 18, 2022 at 14:45
  • @Teepeemm I'm still looking but it seems interesting. It seems like this will require me to keep "playing" with the sizes for each column (change the cm values of \begin{tabular}{ | m{5em} | m{1cm}| m{1cm} | } ) until it fits the page. Are you familiar with a more general solution to just fit such table into the page as wide as possible (since I have several of these tables with different number of columns), or is it just generally true for LaTex that each table needs to be manually fit the page?
    – Penguin
    Commented Aug 18, 2022 at 14:51
  • @Penguin - Please see the answer I posted, which only requires you to specify *relative" column widths, not *absolute" column widths.
    – Mico
    Commented Aug 18, 2022 at 15:03

2 Answers 2

2

You can use tabularx.

\documentclass[twocolumn]{article}
\usepackage{tabularx}

\begin{document}

\begin{table*}
\begin{tabularx}{\linewidth}{Xl}
\textbf{Name} & \textbf{Method} \\
Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference,  & Some method     \\
Reference,Reference & \\
& \\
& \\
& \\
& \\
& \\
& \\
& \\
& \\
& \\
& \\
& \\
& \\
& \\
& \\
\end{tabularx}
\end{table*}

\end{document}

This will make the table span the two columns. If you want the table to be in one column, use table instead of table*.

enter image description here

enter image description here

3
  • I'm not sure if it's because the documentclass is different in my case (I just added the link for all the packages) but the table border seems to now disappear at the end of the 2 columns. Apologies for not adding the packages before, wasn't sure what information people will need!
    – Penguin
    Commented Aug 18, 2022 at 15:09
  • What table border? Commented Aug 20, 2022 at 6:38
  • Fixed it. Instead of X after linewidth I had "C"s, so the table was off. Thanks for the help, this works!
    – Penguin
    Commented Aug 20, 2022 at 14:52
2

I take it that it may be necessary to allow automatic line breaking in both columns, and not just in the column that contains more material. Here's a suggestion: Load the tabularx and ragged2e packages and define a new column type called, say, L that makes it simple to define desired relative column widths. In the example below, we have

\begin{tabularx}{\textwidth}{@{} L{1.6} L{0.4} @{}}

which means that (a) the tabular material spans the full width of the textblock and (b) the ratio of usable column widths is 1.6:0.4 = 4:1. The rule to observe is that the sum of the relative column widths (here: 1.6+0.4=2) must equal the number of columns of type L -- here: 2.

The following screenshot shows the resulting table, which is placed at the top of a page.

enter image description here

\documentclass[twocolumn]{article}
\usepackage{tabularx,ragged2e}
\newcolumntype{L}[1]{>{\RaggedRight\hsize=#1\hsize}X}
\usepackage{booktabs,lipsum}
\begin{document}

\lipsum[1] % a paragraph of filler text

\begin{table*}
\caption{A two-column table that spans the full width of the text block}
\begin{tabularx}{\textwidth}{@{} L{1.6} L{0.4} @{}}
\toprule
\textbf{Name} & \textbf{Method} \\
\midrule
Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference & Some method \\
\addlinespace
Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference & Some method \\
\bottomrule
\end{tabularx}
\end{table*}

\lipsum[2-11] % more filler text

\end{document}
1
  • Thanks for the help! I'm not sure if difference in the documentclass will matter but it did in the other commented's solution. I just added the link for all the packages. Apologies for not adding the packages before, wasn't sure what information people will need!
    – Penguin
    Commented Aug 18, 2022 at 15:10

You must log in to answer this question.

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