0

@LaTeX-class-file

filename = "harvard-thesis.cls",

version = "0.4",

date = "4 April 2012",

codetable = "ISO/ASCII"

As you can see in this example, my table exced the widht of the text document. My intention is to adjust the table widht to the text column in the whole doc.

\documentclass{harvard-thesis}
\captionsetup{labelfont=\rmdefault, textfont=\rmdefault }

\begin{document}

\begin{table}
\centering
\begin{tabular}{@{}lll@{}}\toprule[1.5pt]
\bf Periodista & \bf Medio & \bf Cargo \\\midrule

Sample name surname &  Sample medium & Other text. Responsable de Participación, redes y Comunidad \\ 
Sample name surname &  Sample medium & Other text. Responsable de Participación, redes y Comunidad \\ 
Sample name surname &  Sample medium & Other text. Responsable de Participación, redes y Comunidad \\ 
Sample name surname &  Sample medium & Other text. Responsable de Participación, redes y Comunidad \\ 

\bottomrule[1.25pt]
\end {tabular}\par
\captionof{table}{Periodistas participantes}
\label{tab:periodistas}
\end{table}

\end{document}

Sample above

Torbjørn T.
  • 206,688
  • 1
    Please provide (part of) the real table. There are numerous ways, starting from the proper column type allowing line breaks, modifying intercolumn space, using smaller fonts, turning the table by 90 degrees, shrinking everything (last resort), etc. Google for latex fit table to page site:tex.stackexchange.com and you will find many examples. There is even a page collecting all methods (by Werner?) which I can't find at the moment. – gernot Dec 02 '16 at 14:01
  • 6

1 Answers1

0

Use the tabularx package.

You can define the width of a column as being a percentage of \textwidth and that way, the text will be formatted as a paragraph and have linebreaks. To do this, just use p{<width>} in place of l...

Two columns:

\begin{tabularx}{\textwidth}{|p{0.5\textwidth}|p{0.5\textwidth}|}

Three Columns:

\begin{tabularx}{\textwidth}{|p{0.33\textwidth}|p{0.33\textwidth}|p{0.33\textwidth}|}

Table example:

\begin{center}
\begin{tabularx}{\textwidth}{|p{0.33\textwidth}|p{0.33\textwidth}|p{0.33\textwidth}|}
\hline
Label Sample                                               & Label Sample                                               & Label Sample                                               \\ \hline
a & b & c \\ \hline
Protoctista wave equations telegrapher's equations Maxwell & Protoctista wave equations telegrapher's equations Maxwell & Protoctista wave equations telegrapher's equations Maxwell \\ \hline
Protoctista wave equations telegrapher's equations Maxwell & Protoctista wave equations telegrapher's equations Maxwell & Protoctista wave equations telegrapher's equations Maxwell \\ \hline
a & bbbbbb bbbbbbbb bbbbbbbbbbbbbbbbbbbbb bbbbbbbbbbbl &  c \\ \hline
\end{tabularx}
\end{center}
smollma
  • 311
  • 1
    For that to have any effect one must have at least one X column. – Torbjørn T. Dec 02 '16 at 14:37
  • 2
    This will produce an overfull hbox since the column separation also takes space. Replace the column specifiers p{...} by X; otherwise you can use an ordinary tabular environment (which will produce the same warning). – gernot Dec 02 '16 at 15:26