1

I have the following table. It only fits horizontally in a landscape environment. However, then it does not fits vertically. Is there a way to solve this? I have thought of trying to fix it at the top of the page.

Using \begin{table}[t!} would not work. I have seen solutions using \setlength{\@fptop}{0pt} (How to place a float at the top of a floats-only page?), but that does not suits me because my document has a lot of tables that should not have these settings.

Can someone help?

    \documentclass{article}
    \usepackage[T1]{fontenc}        
    \usepackage[utf8]{inputenc}     
    \usepackage[group-separator={.},
                    group-four-digits,
                    output-decimal-marker={,}]{siunitx}
    \makeatletter    
    \makeatother
    \usepackage[vmargin=3cm, hmargin=2.5cm]{geometry}
    \usepackage[flushleft]{threeparttable}
    \def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}

    \usepackage{pdflscape}
    \usepackage{booktabs, tabularx, ragged2e, rotating}
    \usepackage{amsmath}



 \begin{document}
   \begin{landscape} 
    \begin{table}[t!]
        \centering
        \sisetup{input-symbols=(),
                 table-space-text-post={\sym{***}},
                 output-decimal-marker={,},
                 group-digits=false}
        \caption{Resultados - Impactos sobre resultados eleitorais e heterogeneidade entre municípios} 
        \label{table::a} 
        \setlength\tabcolsep{3pt}
        \begin{threeparttable}
        \begin{tabular}
        {l*{6}{S[table-format={-1.3}]}}\\
        \toprule
        & \multicolumn{6}{c}{Variável dependente:} \\ 
        \cmidrule{2-7} 
        & \multicolumn{2}{c}{$\log(\textrm{Receitas})$} 
        & \multicolumn{2}{c}{\% de votos ($\times$100)} 
        & \multicolumn{2}{c}{\textit{Dummy} Eleição} \\ 
        \cmidrule(lr){2-3} \cmidrule(lr){4-5} \cmidrule(lr){6-7} 
        & {(1)} & {(2)} & {(3)} & {(4)} & {(5)} & {(6)} \\
        \midrule
             Ano $\times$ Tratamento
                 & -0,338\sym{***} & -0,259\sym{***} & -0,052 & -0,057\sym{*} &  &  \\
                 & (0,205) & (0,014) & (0,036) & (0,024) &  &  \\ \addlinespace
            Ano $\times$ Tratamento $\times$ \% T no município 
                 & 3,921\sym{***} &  & 0,048 &  &  & \\ 
                 & (0,502) &  & (0,886) &  &  & \\ \addlinespace 
            Ano $\times$ Tratamento $\times$ $\textrm{HH}^{-1}$  
                 &  & 0,058 &  & 0,750\sym{***} &  & \\ 
                 &  & (0,058) &  & (0,103) &  & \\ \addlinespace 
            Tratamento  
                 &  &  &  &  & -0,246\sym{***} & -0,080\sym{**} \\ 
                 &  &  &  &  & (0,039) & (0,026) \\ \addlinespace 
            Tratamento $\times$ \% T no município 
                 &  &  &  &  & 4,319\sym{***} & \\ 
                 &  &  &  &  &  & (0,736) \\ \addlinespace 
            Tratamento $\times$ $\textrm{HH}^{-1}$ 
                 &  &  &  &  &  & 0,147 \\ 
                 &  &  &  &  &  & 0,120 \\ \addlinespace 
             Constante
                 & 0,112\sym{***} & 0,084\sym{***} & -0,393\sym{***} & -0,387\sym{***} & 0,148 & 0,168 \\ 
                 & (0,007) & (0,006) & (0,013) & (0,011) & (0,155) & (0,155) \\ \addlinespace
        \midrule
            Características pessoais? & \ding{51} & \ding{51} & \ding{51} & \ding{51} & \ding{51} & \ding{51} \\
            Prefeito? & \ding{51} & \ding{51} & \ding{51} &  \ding{51} & \ding{51} & \ding{51} \\
            Total de votos no município? & \ding{51} & \ding{51} & \ding{51} &  \ding{51} & \ding{51} & \ding{51} \\
        \midrule
            Primeiras diferenças? & \ding{51}& \ding{51} & \ding{51} & \ding{51} &  &  \\
            Média da var. dep. em 2016 & {8.767} & {8.767} & {3,97} & {3,97} & {58,6\%} & {58,6\%} \\
            Observações & {39.894} & {39.894} & {39.894} & {39.894} & {39.894} & {39.894} \\ 
            R$^{2}$ & {} & {} & {} & {} & {} & {} \\
        \bottomrule
        \end{tabular}

        \begin{tablenotes}[para,flushleft]
        \footnotesize{
        Notas: $\sym{*}\ p<0{,}1$; $\sym{**}\ p<0{,}05$; $\sym{***}\ p<0{,}01$ \\
        Regressões controlam por caraterísticas pessoais do candidato, incluindo variáveis binárias de grau de escolaridade, sexo e raça, além de pelo fato do candidato ser ou não afiliado aos prefeitos eleitos no ano, assim como pelo total de votos no município. Apesar de nem todos os coeficientes serem reportados, as regressões incluem todas as combinações de interações entre as \textit{dummies} de ano e de tratamento e com proporção de tratados no município ou com o grau de concorrência.}

        \end{tablenotes}
        \end{threeparttable}
        \end{table}
        \end{landscape}



        \end{document}

Thank you!

1 Answers1

2

Landscape would automatically issue a \clearpage at the start and end. You could conceivably add text inside landscape, but it would also be sideways and there is no room for sideways text.

Sidewaystable also takes up the entire page. You have to put the caption inside the threepartable and use rotatebox.

I also had to increase \topfraction and reduce \textfraction. Still getting an error message for \sym.

    \documentclass{article}
    \usepackage[T1]{fontenc}        
    \usepackage[utf8]{inputenc}     
    \usepackage[group-separator={.},
                    group-four-digits,
                    output-decimal-marker={,}]{siunitx}
    \makeatletter    
    \makeatother
    \usepackage[vmargin=3cm, hmargin=2.5cm]{geometry}
    \usepackage[flushleft]{threeparttable}
    \usepackage{pdflscape}
    \usepackage{booktabs, tabularx, ragged2e}
    \usepackage{amsmath}
    \usepackage{graphicx}

    \renewcommand{\topfraction}{.9}% default is .7
    \renewcommand{\textfraction}{.1}% default is .2

    \begin{document}
    \begin{table}[tp]
        \centering
        \sisetup{input-symbols=(),
                 table-space-text-post={\sym{***}},
                 output-decimal-marker={,},
                 group-digits=false}
        \setlength\tabcolsep{3pt}
        \rotatebox{90}{\begin{threeparttable}
        \caption{Resultados - Impactos sobre resultados eleitorais e heterogeneidade entre municípios} 
        \label{table::a}
        \begin{tabular}
        {l*{6}{S[table-format={-1.3}]}}\\
        \toprule
        & \multicolumn{6}{c}{Variável dependente:} \\ 
        \cmidrule{2-7} 
        & \multicolumn{2}{c}{$\log(\textrm{Receitas})$} 
        & \multicolumn{2}{c}{\% de votos ($\times$100)} 
        & \multicolumn{2}{c}{\textit{Dummy} Eleição} \\ 
        \cmidrule(lr){2-3} \cmidrule(lr){4-5} \cmidrule(lr){6-7} 
        & {(1)} & {(2)} & {(3)} & {(4)} & {(5)} & {(6)} \\
        \midrule
             Ano $\times$ Tratamento
                 & -0,338\sym{***} & -0,259\sym{***} & -0,052 & -0,057\sym{*} &  &  \\
                 & (0,205) & (0,014) & (0,036) & (0,024) &  &  \\ \addlinespace
            Ano $\times$ Tratamento $\times$ \% T no município 
                 & 3,921\sym{***} &  & 0,048 &  &  & \\ 
                 & (0,502) &  & (0,886) &  &  & \\ \addlinespace 
            Ano $\times$ Tratamento $\times$ $\textrm{HH}^{-1}$  
                 &  & 0,058 &  & 0,750\sym{***} &  & \\ 
                 &  & (0,058) &  & (0,103) &  & \\ \addlinespace 
            Tratamento  
                 &  &  &  &  & -0,246\sym{***} & -0,080\sym{**} \\ 
                 &  &  &  &  & (0,039) & (0,026) \\ \addlinespace 
            Tratamento $\times$ \% T no município 
                 &  &  &  &  & 4,319\sym{***} & \\ 
                 &  &  &  &  &  & (0,736) \\ \addlinespace 
            Tratamento $\times$ $\textrm{HH}^{-1}$ 
                 &  &  &  &  &  & 0,147 \\ 
                 &  &  &  &  &  & 0,120 \\ \addlinespace 
             Constante
                 & 0,112\sym{***} & 0,084\sym{***} & -0,393\sym{***} & -0,387\sym{***} & 0,148 & 0,168 \\ 
                 & (0,007) & (0,006) & (0,013) & (0,011) & (0,155) & (0,155) \\ \addlinespace
        \midrule
            Características pessoais? & \ding{51} & \ding{51} & \ding{51} & \ding{51} & \ding{51} & \ding{51} \\
            Prefeito? & \ding{51} & \ding{51} & \ding{51} &  \ding{51} & \ding{51} & \ding{51} \\
            Total de votos no município? & \ding{51} & \ding{51} & \ding{51} &  \ding{51} & \ding{51} & \ding{51} \\
        \midrule
            Primeiras diferenças? & \ding{51}& \ding{51} & \ding{51} & \ding{51} &  &  \\
            Média da var. dep. em 2016 & {8.767} & {8.767} & {3,97} & {3,97} & {58,6\%} & {58,6\%} \\
            Observações & {39.894} & {39.894} & {39.894} & {39.894} & {39.894} & {39.894} \\ 
            R$^{2}$ & {} & {} & {} & {} & {} & {} \\
        \bottomrule
        \end{tabular}

        \begin{tablenotes}[para,flushleft]
        \footnotesize{
        Notas: $\sym{*}\ p<0{,}1$; $\sym{**}\ p<0{,}05$; $\sym{***}\ p<0{,}01$ \\
        Regressões controlam por caraterísticas pessoais do candidato, incluindo variáveis binárias de grau de escolaridade, sexo e raça, além de pelo fato do candidato ser ou não afiliado aos prefeitos eleitos no ano, assim como pelo total de votos no município. Apesar de nem todos os coeficientes serem reportados, as regressões incluem todas as combinações de interações entre as \textit{dummies} de ano e de tratamento e com proporção de tratados no município ou com o grau de concorrência.}

        \end{tablenotes}
        \end{threeparttable}}%
        \end{table}
Some text.
        \end{document}

full page


This solution places the text alongside the threeparttable. Since it fills the page, no wrapfig needed.

\documentclass{article}
\usepackage[T1]{fontenc}        
\usepackage[utf8]{inputenc}     
\usepackage[group-separator={.},
                group-four-digits,
                output-decimal-marker={,}]{siunitx}
\makeatletter    
\makeatother
\usepackage[vmargin=3cm, hmargin=2.5cm]{geometry}
\usepackage[flushleft]{threeparttable}
\usepackage{pdflscape}
\usepackage{booktabs, tabularx, ragged2e}
\usepackage{amsmath}
\usepackage{pdflscape}

\let\sym=\relax% enough with the error messages!
\let\ding=\relax

\newsavebox{\tablebox}

\begin{document}
\begin{landscape}
\savebox{\tablebox}{%measure width
    \sisetup{input-symbols=(),
             table-space-text-post={\sym{***}},
             output-decimal-marker={,},
             group-digits=false}
    \setlength\tabcolsep{3pt}
    \begin{threeparttable}
    \caption{Resultados - Impactos sobre resultados eleitorais e heterogeneidade entre municípios} 
    \label{table::a}
    \begin{tabular}
    {l*{6}{S[table-format={-1.3}]}}\\
    \toprule
    & \multicolumn{6}{c}{Variável dependente:} \\ 
    \cmidrule{2-7} 
    & \multicolumn{2}{c}{$\log(\textrm{Receitas})$} 
    & \multicolumn{2}{c}{\% de votos ($\times$100)} 
    & \multicolumn{2}{c}{\textit{Dummy} Eleição} \\ 
    \cmidrule(lr){2-3} \cmidrule(lr){4-5} \cmidrule(lr){6-7} 
    & {(1)} & {(2)} & {(3)} & {(4)} & {(5)} & {(6)} \\
    \midrule
         Ano $\times$ Tratamento
             & -0,338\sym{***} & -0,259\sym{***} & -0,052 & -0,057\sym{*} &  &  \\
             & (0,205) & (0,014) & (0,036) & (0,024) &  &  \\ \addlinespace
        Ano $\times$ Tratamento $\times$ \% T no município 
             & 3,921\sym{***} &  & 0,048 &  &  & \\ 
             & (0,502) &  & (0,886) &  &  & \\ \addlinespace 
        Ano $\times$ Tratamento $\times$ $\textrm{HH}^{-1}$  
             &  & 0,058 &  & 0,750\sym{***} &  & \\ 
             &  & (0,058) &  & (0,103) &  & \\ \addlinespace 
        Tratamento  
             &  &  &  &  & -0,246\sym{***} & -0,080\sym{**} \\ 
             &  &  &  &  & (0,039) & (0,026) \\ \addlinespace 
        Tratamento $\times$ \% T no município 
             &  &  &  &  & 4,319\sym{***} & \\ 
             &  &  &  &  &  & (0,736) \\ \addlinespace 
        Tratamento $\times$ $\textrm{HH}^{-1}$ 
             &  &  &  &  &  & 0,147 \\ 
             &  &  &  &  &  & 0,120 \\ \addlinespace 
         Constante
             & 0,112\sym{***} & 0,084\sym{***} & -0,393\sym{***} & -0,387\sym{***} & 0,148 & 0,168 \\ 
             & (0,007) & (0,006) & (0,013) & (0,011) & (0,155) & (0,155) \\ \addlinespace
    \midrule
        Características pessoais? & \ding{51} & \ding{51} & \ding{51} & \ding{51} & \ding{51} & \ding{51} \\
        Prefeito? & \ding{51} & \ding{51} & \ding{51} &  \ding{51} & \ding{51} & \ding{51} \\
        Total de votos no município? & \ding{51} & \ding{51} & \ding{51} &  \ding{51} & \ding{51} & \ding{51} \\
    \midrule
        Primeiras diferenças? & \ding{51}& \ding{51} & \ding{51} & \ding{51} &  &  \\
        Média da var. dep. em 2016 & {8.767} & {8.767} & {3,97} & {3,97} & {58,6\%} & {58,6\%} \\
        Observações & {39.894} & {39.894} & {39.894} & {39.894} & {39.894} & {39.894} \\ 
        R$^{2}$ & {} & {} & {} & {} & {} & {} \\
    \bottomrule
    \end{tabular}

    \begin{tablenotes}[para,flushleft]
    \footnotesize{
    Notas: $\sym{*}\ p<0{,}1$; $\sym{**}\ p<0{,}05$; $\sym{***}\ p<0{,}01$ \\
    Regressões controlam por caraterísticas pessoais do candidato, incluindo variáveis binárias de grau de escolaridade, sexo e raça, além de pelo fato do candidato ser ou não afiliado aos prefeitos eleitos no ano, assim como pelo total de votos no município. Apesar de nem todos os coeficientes serem reportados, as regressões incluem todas as combinações de interações entre as \textit{dummies} de ano e de tratamento e com proporção de tratados no município ou com o grau de concorrência.}

    \end{tablenotes}
    \end{threeparttable}}%
\noindent\begin{minipage}[t][\textheight][t]{\dimexpr \linewidth-\wd\tablebox-\columnsep}
Some text.
\end{minipage}\hfill\usebox{\tablebox}
\end{landscape}
\end{document}

demo

John Kormylo
  • 79,712
  • 3
  • 50
  • 120