1

I need help. How can I fix this problem with taburlax not fit on page? If I use tabular and width=\textwidth, it works but the text on the table stays very small.

obs: I looked for similar posts here but none of them helped me to fix it.

Table not fit on page

\begin{table}[H]
  \caption{Quantidade de Votos. Elaborado por Autor. 2018.}
    %\begin{adjustbox}{width=\textwidth}
    \renewcommand{\arraystretch}{2.5}
        \begin{tabularx}{\textwidth}{|*{11}{c|}} %{\linewidth}{*{11}{|c}|} %{|l|c|c|c|c|c|c|c|c|c|c|}
        \hline
        \multicolumn{1}{|c|}{\textbf{Número}} & \textbf{Candidato a Vereador}    & \textbf{Partido} & \textbf{Coligação} & \textbf{Situação} & \textbf{\makecell{Votos Nominais \\ Zona 146}} & \textbf{Votos Válidos na Zona} & \textbf{\% de Votos Válidos na Zona} & \textbf{Colocação Geral} & \textbf{Votos Totais Goiânia} & \textbf{NEM (Concentração/Dispersão)} \\ \hline
        90100  & Vinicius Cirqueira        & PROS                      & PROS & Eleito & 5431 & 64908 & 8.37 & 3 & 88582 & 3.08                                          \\ \hline
        44444  & Jorge Kajuru              & PRP                       & DEM/PRP & Eleito & 3154 & 64908 & 4.86 & 1 & 37796 & 23.31                                          \\ \hline
        19193  & Sargento Novandir        & PTN                      & PTN & Eleito & 1964 & 64908 & 3.03 & 65 & 2713 & 24.7                                          \\ \hline
        13680  & João Araujo              & PT                      & PT/PEN/PPL/PC do B & Suplente & 1947 & 64908 & 3 & 78 & 2305 & 13.02                                          \\ \hline
        22018  & Jorge                    & PR                      & PR/PMN & Suplente & 1890 & 64908 & 2.91 & 57 & 3044 & 37.51                                          \\ \hline
        45444  & Mauricio Beraldo        & PSDB                      & PSB/PSDB/PRB/SD & Suplente & 1775 & 64908 & 2.73 & 46 & 3472 & 17.36                                          \\ \hline
        \end{tabularx}
       \label{tab:quantidadeVotos6Candidatos}
    %\end{adjustbox}
\end{table}
  • Welcome to TeX SE! Please post a minimal working example so we can run your code. Let us know what packages you used (etc.) Thank you! – Jennifer Jul 30 '19 at 19:30
  • 1
    You're not using any X-type columns with the tabularx environment. – Mico Jul 30 '19 at 19:40
  • Your table contains 11 columns with quite long headers. You could introduce more lnebreaks in the headers, and/or use abbreviations. Additionally, your table is most likely still too wide to fit into a portrait page's text widt. You could therefore consider rotating the page to a landscape orientation. – leandriis Jul 30 '19 at 19:42
  • 2
    Please also tell us which document class you employ and how wide the textblock is. – Mico Jul 30 '19 at 19:45
  • Guys, I'm sorry I didn't said all the necessary so you can help me. @Mico answer helped me a lot. I really appreciate all the help here. – Guilherme Schults Jul 30 '19 at 20:50
2

Some suggestions:

  • Load the rotating package and use a sidewaystable environment instead of a table environment.

  • Allow line breaks in all columns that require them. The only columns where automatic line breaking is not necessary (or helpful) are columns 1, 3, and 5.

  • Use a centered version of the X column type for all other columns. Note that it's advantageous to make the final column slight wider than the others of type X: that way, none of the header cells need span more than 3 rows.

  • Replace all instances of / ("slash") with \slash. That way, line breaking can also take place after / symbols.

  • Give the tabular material a much more open "look" by (a) omitting all vertical rules and (b) most horizontal rules. I also suggest you dispense with bold-facing the header row. A well-designed tableau should not require bold-facing. Period.

These ideas are implemented in the following code.

enter image description here

\documentclass{article} % or some other suitable document class
\usepackage[T1]{fontenc}
\usepackage[portuguese]{babel}
\usepackage[a4paper,margin=2.5cm]{geometry} % choose page parameters
\usepackage{tabularx,rotating,ragged2e,booktabs}
\newcolumntype{C}[1]{>{\Centering\arraybackslash\hsize=#1\hsize}X}
\usepackage[skip=0.5\baselineskip]{caption}

\begin{document}

\begin{sidewaystable}
\caption{Quantidade de Votos. Elaborado por Autor. 2018.}
\label{tab:quantidadeVotos6Candidatos}

\setlength\tabcolsep{5pt} % default: 6pt
\begin{tabularx}{\textwidth}{@{} l C{0.97} c C{0.97} c *{5}{C{0.97}} C{1.21} @{}} 
\toprule
Número & Candidato a Vereador & Partido & Coligação & Situação & 
Votos Nominais Zona 146 & Votos Válidos na Zona & 
\% de Votos Válidos na Zona & Colocação Geral & Votos Totais Goiânia & 
NEM (Concentração\slash Dispersão) \\ 
\midrule
90100  & Vinicius Cirqueira& PROS & PROS & Eleito & 5431 & 64908 & 8.37 & 3 & 88582 & 3.08 \\ 
\addlinespace
44444  & Jorge Kajuru      & PRP  & DEM\slash PRP & Eleito & 3154 & 64908 & 4.86 & 1 & 37796 & 23.31 \\ 
\addlinespace
19193  & Sargento Novandir & PTN  & PTN & Eleito & 1964 & 64908 & 3.03 & 65 & 2713 & 24.7 \\ 
\addlinespace
13680  & João Araujo       & PT   & PT\slash PEN\slash PPL\slash PC do B & Suplente & 1947 & 64908 & 3 & 78 & 2305 & 13.02 \\ 
\addlinespace
22018  & Jorge             & PR   & PR\slash PMN & Suplente & 1890 & 64908 & 2.91 & 57 & 3044 & 37.51 \\ 
\addlinespace
45444  & Mauricio Beraldo  & PSDB & PSB\slash PSDB\slash PRB\slash SD & Suplente & 1775 & 64908 & 2.73 & 46 & 3472 & 17.36 \\ 
\bottomrule
\end{tabularx}
\end{sidewaystable}
\end{document}
  • thank you so much for your help. I'm new on making nice latex table. Can you please help me why my table stayed on vertical way on the page? I want it just like you did and showed here. What's causing my table to stay on vertical? – Guilherme Schults Jul 30 '19 at 20:49
  • @GuilhermeSchults - See the first item in the quick list I assembled: Your code employs a table environment, whereas mine uses a sidewaystable environment. – Mico Jul 30 '19 at 20:54
  • I saw that. I removed the table environment and did just like your code, and my table stayed on vertical. I don't know what could be. – Guilherme Schults Jul 30 '19 at 20:58
  • @GuilhermeSchults - I don't know which document class you employ or which other packages you load. (Moreover, my psychic divination skills are worthless.) Without these crucial bits of information, I'm simply not in a position to diagnose what's going on in your document, let alone suggest a cure. Sorry. – Mico Jul 30 '19 at 21:05
  • I'm using this packages: \usepackage{amsmath,amssymb,exscale} \usepackage{pgfgantt} \usepackage{quoting} \usepackage{makecell} \usepackage{multirow} \usepackage{array,booktabs,siunitx} \usepackage{tabularx} \usepackage{adjustbox} and my document class is \documentclass[relatorio, abnt] an specific one here. – Guilherme Schults Jul 31 '19 at 2:46

Not the answer you're looking for? Browse other questions tagged or ask your own question.