2

I have a long variable name (first column, row three) in a table, is there a way I can separate the variable in two lines? This is my table:

% Tabla 6 test de tendencia paralela
\begin{table}[htbp]
\footnotesize
\begin{adjustwidth}{-1in}{-1in} %
\centering
\caption{Test de tendencia paralela}
\begin{tabular}{lccc}
\toprule
      & \multicolumn{1}{c}{(1)} & \multicolumn{1}{c}{(2)} & \multicolumn{1}{c}{(3)} \\
Variables & \multicolumn{1}{c}{Número de Operaciones NB} & \multicolumn{1}{c}{Desembolsos  PPML} & \multicolumn{1}{c}{Crédito Promedio PPML} \\
    \midrule
      & \multicolumn{1}{c}{} & \multicolumn{1}{c}{} & \multicolumn{1}{c}{} \\
Tratamiento & \multicolumn{1}{c}{0.09} & \multicolumn{1}{c}{-0.28} & \multicolumn{1}{c}{-0.13} \\
      & \multicolumn{1}{c}{(0.17)} & \multicolumn{1}{c}{(0.49)} & \multicolumn{1}{c}{(0.33)} \\
Distancia entre localidad y sucursal (Km) & \multicolumn{1}{c}{-0.75***} & \multicolumn{1}{c}{-3.60***} & \multicolumn{1}{c}{-1.69***} \\
      & \multicolumn{1}{c}{(0.18)} & \multicolumn{1}{c}{(1.01)} & \multicolumn{1}{c}{(0.46)} \\
Recaudación IVA (log) & \multicolumn{1}{c}{0.17} & \multicolumn{1}{c}{0.17} & \multicolumn{1}{c}{0.44**} \\
      & \multicolumn{1}{c}{(0.14)} & \multicolumn{1}{c}{(0.2)} & \multicolumn{1}{c}{(0.19)} \\
Tasa de desempleo & \multicolumn{1}{c}{-3.53} & \multicolumn{1}{c}{-2.97} & \multicolumn{1}{c}{3.3} \\
      & \multicolumn{1}{c}{(3.55)} & \multicolumn{1}{c}{(6.34)} & \multicolumn{1}{c}{(5.62)} \\
Crédito familias (log) & \multicolumn{1}{c}{-0.12} & \multicolumn{1}{c}{-0.40*} & \multicolumn{1}{c}{-0.41**} \\
      & \multicolumn{1}{c}{(0.09)} & \multicolumn{1}{c}{(0.24)} & \multicolumn{1}{c}{(0.19)} \\
Constante      & \multicolumn{1}{c}{} & \multicolumn{1}{c}{6.73***} & \multicolumn{1}{c}{3.19**} \\
                & \multicolumn{1}{c}{} & \multicolumn{1}{c}{(1.76)} & \multicolumn{1}{c}{(1.33)} \\
    \bottomrule
    \multicolumn{4}{l}{\textsuperscript{}\footnotesize{Período: septiembre 2011 a abril de 2012. Errores clúster a nivel de localidad. *** p<0.01, ** p<0.05, * p<0.1}}
\end{tabular}%
    \label{tab:paralela}%
\end{adjustwidth}
\end{table}%
4
  • 1
    What's the point of \multicolumn{1}{c}{...} for columns that already have column specifier c? Sep 10, 2015 at 14:11
  • I have no idea.... excel2latex generated this table, after using outreg2 in STATA
    – Uruguayo
    Sep 10, 2015 at 14:14
  • 1
    That's the reason why you always should rework tables that comes from Excel2LaTeX. It is a (good) point to start, but the given LaTeX code is terrible.
    – Mensch
    Sep 10, 2015 at 14:44
  • Actually, I did edit it a bit... added lines, alignment, caption
    – Uruguayo
    Sep 10, 2015 at 14:53

2 Answers 2

4

I think you should do the following:

  • Get rid of all \multicolumn{1}{c}{...} "wrappers"

  • Use a package, e.g., the dcolumn package, to align the numeric data in columns 2, 3, and 4 on the decimal markers

  • Use a tabularx environment, with width set to \textwidth, instead of tabular.

  • Use \addlinespace directives generously.

enter image description here

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}

\usepackage{booktabs,tabularx,ragged2e,dcolumn,caption} 
\newcolumntype{C}{>{\Centering\arraybackslash \hspace{0pt}}X}
\newcolumntype{d}[1]{D{.}{,}{#1}}
% handy shortcut macros
\newcommand\mc[1]{\multicolumn{1}{c}{#1}}
\newcommand\MC[1]{\multicolumn{1}{C}{#1}}

\begin{document}

\begin{table}
\small
\caption{Test de tendencia paralela} \label{tab:paralela}
\begin{tabularx}{\textwidth}{@{} l *{3}{d{2.4}} @{}}
\toprule
Variables & \mc{(1)} & \mc{(2)} & \mc{(3)} \\ 
          & \MC{Número de Operaciones NB} 
          & \MC{Desembolsos  PPML} 
          & \MC{Crédito Promedio PPML} \\
\midrule
\addlinespace
Tratamiento            & 0.09 & -0.28 & -0.13 \\
                       & (0.17) & (0.49) & (0.33) \\
\addlinespace
Distancia entre localidad & -0.75^{***} & -3.60^{***} & -1.69^{***} \\
\quad y sucursal (km)     & (0.18) & (1.01) & (0.46) \\
\addlinespace
Recaudación IVA (log)  & 0.17 & 0.17 & 0.44^{**} \\
                       & (0.14) & (0.2) & (0.19) \\
\addlinespace
Tasa de desempleo      & -3.53 & -2.97 & 3.3 \\
                       & (3.55) & (6.34) & (5.62) \\
\addlinespace
Crédito familias (log) & -0.12 & -0.40^{*} & -0.41^{**} \\
                       & (0.09) & (0.24) & (0.19) \\
\addlinespace
Constante              &  & 6.73^{***} & 3.19^{**} \\
                       &  & (1.76) & (1.33) \\
\bottomrule
\addlinespace
\multicolumn{4}{@{}l}{\footnotesize Período: septiembre 2011 a abril de 2012. Errores clúster a nivel de localidad.}\\
\multicolumn{4}{@{}l}{\footnotesize ${}^{***}\ p<0.01$; ${}^{**}\ p<0.05$; ${}^{*} p<0.1$}\\
\end{tabularx}
\end{table}
\end{document}
4
  • Looks great, thank you. Can you recommend any way to getting stata output to tex using these commands?
    – Uruguayo
    Sep 10, 2015 at 16:55
  • @JoaquinSaldainDescalzi - I'm afraid I have no experience with Stata. Sorry.
    – Mico
    Sep 10, 2015 at 17:04
  • @Mico How I can add comments without affecting the spacing between columns ?? This will be great if you can show it here.
    – msh855
    Dec 24, 2017 at 19:30
  • @msh855 - I'm afraid I don't understand your query. Please post a new query, in which you lay out all information that's needed to understand your situation and (hopefully) to come up with a solution.
    – Mico
    Dec 24, 2017 at 23:07
1

I think that the long name is Distancia entre localidad y sucursal (Km).

First you have to change the position l by p{'width'}, with width equal to the column width wanted, and write the following should work:

Distancia entre \newline localidad y sucursal (Km)
4
  • 1
    l columns are not impressed by \newline. Use p{...} or X columns (package tabularx) or inner tables. Sep 10, 2015 at 14:12
  • @HeikoOberdiek : my bad, to see this. I'll modified the answer Sep 10, 2015 at 14:15
  • 1
    @RomainPicot do you mean \begin{tabular}{p{'width'}ccc} ? This doesn't work...
    – Uruguayo
    Sep 10, 2015 at 14:46
  • Modify width with the wanted size Sep 10, 2015 at 14:48

You must log in to answer this question.

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