1

Hi fellow Stack Exchangers,

I am trying to create a table but the columns are all messed up with text from columns flowing onto adjacent columns and number being broken up over multiple rows.

Does anyone know the code I can use to make this automatic?

If you insert a space between Distributed: and the series of \cite commands, you'll allow LaTeX to insert a line break. The ? marks in the screenshot below arise because I can't resolve the \cite instructions. If need be, insert another space between some of the \cite commands in order to allow still another line break.

\documentclass{article}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{multirow}
\begin{document}

\begin{table}[htbp]\centering
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\caption{Spillover Effect onto Other Industries}\label{other industries}
\begin{tabularx}{\textwidth}{p{2cm}p{1.5cm}p{1.5cm}p{1.5cm}}
\hline\hline & \multicolumn{1}{c}{Baseline} & \multicolumn{2}{c}{Economic Slack} \\ \cmidrule{2-2} \cmidrule(lr){3-4}
 \multicolumn{1}{c}{Industries}                   &\multicolumn{1}{c}{Public Ed Construction (\$ millions)} &\multicolumn{1}{c}{Public Ed Construction (\$ millions)} &\multicolumn{1}{c}{Economic Slack Interaction}\\  
 \multirow{2}{*}{Agriculture, Forestry and Fishing}& 0.00539 & -0.0130 & 0.0231**\\ &(0.68)& (-1.04)& (2.41) \\ \multirow{2}{*}{Mining}& -0.0109* & -0.0292 & 0.0226\\ &(-2.36)&(-1.85)&(1.53) \\ \multirow{2}{*}{Manufacturing}& 0.0205 & 0.00547 & 0.0183\\&(1.43)&(0.30)& (1.71)\\ \multirow{2}{*}{Electricity, Gas, Water and Waste Services}& -0.00458* & -0.0137*** & 0.0115*\\&(-2.05)&(-4.38)& (2.07)\\ Wholesale Trade& -0.0125 & -0.0194 &  0.00875\\&(-1.52)&(-1.15)& (0.54)\\ \multirow{2}{*}{Retail Trade}& -0.0117 & -0.0170 & 0.00511 \\&(-1.00)& (-0.76)&(0.32) \\ \multirow{2}{*}{Accommodation and Food Services}& 0.00404 & 0.00193 & 0.00290\\&(1.28)&(0.17)& (0.23)\\ \multirow{2}{*}{Transport, Postal and Warehousing}& -0.00342 & 0.00612 & -0.0120\\&(-0.43)&(0.71)& (-1.45)\\ \multirow{2}{*}{Information Media and Telecommunications}& 0.00766 & 0.0126 & -0.00645\\&(1.82)&(1.88)& (-1.03)\\ \multirow{2}{*}{Financial and Insurance Services}& 0.00355 & 0.0160 & -0.0159\\&(1.20)&(1.41)& (-1.32)\\ \multirow{2}{*}{Rental, Hiring and Real Estate Services}& 0.00426 & 0.00165 &  0.00296 \\&(0.71)&(0.22) (0.53)\\ \multirow{2}{*}{Professional, Scientific and Technical Services}& -0.0009 & 0.0399** & -0.0517**\\&(-0.15)&(2.95)& (-2.52)\\ \multirow{2}{*}{Administrative and Support Services}& 0.00519* & -0.00109 & -0.0137\\&(1.92)&(-0.13)& (0.91)\\ \multirow{2}{*}{Public Administration and Safety}& -0.0110 & -0.000109 & -0.0200\\&(-1.50)&(-0.01)& (-1.55)\\ \multirow{2}{*}{Education and Training}& 0.00674 & 0.0227 &\\&(0.57)&(1.17)& -0.0311* \\ \multirow{2}{*}{Health Care and Social Assistance}& 0.00483 & 0.0298 & -0.0311*\\&(0.35)&(1.42)& (-1.25)\\ \multirow{2}{*}{Arts and Recreation Services}& 0.00415 & 0.00948* & -0.00687\\&(1.11)&(2.06)& (-1.37)\\ \multirow{2}{*}{Other Services}& -0.0129 & -0.0141 & 0.00166\\&(-1.76)&(-0.74)& (0.10)
\end{tabularx}
\end{table}
\end{document}
  • I've taken the liberty to make your MWE compilable. Apart from that, remove all the occurences of \multicolumn{1}{c}{} in the first column. Also, what's the purpose of using tabularx without any X type column? – leandriis May 23 at 9:56
  • @leandriis What do you mean by all the occurrences of \multicolumn{1}{c}{}, there is only one? Do you mean multirow? – Asaf Cohen May 23 at 10:02
  • Sorry, I meant "in the headr row" instead of the first column. You could also try to replace \multirow{2}{*} by \multirow{2}{=}. – leandriis May 23 at 10:04
2

Here is part of your table. The rest of the code can be adapted accordingly:

enter image description here

\documentclass{article}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{ragged2e}
\newcolumntype{C}{>{\Centering}X}
\begin{document}

\begin{table}[htbp]\centering
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\caption{Spillover Effect onto Other Industries}\label{other industries}
\begin{tabularx}{\textwidth}{p{4cm}CCC}
\toprule & \multicolumn{1}{c}{Baseline} & \multicolumn{2}{c}{Economic Slack} \\ \cmidrule{2-2} \cmidrule(lr){3-4}
 Industries                   &Public Ed Construction (\$ millions) & Public Ed Construction (\$ millions) &Economic Slack Interaction\\ 
 \midrule 
 \multirow{2}{=}{Agriculture, Forestry and Fishing}& 0.00539 & -0.0130 & 0.0231**\\ &(0.68)& (-1.04)& (2.41) \\ \addlinespace
Mining& -0.0109* & -0.0292 & 0.0226\\ &(-2.36)&(-1.85)&(1.53) \\ \addlinespace
Manufacturing& 0.0205 & 0.00547 & 0.0183\\&(1.43)&(0.30)& (1.71)\\ \addlinespace
\multirow{2}{=}{Electricity, Gas, Water and Waste Services}& -0.00458* & -0.0137*** & 0.0115*\\&(-2.05)&(-4.38)& (2.07)\\ \addlinespace
\end{tabularx}
\end{table}
\end{document}

Changes in comparison to the original:

  • Removed \multicolumn commands in the table header as they prevented automatic line breaks
  • Replaced \multirow{2}{*} by \multirow{2}{=} as the latter uses the declared width (4cm in this case) for the multirows as well.
  • Added some \addlinespace commands for increased readability
  • Used a new centered C type column that in based on tabularx's X type column for the data columns.
  • ...

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.