2

I've just started using sharelatex and I read many manuals and previous questions about long tables yet my long table doesn't fit to my document. it is too wide and exit the margins. it doesn't rotate either. I would be glad if you could help me because I don't know where else to look for a solution. That's the text:

\begin{sidewaytable}
\begin{longtable}{|c|c|c|c|}
\hline
Variable &Type/ denomination &Source&Employed in: 
\hline
Compulsory voting 
&Dummy=1 if voting compulsory in country i at time t &Self-created based on IDEA information
&(2a), (3a) 
\hline
Voting age &Minimum age to vote in country i at time t &IDEA&
\hline
Urban population 
&\% population living in cities &WB &(2a), (3a) 
\hline
Gini coefficient&Gini coefficient estimate &WB&(2a) 
\hline
High\_Ten &\% of country i’s GNI held by richest 10\% of population &WB 
\hline
Patents &Patent application from residents of country i at time t &WB 
\hline
Oda &Net ODA received per capita &WB &(2a) 
\hline
Literacy &Literacy rate of population above 15 &WB 
\hline
Life &Life expectancy at birth, in years &WB& 
\hline
Net exports&Exports in current US \$ - Imports in current US \$& Self-created based on WB data &(2a), (3a) 
\hline
Inflation &CPI index, growth rate in country i from t-1 to t, relative to time t &WB&
\hline
Agriculture value added&As a \% of GDP &WB 
\hline
C02 emissions&In tons per capita&WB 
\hline
Domestic credit &To the private sector, as a \% of GDP &WB\\ 
\label{tab2}
\end{longtable}
\end{sidewaytable} 
  • 1
    Welcome to TeX.SE! Please make your code snippet compilable! – Mensch Apr 5 '18 at 17:01
  • 2
    Embedding a longtable inside a sidewaystable env. cannot work – Mico Apr 5 '18 at 17:02
1

Mwe

You do not need a longtable here, and please, please, please, do not use vertical lines:

\documentclass[a4paper]{article}
\usepackage{geometry}
\usepackage{rotating,booktabs,array}
\usepackage{tabulary}
\begin{document}

\begin{sidewaystable}
\setlength\belowcaptionskip{1ex}
\caption{The caption of this table.}
\renewcommand\arraystretch{1.6}
\begin{tabulary}{\linewidth}{LLLL}
\toprule
Variable  & Type/ denomination  & Source & Employed in: \\\midrule
Compulsory voting 
 & Dummy=1 if voting compulsory in country i at time t  & Self-created based on IDEA information
 & (2a), (3a) \\
Voting age  & Minimum age to vote in country i at time t  & IDEA & \\
Urban population 
 & \% population living in cities  & WB  & (2a), (3a) \\
Gini coefficient & Gini coefficient estimate  & WB & (2a) \\
High\_Ten  & \% of country i’s GNI held by richest 10\% of population  & WB \\
Patents  & Patent application from residents of country i at time t  & WB \\
Oda  & Net ODA received per capita  & WB  & (2a) \\
Literacy  & Literacy rate of population above 15  & WB \\
Life  & Life expectancy at birth, in years  & WB &  \\
Net exports & Exports in current US \$ - Imports in current US \$ &  Self-created based on WB data  & (2a), (3a) \\
Inflation  & CPI index, growth rate in country i from t-1 to t, relative to time t  & WB & \\
Agriculture value added & As a \% of GDP  & WB \\
C02 emissions & In tons per capita & WB \\
Domestic credit  & To the private sector, as a \% of GDP  & WB\\ \\\bottomrule
\end{tabulary}
\end{sidewaystable} 
\end{document}
  • It could be better if you suppress also the number of page in that page (\thispagestyle{empty} should work). – Fran Apr 5 '18 at 17:31
  • Perfect and graphically Beautiful! thank you very much – federica Apr 5 '18 at 17:39
1
\documentclass[12pt,a4paper]{article}
\usepackage{lscape,ltablex}
\begin{document}

\begin{landscape}
\begin{tabularx}{\linewidth}{|p{8em}|X|p{9em}|p{4em}|}
    \hline
    Variable                & Type/denomination                                                     & Source                                 & Employed in: \\ \hline
    Compulsory voting       & Dummy=1 if voting compulsory in country i at time t                   & Self-created based on IDEA information & (2a), (3a)   \\ \hline
    Voting age              & Minimum age to vote in country i at time t                            & IDEA                                   &              \\ \hline
    Urban population        & \% population living in cities                                        & WB                                     & (2a), (3a)   \\ \hline
    Gini coefficient        & Gini coefficient estimate                                             & WB                                     & (2a)         \\ \hline
    High\_Ten               & \% of country i’s GNI held by richest 10\% of population              & WB                                     &              \\ \hline
    Patents                 & Patent application from residents of country i at time t              & WB                                     &              \\ \hline
    Oda                     & Net ODA received per capita                                           & WB                                     & (2a)         \\ \hline
    Literacy                & Literacy rate of population above 15                                  & WB                                     &              \\ \hline
    Life                    & Life expectancy at birth, in years                                    & WB                                     &              \\ \hline
    Net exports             & Exports in current US \$ - Imports in current US \$                   & Self-created based on WB data          & (2a), (3a)   \\ \hline
    Inflation               & CPI index, growth rate in country i from t-1 to t, relative to time t & WB                                     &              \\ \hline
    Agriculture value added & As a \% of GDP                                                        & WB                                     &              \\ \hline
    C02 emissions           & In tons per capita                                                    & WB                                     &              \\ \hline
    Domestic credit         & To the private sector, as a \% of GDP                                 & WB                                     &              \\ \hline
\end{tabularx}
\end{landscape}

\end{document}

enter image description here

  • Thank you a lot. It works. The only remaining problem is that the last row ends up alone in the following page. what can I do? – federica Apr 5 '18 at 17:10
  • If you play a bit with the third column width, you will make the table shorter. Also, I used X column type for the second column to benefit from a whole line width. – AboAmmar Apr 5 '18 at 18:18

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.