3

I would like to know how to construct a table with 16 columns and that fit on one page. Can anybody help me?

\begin{center}

\begin{longtable}{|p{1.5cm}|p{1.5cm}|p{1.5cm}|p{1.5cm}|p{1.5cm}|p{1.5cm}|p{1.5cm}|p{1.5cm}|p{1.5cm}|p{1.5cm}|p{1.5cm}|p{1.5cm}|p{1.5cm}|p{1.5cm}|p{1.5cm}|p{1.5cm}|}
\caption{Trabalhos Selecionados após critérios de Seleção} 
\label{tab:laal} \\

\hline
\multicolumn{1}{|c|}{\textbf{Identificador}} &
\multicolumn{1}{c|}{\textbf{Autores}} & 
\multicolumn{1}{c|}{\textbf{Ano}} & 
\multicolumn{1}{c|}{\textbf{Titulo}} &
\multicolumn{1}{c|}{\textbf{Resumo}} & 
\multicolumn{1}{c|}{\textbf{Benefícios}} & 
\multicolumn{1}{c|}{\textbf{Limitações}} & 
\multicolumn{1}{c|}{\textbf{Padrão de Projeto}} & 
\multicolumn{1}{c|}{\textbf{Elementos/Padrões Arquiteturais}} & 
\multicolumn{1}{c|}{\textbf{Tecnologias (frameworks, APIs)}} & 
\multicolumn{1}{c|}{\textbf{Modelo de Acessibilidade}} & 
\multicolumn{1}{c|}{\textbf{Nível Acessibilidade}} & 
\multicolumn{1}{c|}{\textbf{Tipo de Deficiência}} & 
\multicolumn{1}{c|}{\textbf{Tecnologia Assistiva}} & 
\multicolumn{1}{c|}{\textbf{Linguagens}} & 
\multicolumn{1}{c|}{\textbf{Tipo de Avaliação}} 
\\ \hline
\endfirsthead

\multicolumn{16}{c}%
{{ \tablename\ \thetable{} -- continuação  da página anterior}} \\
\hline 
\multicolumn{1}{|c|}{\textbf{Identificador}} &
\multicolumn{1}{c|}{\textbf{Autores}} & 
\multicolumn{1}{c|}{\textbf{Ano}} & 
\multicolumn{1}{c|}{\textbf{Titulo}} &
\multicolumn{1}{c|}{\textbf{Resumo}} & 
\multicolumn{1}{c|}{\textbf{Benefícios}} & 
\multicolumn{1}{c|}{\textbf{Limitações}} & 
\multicolumn{1}{c|}{\textbf{Padrão de Projeto}} & 
\multicolumn{1}{c|}{\textbf{Elementos/Padrões Arquiteturais}} & 
\multicolumn{1}{c|}{\textbf{Tecnologias (frameworks, APIs)}} & 
\multicolumn{1}{c|}{\textbf{Modelo de Acessibilidade}} & 
\multicolumn{1}{c|}{\textbf{Nível Acessibilidade}} & 
\multicolumn{1}{c|}{\textbf{Tipo de Deficiência}} & 
\multicolumn{1}{c|}{\textbf{Tecnologia Assistiva}} & 
\multicolumn{1}{c|}{\textbf{Linguagens}} & 
\multicolumn{1}{c|}{\textbf{Tipo de Avaliação}} 
\\ \hline

\endhead

\hline \multicolumn{16}{|r|}{{Continua na próxima página}} \\ \hline
\endfoot

\hline \hline
\endlastfoot

\end{longtable}
\end{center}
Bernard
  • 271,350
  • you have forced every column to be 1.5cm wide (plus 12pt padding plus the width of vertical rules) so that may or may not fit on the page depending how wide your page is. As you have not provided a real example there is no information about the page size. – David Carlisle Jan 31 '18 at 18:35
  • see https://tex.stackexchange.com/questions/332902/my-table-doesnt-fit-what-are-my-options you might find it relavent. – Dan Jan 31 '18 at 18:36
  • 1
    unrelated to the width but never put longtable in a center environment – David Carlisle Jan 31 '18 at 18:36
  • 1
    The objective(s) of your query are quite confusing. In particular, if the entire table is supposed to fit on a single page, why do you employ a longtable environment -- which is sensible only if the tabular material should be allowed to span more than 1 page. Please advise. – Mico Jan 31 '18 at 19:52

1 Answers1

1

A preliminary remark: The title of your posting is confusing. You say you want to the tabular material to fit on a single page, but you also propose using a longtable environment -- strongly suggesting that the table will occupy more than one page.

Assuming the 16-column table indeed is supposed to fit on a single page, I can make the following suggestions:

  • Use landscape more. E.g., load the rotating package and use a sidewaystable environment.

  • Don't use fixed-width columns, e.g., p{1.5cm}. Instead, load the tabularx package and make LaTeX calculate the column widths dynamically; use either a standard X column type or, as is done below, use a centered version of the X column type. To get a centered version, I suggest you load the ragged2e package and use a \Centering directive instead of the basic LaTeX \centering macro. (What's the difference, you may ask. \Centering permits hyphenation, whereas \centering does not.)

  • Don't use \multicolumn{1}{c}{...} wrappers for the contents of the header cells, as doing so will disallow linebreaks.

  • Don't use bold text for the header cells. A well-designed table shouldn't require to fall back on such methods.

  • Reduce the value of \tabcolsep, to allow more usable (horizontal) space in each cell.

The result of these suggestions:

enter image description here

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[margin=1in,letterpaper]{geometry}
\usepackage[portuguese]{babel}

\usepackage{tabularx,ragged2e,rotating}
\newcolumntype{C}{>{\hspace{0pt}%
    \Centering\arraybackslash}X}
\usepackage[skip=0.333\baselineskip]{caption}

\begin{document}
\begin{sidewaystable}
\setlength\tabcolsep{2pt} % default is '6pt'
\setlength\extrarowheight{2pt}
\caption{Trabalhos Selecionados após critérios de Seleção} 
\label{tab:laal} 
\begin{tabularx}{\textwidth}{|*{16}{C|}}
\hline
Identificador &
Autores & 
Ano & 
Titulo &
Resumo & 
Benefícios & 
Limitações & 
Padrão de Projeto & 
Elementos\slash Padrões Arquiteturais & 
Tecnologias (frame\-works, APIs) & 
Modelo de Acessibilidade & 
Nível Acessibilidade & 
Tipo de Deficiência & 
Tecnologia Assistiva & 
Linguagens & 
Tipo de Avaliação \\ 
\hline
\end{tabularx}

\end{sidewaystable}
\end{document}
Mico
  • 506,678