5

I would like this table to adjust the width of its columns to the content. Columns 2, 3 and 4 are way big. Any suggestions?

    \documentclass[12pt]{article}
    \usepackage[margin=3cm]{geometry} % Ajusta margen hoja
    \usepackage{float} % Permite opción float en Figures para las que querés fijar en una página
    \usepackage[hyperref=true,citestyle=authoryear,sorting=nyt,bibencoding=ascii,backend=bibtex,url=true,maxcitenames=1,doi=false,isbn=false]{biblatex} % Citas: autor, (año)
    \usepackage[expansion=alltext,stretch=30]{microtype}
    \usepackage{amsmath}
    \usepackage{graphicx}
    \usepackage{epstopdf}
    \usepackage{chngcntr}
    \usepackage{booktabs}
    \usepackage{rotating} % Rotate tables
    \usepackage{chngpage}  % Permite ajustar margenes para tablas específicas    

    \begin{document}

    \begin{table}[htbp]
    \begin{adjustwidth}{-3in}{-3in} %
      \centering
      \caption{Número de operaciones crediticias}
      \begin{tabular}{lccc}
      \toprule
     & (1) & (2) & (3) \\
        Variables & MCO & EF & ZINB \\
        \midrule
      &   &   &  \\
    Tiene Fondo de Garantía & 0.446 & 1.041 & 0.184** \\
          & (2.101) & (0.703) & (0.089) \\
    \begin{tabular}{@{}c@{}}Distancia entre localidad \\ y sucursal (Km)\end{tabular} & -5.275*** & -6.655* & -1.472*** \\
          & (1.862) & (3.845) & (0.217) \\
    Recaudación IVA (log) & -1.082 & -1.883 & -0.314 \\
          & (1.876) & (1.317) & (0.208) \\
    Tasa de desempleo & 6.830 & -3.858 & 3.180** \\
          & (18.887) & (11.460) & (1.581) \\
    Crédito bancario (log) & 0.152 & -1.793 & -0.450* \\
          & (2.437) & (1.921) & (0.245) \\
    Constante & 8.600 & 23.158** &  \\
          & (5.927) & (11.165) &  \\
          &       &       &  \\
    Observaciones & 1,250 & 1,250 & 1,250 \\
    Efectos Fijos por Departamento & NO    & SI    & SI \\
    Dummies temporales & SI    & SI    & SI \\
    Número de localidades &       & 125   & 125 \\
    \bottomrule
        \multicolumn{3}{l}{\textsuperscript{}\footnotesize{Período: septiembre 2011 a diciembre de 2013. Ecuación de ceros en ZINB incluye una dummy que}} \\
        \multicolumn{3}{l}{\textsuperscript{}\footnotesize{vale 1 cuando hay una sucursal en el departamento, y dummies por localidad. Errores clúster a nivel}} \\
        \multicolumn{3}{l}{\textsuperscript{}\footnotesize{de localidad. *** p<0.01,** p<0.05, * p<0.1}}
    \end{tabular}%
  \label{tab:noperaciones}%
\end{adjustwidth}
\end{table}%
\end{document}
2

Here, I took the final three footnote rows which had been set in a multicolumn, and instead placed them in a parbox.

\documentclass[12pt]{article}
\usepackage[margin=3cm]{geometry} % Ajusta margen hoja
\usepackage{float} % Permite opción float en Figures para las que querés fijar en una página
\usepackage[hyperref=true,citestyle=authoryear,sorting=nyt,bibencoding=ascii,backend=bibtex,url=true,maxcitenames=1,doi=false,isbn=false]{biblatex} % Citas: autor, (año)
\usepackage[expansion=alltext,stretch=30]{microtype}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{epstopdf}
\usepackage{chngcntr}
\usepackage{booktabs}
\usepackage{rotating} % Rotate tables
\usepackage{chngpage}  % Permite ajustar margenes para tablas específicas    

\begin{document}

\begin{table}[htbp]
\begin{adjustwidth}{-3in}{-3in} %
  \centering
  \caption{Número de operaciones crediticias}
  \begin{tabular}{lccc}
  \toprule
 & (1) & (2) & (3) \\
    Variables & MCO & EF & ZINB \\
    \midrule
  &   &   &  \\
Tiene Fondo de Garantía & 0.446 & 1.041 & 0.184** \\
      & (2.101) & (0.703) & (0.089) \\
\begin{tabular}{@{}c@{}}Distancia entre localidad \\ y sucursal (Km)\end{tabular} & -5.275*** & -6.655* & -1.472*** \\
      & (1.862) & (3.845) & (0.217) \\
Recaudación IVA (log) & -1.082 & -1.883 & -0.314 \\
      & (1.876) & (1.317) & (0.208) \\
Tasa de desempleo & 6.830 & -3.858 & 3.180** \\
      & (18.887) & (11.460) & (1.581) \\
Crédito bancario (log) & 0.152 & -1.793 & -0.450* \\
      & (2.437) & (1.921) & (0.245) \\
Constante & 8.600 & 23.158** &  \\
      & (5.927) & (11.165) &  \\
      &       &       &  \\
Observaciones & 1,250 & 1,250 & 1,250 \\
Efectos Fijos por Departamento & NO    & SI    & SI \\
Dummies temporales & SI    & SI    & SI \\
Número de localidades &       & 125   & 125 \\
\bottomrule
\end{tabular}\\\smallskip%
\parbox{4.8in}{%
\footnotesize Período: septiembre 2011 a diciembre de 2013. Ecuación de ceros en ZINB incluye una dummy que
vale 1 cuando hay una sucursal en el departamento, y dummies por localidad. Errores clúster a nivel
de localidad. *** p<0.01,** p<0.05, * p<0.1}
\end{adjustwidth}
\end{table}

\end{document}

enter image description here

2

mwe

I used atabularx to fix the width of the table without the adjustwidth environment. Probably you may want use comma separators (not dots) for decimals in spanish documents, but overall, do not use hyphens (-) as minus signs ($-$)!

Both things can be corrected automatically simply using a math mode. Beside, it could be a good idea align the numbers by the decimal separator instead of center all the numbers. Although mixing in the same column the variable values and cells with other information later and signification marks make some more difficult make this, stil is possible using the dcolumn package and multicolumns for cells with another alignment.

The example also add vertical spaces between variables and multirow in the first column. Beside this, your MWE obviously need also at least the packages inputenc and babel for render properly the Spanish text with pdflatex.

Off- topic: Be careful with capitalization for common words in Spanish. This should be avoided except in nouns and adjectives that are part of a name (not sure if that could be the case in "Fondo de Garantía", etc.) and mark words of another languages with italics or quotation marks (\emph{} or «», for instance).

\documentclass[12pt]{article}
\usepackage[margin=3cm]{geometry} 
\usepackage[utf8]{inputenc}
\usepackage{booktabs}
\usepackage{dcolumn,multirow,tabularx}
\usepackage[spanish]{babel}
%\usepackage{amstext} % for \text macro
\def\mcc#1{\multicolumn{1}{X}{\centering #1}}
\def\mrl#1{\multirow{2}{5cm}{#1}}
\begin{document}
\begin{table}[htbp]
\centering
\caption{Número de  operacione  crediticias.}
\begin{tabularx}{.8\linewidth}{p{.35\linewidth}D{.}{,}{1.1}D{.}{,}{1.1}D{.}{,}{1.1}}
\toprule
& \mcc{(3)} & \mcc{(3)} & \mcc{(3)} \\
Variables   & \mcc{MCO} & \mcc{EF}  & \mcc{ZINB}\\\midrule\addlinespace[.5em]
\mrl{Tiene fondo de garantía}   & 0.446 & 1.041 & 0.184^{**} \\
    & (2.101)   & (0.703)   & (0.089) \\\addlinespace[.5em]
\mrl{Distancia entre localidad y sucursal (km)}
    & -5.275^{***}  & -6.655^{*}    & -1.472^{***} \\
    & (1.862)   & (3.845)   & (0.217) \\\addlinespace[.5em]
\mrl{Recaudación IVA (log)} & 1.082 & -1.883    & -0.314 \\
    & (1.876)   & (1.317)   & (0.208) \\\addlinespace[.5em]
\mrl{Tasa de desempleo} & 6.830 & -3.858    & 3.180^{**} \\
    & (18.887)  & (11.460)  & (1.581) \\\addlinespace[.5em]
\mrl{Crédito bancario (log)}    & 0.152 & -1.793    & -0.450^{*} \\
    & (2.437)   & (1.921)   & (0.245) \\\addlinespace[.5em]
\mrl{Constante} & 8.600 & 23.158^{**}   & \\
    & (5.927)   & (11.165)  & \\\addlinespace[.5em]\midrule\addlinespace[.5em]
Observaciones   & \mcc{1250}    & \mcc{1250}    & \mcc{1250} \\\addlinespace[.5em]
Efectos fijos por departamento  & \mcc{NO}  & \mcc{SI}  & \mcc{SI} \\\addlinespace[.5em]
«Dummies» temporales    & \mcc{SI}  & \mcc{SI}  & \mcc{SI} \\\addlinespace[.5em]
Número de localidades   &   & \mcc{125} & \mcc{125} \\\addlinespace[.5em]
\bottomrule
\multicolumn{4}{p{\dimexpr.8\linewidth-2\tabcolsep}}{\footnotesize Período: septiembre 2011 a diciembre de 2013. Ecuación de ceros en ZINB incluye una dummy que vale 1 cuando hay una sucursal en el departamento, y dummies por localidad. Errores clúster a nivel de localidad. $^{***}\ p<0.01$; $^{**}\ p<0.05$; $^{*}\ p<0.1$.}
\end{tabularx}
\end{table}%

\end{document}
  • @Mico oooopps. Luckily I do not deleted it from the editor. Solved. – Fran Apr 18 '16 at 3:35
2

Some suggestions:

  • Use a tabularx environment, with an overall width of \textwidth. Use the X column type for the first column.

  • Use the dcolumn package to align the numbers in columns 2, 3, and 4 on their respective decimal markers.

  • Don't use separate \multicolumn directives for the three (unnumbered) footnotes. Instead, just let them flow together in an ordinary text paragraph following the tabular material.

enter image description here

\documentclass[12pt]{article}
\usepackage[margin=3cm]{geometry} % Ajusta margen hoja
\usepackage{float}
\usepackage[hyperref=true,citestyle=authoryear,
            sorting=nyt,bibencoding=ascii,backend=bibtex,
            url=true,maxcitenames=1,doi=false,isbn=false]
           {biblatex} % Citas: autor, (año)
\usepackage[expansion=alltext,stretch=30]{microtype}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage{tabularx,dcolumn,caption}
\captionsetup{skip=0.5\baselineskip}
\newcolumntype{d}[1]{D.,{#1}}  
\newcommand\mc[1]{\multicolumn{1}{@{}c@{}}{#1}} % handy shortcut macro

\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{epstopdf}
\usepackage{chngcntr}
\usepackage{booktabs}
\usepackage{rotating} % Rotate tables
\usepackage{chngpage}  % Permite ajustar margenes para tablas específicas  

\begin{document}

\begin{table}[htbp]
\caption{Número de operaciones crediticias}
\begin{tabularx}{\textwidth}{@{} X *{3}{d{3.5}} @{}}
  \toprule
  & \mc{(1)} & \mc{(2)} & \mc{(3)} \\
  Variables & \mc{MCO} & \mc{EF} & \mc{ZINB} \\
  \midrule
  Tiene Fondo de Garantía & 0.446 & 1.041 & 0.184^{**} \\
      & (2.101) & (0.703) & (0.089) \\
  Distancia entre localidad y sucursal (Km) & -5.275^{***} & -6.655^{*} & -1.472^{***} \\
      & (1.862) & (3.845) & (0.217) \\
  Recaudación IVA (log) & -1.082 & -1.883 & -0.314 \\
      & (1.876) & (1.317) & (0.208) \\
  Tasa de desempleo & 6.830 & -3.858 & 3.180^{**} \\
      & (18.887) & (11.460) & (1.581) \\
  Crédito bancario (log) & 0.152 & -1.793 & -0.450^{*} \\
      & (2.437) & (1.921) & (0.245) \\
  Constante & 8.600 & 23.158^{**} &  \\
      & (5.927) & (11.165) &  \\
  \addlinespace
  Observaciones & \mc{1250} & \mc{1250} & \mc{1250} \\
  Efectos Fijos por Departamento & \mc{NO}    & \mc{SI}    & \mc{SI} \\
  Dummies temporales & \mc{SI}    & \mc{SI}    & \mc{SI} \\
  Número de localidades &       & \mc{125}   & \mc{125} \\
\bottomrule
\end{tabularx}

\medskip

{\footnotesize Período: septiembre 2011 a diciembre de 2013. Ecuación de ceros en ZINB incluye una dummy que
vale~1 cuando hay una sucursal en el departamento, y dummies por localidad. Errores clúster a nivel
de localidad. $^{***} p<0.01$, $^{**} p<0.05$, $^{*} p<0.1$.\par}

\end{table}

\end{document}

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.