2

I have the attached table I can't make it fix to the page...what do you recommend me to do?

\begin{sidewaystable}[ht]
    \centering
    \begin{tabularx}{\textwidth}{P{2.5cm}lrrrrrrrrrr}
    %   \toprule
        \hline
        & Momento & CD.Oeste & CD.Norte & CD.Este & CD.Sur & ONU.Chileno & ONU.Latinoamericano & ONU.Lejano.Este & ONU.Sur.Asia & ONU.General \\ 
        \hline
        1898 & 40.68 & 45.79 & 45.88 & 45.12 & 45.75 & 47.12 & 46.36 & 47.66 & 46.03 & 46.75 \\ 
        1903 & 42.15 & 47.47 & 47.56 & 46.83 & 47.53 & 48.96 & 48.17 & 49.61 & 47.77 & 48.60 \\ 
        1908 & 43.67 & 49.22 & 49.32 & 48.64 & 49.38 & 50.88 & 50.05 & 51.62 & 49.58 & 50.52 \\ 
        1913 & 45.25 & 51.08 & 51.18 & 50.54 & 51.31 & 52.85 & 51.99 & 53.71 & 51.45 & 52.52 \\ 
        1918 & 46.88 & 53.05 & 53.16 & 52.54 & 53.32 & 54.89 & 54.00 & 55.87 & 53.39 & 54.58 \\ 
        1923 & 48.54 & 55.15 & 55.27 & 54.64 & 55.40 & 56.97 & 56.06 & 58.08 & 55.39 & 56.70 \\ 
        1928 & 50.24 & 57.38 & 57.43 & 56.82 & 57.54 & 59.09 & 58.17 & 60.34 & 57.44 & 58.87 \\ 
        1933 & 51.97 & 59.66 & 59.64 & 59.07 & 59.72 & 61.23 & 60.31 & 62.61 & 59.51 & 61.07 \\ 
        1938 & 53.72 & 61.98 & 61.88 & 61.38 & 61.93 & 63.37 & 62.46 & 64.88 & 61.60 & 63.28 \\ 
        1943 & 55.48 & 64.34 & 64.13 & 63.72 & 64.13 & 65.50 & 64.60 & 67.13 & 63.68 & 65.48 \\ 
        1948 & 57.24 & 66.70 & 66.37 & 66.08 & 66.32 & 67.59 & 66.71 & 69.31 & 65.75 & 67.64 \\ 
        1953 & 59.00 & 69.04 & 68.57 & 68.42 & 68.45 & 69.62 & 68.78 & 71.41 & 67.78 & 69.74 \\ 
        1958 & 60.74 & 71.32 & 70.73 & 70.73 & 70.52 & 71.59 & 70.78 & 73.42 & 69.76 & 71.77 \\ 
        1963 & 62.46 & 73.51 & 72.82 & 72.97 & 72.50 & 73.47 & 72.70 & 75.30 & 71.67 & 73.71 \\ 
        1968 & 64.16 & 75.58 & 74.82 & 75.10 & 74.35 & 75.23 & 74.52 & 77.04 & 73.49 & 75.52 \\ 
        1973 & 65.81 & 77.52 & 76.72 & 77.08 & 76.10 & 76.89 & 76.23 & 78.66 & 75.23 & 77.22 \\ 
        1978 & 67.43 & 79.28 & 78.47 & 78.90 & 77.72 & 78.42 & 77.82 & 80.11 & 76.84 & 78.78 \\ 
        1983 & 68.99 & 80.86 & 80.07 & 80.52 & 79.23 & 79.85 & 79.30 & 81.44 & 78.37 & 80.22 \\ 
        1988 & 70.51 & 82.23 & 81.46 & 81.94 & 80.59 & 81.13 & 80.63 & 82.61 & 79.75 & 81.51 \\ 
        1993 & 71.96 & 83.43 & 82.69 & 83.21 & 81.84 & 82.31 & 81.87 & 83.68 & 81.03 & 82.69 \\ 
        1998 & 73.36 & 84.46 & 83.73 & 84.29 & 82.95 & 83.36 & 82.97 & 84.60 & 82.18 & 83.72 \\ 
%   \bottomrule
    \hline
    \end{tabularx}
\end{sidewaystable}
4
  • please fix your example to be a complete document, the question is impossible to answer without knowing your page width, but almost certainly you do not want tabularx here (or in any numeric table) just a normal tab ular would be better Dec 9, 2015 at 1:19
  • tabularx can in anycase not work without an X column Dec 9, 2015 at 1:20
  • documentclass[12pt, letterpaper]{article} Dec 9, 2015 at 3:48
  • How is the P column type defined?
    – Mico
    Dec 9, 2015 at 6:22

2 Answers 2

3

You don't really have to use sidewaystable if you have multiline column heads with makecell and use a smaller font size for the table:

\documentclass[letterpaper, 12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern} 
\usepackage[showframe]{geometry}

\usepackage{caption, array, makecell, booktabs}

\begin{document}

\begin{table}[!htb]
\caption{My nice little caption}
\centering\small 
\setlength\tabcolsep{4pt}
\begin{tabular}{l*{10}{c}}
\toprule
& \thead{Momento} & \thead{CD.\\Oeste} & \thead{CD.\\Norte} & \thead{CD.\\Este} & \thead{CD.\\Sur} & \thead{ONU.\\Chileno} & \thead{ONU.\\Latino\\americano} & \thead{ONU.\\Lejano.\\Este} & \thead{ONU.\\Sur.\\Asia} & \thead{ONU.\\General} \\
\midrule
1898 & 40.68 & 45.79 & 45.88 & 45.12 & 45.75 & 47.12 & 46.36 & 47.66 & 46.03 & 46.75 \\
1903 & 42.15 & 47.47 & 47.56 & 46.83 & 47.53 & 48.96 & 48.17 & 49.61 & 47.77 & 48.60 \\
1908 & 43.67 & 49.22 & 49.32 & 48.64 & 49.38 & 50.88 & 50.05 & 51.62 & 49.58 & 50.52 \\
1913 & 45.25 & 51.08 & 51.18 & 50.54 & 51.31 & 52.85 & 51.99 & 53.71 & 51.45 & 52.52 \\
1918 & 46.88 & 53.05 & 53.16 & 52.54 & 53.32 & 54.89 & 54.00 & 55.87 & 53.39 & 54.58 \\
1923 & 48.54 & 55.15 & 55.27 & 54.64 & 55.40 & 56.97 & 56.06 & 58.08 & 55.39 & 56.70 \\
1928 & 50.24 & 57.38 & 57.43 & 56.82 & 57.54 & 59.09 & 58.17 & 60.34 & 57.44 & 58.87 \\
1933 & 51.97 & 59.66 & 59.64 & 59.07 & 59.72 & 61.23 & 60.31 & 62.61 & 59.51 & 61.07 \\
1938 & 53.72 & 61.98 & 61.88 & 61.38 & 61.93 & 63.37 & 62.46 & 64.88 & 61.60 & 63.28 \\
1943 & 55.48 & 64.34 & 64.13 & 63.72 & 64.13 & 65.50 & 64.60 & 67.13 & 63.68 & 65.48 \\
1948 & 57.24 & 66.70 & 66.37 & 66.08 & 66.32 & 67.59 & 66.71 & 69.31 & 65.75 & 67.64 \\
1953 & 59.00 & 69.04 & 68.57 & 68.42 & 68.45 & 69.62 & 68.78 & 71.41 & 67.78 & 69.74 \\
1958 & 60.74 & 71.32 & 70.73 & 70.73 & 70.52 & 71.59 & 70.78 & 73.42 & 69.76 & 71.77 \\
1963 & 62.46 & 73.51 & 72.82 & 72.97 & 72.50 & 73.47 & 72.70 & 75.30 & 71.67 & 73.71 \\
1968 & 64.16 & 75.58 & 74.82 & 75.10 & 74.35 & 75.23 & 74.52 & 77.04 & 73.49 & 75.52 \\
1973 & 65.81 & 77.52 & 76.72 & 77.08 & 76.10 & 76.89 & 76.23 & 78.66 & 75.23 & 77.22 \\
1978 & 67.43 & 79.28 & 78.47 & 78.90 & 77.72 & 78.42 & 77.82 & 80.11 & 76.84 & 78.78 \\
1983 & 68.99 & 80.86 & 80.07 & 80.52 & 79.23 & 79.85 & 79.30 & 81.44 & 78.37 & 80.22 \\
1988 & 70.51 & 82.23 & 81.46 & 81.94 & 80.59 & 81.13 & 80.63 & 82.61 & 79.75 & 81.51 \\
1993 & 71.96 & 83.43 & 82.69 & 83.21 & 81.84 & 82.31 & 81.87 & 83.68 & 81.03 & 82.69 \\
1998 & 73.36 & 84.46 & 83.73 & 84.29 & 82.95 & 83.36 & 82.97 & 84.60 & 82.18 & 83.72 \\
\bottomrule
\end{tabular}
\end{table}

\end{document} 

enter image description here

6
  • documentclass[12pt, letterpaper]{article} %\usepackage[spanish,activeacute]{babel} \usepackage{lmodern} \usepackage[T1]{fontenc} % Configuación de general del documento y de páginas \usepackage[utf8]{inputenc} \usepackage{lipsum} \usepackage[showframe]{geometry} This it's the document type. I just use your code, but it's still out of the margins of the page. Dec 9, 2015 at 2:03
  • And how do I put the caption here? Dec 9, 2015 at 2:44
  • "You don't really have to use sidewaystable if ..." -- you may also want to mention that your code loads the geometry package, which automatically widens the text block relative to the LaTeX default. Without this device, the table will not fit in portrait mode unless the font size is reduced significantly.
    – Mico
    Dec 9, 2015 at 7:00
  • @Mico: You're right. However the O.P. posted a comment with part of his preamble, in which loading geometry is mentioned. There remains however a problem, even with geometry, in 12pt, which the O.P. didn't initially mention. I've updated my answer in consequence.
    – Bernard
    Dec 9, 2015 at 10:57
  • @Nicolás Sacco: I've updated my answer to take the fontsize into account, and add a caption.
    – Bernard
    Dec 9, 2015 at 10:58
1

In order for the tabular material to have a chance to fit inside the width of the text block -- even if rotated to landscape mode -- it is necessary to introduce line breaks in the several of the header cells. To this effect, I suggest you use a plain l column type (instead of P{...}) for the very first column and a centered version of the X column type (instead of r) for the ten data columns.

I would further like to suggest that you organize the table header some more, to highlight that the first four data columns are about "CD" and the final six are about "ONU". A line break in the word "Latinoamericano" can be induced by adding a discretionary hyphen, i.e., by writing it as "Latino\-americano". Finally, to help your readers parse and take in the material in the table, a bit of vertical whitespace, say after every fifth row of the data, might be helpful.

enter image description here

\documentclass{article}
\usepackage[spanish]{babel}
\usepackage{rotating,tabularx,booktabs,caption}
\newcolumntype{C}{>{\centering\arraybackslash}X} % centered version of "X" column

\begin{document}

\begin{sidewaystable}
\caption{[table caption here]} 
\label{tab:some_table}
\begin{tabularx}{\textwidth}{@{} l*{10}{C} @{}}
\toprule
& \multicolumn{4}{c}{CD} & \multicolumn{6}{c@{}}{ONU} \\
\cmidrule(lr){2-5} \cmidrule(l){6-11}
& Momento & Oeste & Norte & Este & Sur & Chileno &  Latino\-americano &  Lejano Este &  Sur Asia &  General \\ 
\midrule
1898 & 40.68 & 45.79 & 45.88 & 45.12 & 45.75 & 47.12 & 46.36 & 47.66 & 46.03 & 46.75 \\ 
1903 & 42.15 & 47.47 & 47.56 & 46.83 & 47.53 & 48.96 & 48.17 & 49.61 & 47.77 & 48.60 \\ 
1908 & 43.67 & 49.22 & 49.32 & 48.64 & 49.38 & 50.88 & 50.05 & 51.62 & 49.58 & 50.52 \\ 
1913 & 45.25 & 51.08 & 51.18 & 50.54 & 51.31 & 52.85 & 51.99 & 53.71 & 51.45 & 52.52 \\ 
1918 & 46.88 & 53.05 & 53.16 & 52.54 & 53.32 & 54.89 & 54.00 & 55.87 & 53.39 & 54.58 \\ 
\addlinespace
1923 & 48.54 & 55.15 & 55.27 & 54.64 & 55.40 & 56.97 & 56.06 & 58.08 & 55.39 & 56.70 \\ 
1928 & 50.24 & 57.38 & 57.43 & 56.82 & 57.54 & 59.09 & 58.17 & 60.34 & 57.44 & 58.87 \\ 
1933 & 51.97 & 59.66 & 59.64 & 59.07 & 59.72 & 61.23 & 60.31 & 62.61 & 59.51 & 61.07 \\ 
1938 & 53.72 & 61.98 & 61.88 & 61.38 & 61.93 & 63.37 & 62.46 & 64.88 & 61.60 & 63.28 \\ 
1943 & 55.48 & 64.34 & 64.13 & 63.72 & 64.13 & 65.50 & 64.60 & 67.13 & 63.68 & 65.48 \\ 
\addlinespace
1948 & 57.24 & 66.70 & 66.37 & 66.08 & 66.32 & 67.59 & 66.71 & 69.31 & 65.75 & 67.64 \\ 
1953 & 59.00 & 69.04 & 68.57 & 68.42 & 68.45 & 69.62 & 68.78 & 71.41 & 67.78 & 69.74 \\ 
1958 & 60.74 & 71.32 & 70.73 & 70.73 & 70.52 & 71.59 & 70.78 & 73.42 & 69.76 & 71.77 \\ 
1963 & 62.46 & 73.51 & 72.82 & 72.97 & 72.50 & 73.47 & 72.70 & 75.30 & 71.67 & 73.71 \\ 
1968 & 64.16 & 75.58 & 74.82 & 75.10 & 74.35 & 75.23 & 74.52 & 77.04 & 73.49 & 75.52 \\ 
\addlinespace
1973 & 65.81 & 77.52 & 76.72 & 77.08 & 76.10 & 76.89 & 76.23 & 78.66 & 75.23 & 77.22 \\ 
1978 & 67.43 & 79.28 & 78.47 & 78.90 & 77.72 & 78.42 & 77.82 & 80.11 & 76.84 & 78.78 \\ 
1983 & 68.99 & 80.86 & 80.07 & 80.52 & 79.23 & 79.85 & 79.30 & 81.44 & 78.37 & 80.22 \\ 
1988 & 70.51 & 82.23 & 81.46 & 81.94 & 80.59 & 81.13 & 80.63 & 82.61 & 79.75 & 81.51 \\ 
1993 & 71.96 & 83.43 & 82.69 & 83.21 & 81.84 & 82.31 & 81.87 & 83.68 & 81.03 & 82.69 \\ 
1998 & 73.36 & 84.46 & 83.73 & 84.29 & 82.95 & 83.36 & 82.97 & 84.60 & 82.18 & 83.72 \\ 
\bottomrule
\end{tabularx}
\end{sidewaystable}

\end{document}
1
  • Mico, thank so much! How can i set the caption (and the source) to the left and center and put the headlines in the middle (no white space) Dec 9, 2015 at 18:24

You must log in to answer this question.

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