3

I'm new at LaTEX. I'm learning it by myself so this maybe is a beginner problem. I'm getting the warning:

Underfull \hbox (badness 10000) in paragraph at lines

In this code:

\documentclass{article}

\begin{document}
\begin{table}[]
\centering

\begin{tabular}{|p{5.5cm}|p{4cm}|p{4cm}|}
\hline
\multicolumn{1}{|c|}{\textbf{Name}} &
\multicolumn{1}{|c|}{\textbf{OPt 1}} & 
\multicolumn{1}{|c|}{\textbf{Opt2}} \\ \hline

 Entorno   & Fibra ADSL (velocidad?) con router ?  &  SIM ?Vodafone? \\ \hline
 Entorno    & Fibra (velocidad?), router ? & SIM ?vodafone? \\ \hline
 Entorno        & Wifi velocidad? & SIM ?vodafone? \\ \hline
 Entorno     & WiFi velocidad? & SIM core ? \\ \hline
 Entorno   & Conexión TCP Wifi. &  Ethernet entre dos ordenadores Toshiba Tecra. \\ \hline

\end{tabular}
\caption{Tabla resumen de entornos}
\label{tab:una}
\end{table}
\end{document}

And I don't know what's wrong here, can you help me?

David Carlisle
  • 757,742
dgr
  • 31
  • Welcome to TeX.SX! Have a look at this post. – TeXnician Feb 22 '17 at 10:33
  • I completed your example to be a document so that people can run it and see the problem but it does not generate the message shown, it warns about the [] option LaTeX Warning: No positions in optional float specifier. and that the table is too wide Overfull \hbox (75.11218pt too wide) in paragraph at lines 7--20 but no underfull box warning. The warning you show almost always comes from \\ being mis-used at the end of a paragraph but you do not have any use of \\ outside tables in the code you posted. – David Carlisle Feb 22 '17 at 10:37
  • 1
    unrelated but \multicolumn{1}{|c|} should be \multicolumn{1}{c|} except in the first column otherwise you get doubled lines, one at the right edge of column 1 and a second at the left edge of column 2 – David Carlisle Feb 22 '17 at 10:41
  • I can't reproduce the error. I have an overfull \hbox instead. – Bernard Feb 22 '17 at 13:33

1 Answers1

3

The underfull box problem, as @TeXnician and @DavidCarlisle pointed out, is certainly due to other portions of your code, and probably related to terminating paragraph with \\ instead of \par or an empty line.


Regarding the problems that your code does show, here are some remarks.

The main problem, as the people in the comments have specified are that:

  1. you give an empty [] option to table (it's better to leave out the entire optional parameter then)
  2. you have a table that is too wide for the page
  3. As @DavidCarlisle pointed out \multicolumn{1}{|c|} should become \multicolumn{1}{c|} to avoid double lines.

Possible solutions

The part 2 problem is the hardest to solve, especially if you really want the table cells to be that wide. I will propose a couple of solutions which can, or can not be acceptable to you.

Meddling with paper and keeping the separator (not optimal)

The easiest one is just to enlarge the margins and specify some paper size. I did this with a4paper, and loading the geometry package with a4paper option. For this (fairly common in Europe) papersize, it is sufficient to do the job, provided that you compress a bit one of the columns (I chose the last one, by 2mm).

I also loaded array and ragged2e, in order to define columns that are ragged right, which is good solution for something so confined as your table. I'm providing this solution just as a reference, and I don't think it's good typography

\documentclass[a4paper]{article}
\usepackage[a4paper]{geometry}
\usepackage{array,ragged2e}
\newcolumntype{P}[1]{>{\RaggedRight\arraybackslash}p{#1}}
\begin{document}
\begin{table}
\centering

\begin{tabular}{|P{5.5cm}|P{4cm}|P{3.8cm}|} \hline \multicolumn{1}{|c|}{\textbf{Name}} & \multicolumn{1}{c|}{\textbf{OPt 1}} & \multicolumn{1}{c|}{\textbf{Opt2}} \ \hline

Entorno & Fibra ADSL (velocidad?) con router ? & SIM ?Vodafone? \ \hline Entorno & Fibra (velocidad?), router ? & SIM ?vodafone? \ \hline Entorno & Wifi velocidad? & SIM ?vodafone? \ \hline Entorno & WiFi velocidad? & SIM core ? \ \hline Entorno & Conexión TCP Wifi. & Ethernet entre dos ordenadores Toshiba Tecra. \ \hline

\end{tabular} \caption{Tabla resumen de entornos} \label{tab:una} \end{table} \end{document}

enter image description here

Better typography (reducing also width)

A fair and square solution to your table impagination problem would require many more information and also the understanding of what you need. As a general solution, I think it's safe to proceed using the following steps:

  1. remove vertical separators. They're ugly, almost never serve a purpose other than making the table less readable
  2. making the first column width automatically calculated
  3. using the booktabs separators to make a more professional look

So here is the code

\documentclass[a4paper]{article}
\usepackage[a4paper]{geometry}
\usepackage{array,booktabs,ragged2e}
\newcolumntype{P}[1]{>{\RaggedRight\arraybackslash}p{#1}}
\begin{document}
\begin{table}
\centering

\begin{tabular}{lP{4cm}P{4cm}} \toprule \multicolumn{1}{c}{\textbf{Name}} & \multicolumn{1}{c}{\textbf{OPt 1}} & \multicolumn{1}{c}{\textbf{Opt2}} \ \midrule

Entorno & Fibra ADSL (velocidad?) con router ? & SIM ?Vodafone? \ Entorno & Fibra (velocidad?), router ? & SIM ?vodafone? \ Entorno & Wifi velocidad? & SIM ?vodafone? \ Entorno & WiFi velocidad? & SIM core ? \ Entorno & Conexión TCP Wifi. & Ethernet entre dos ordenadores Toshiba Tecra. \ \bottomrule \end{tabular} \caption{Tabla resumen de entornos} \label{tab:una} \end{table} \end{document}

And a peek:

enter image description here

Moriambar
  • 11,466