I'm using the package longtable
to define a table in two pages but it has too much width when I write long text in a cell that fills until the border of the page and doesn´t have room for all the text. Is there a way to fix or limit the width of the table or make the text fill in some lines?
I´ve just used double '\' to fill the long lines in many lines but there is a big space between them. Here is the code that i´ve used
\begin{longtable}{lp{5cm}lp{5cm}lp{5cm}}
\hline
Característica & DDS & MQTT \\
\hline
\endfirsthead
\hline
Característica & DDS & MQTT \\
\hline
\\
\endhead
\multicolumn{3}{c}{(Continúa en la página siguiente)} \\
\endfoot
\multicolumn{3}{c}{(Fin del Cuadro)} \\
\endlastfoot
%Aqui añadimos el cuerpo de la tabla
\\
Abstracción & Publicación/Suscripción & Publicación/Suscripción \\
\\
Arquitectura & Descentralizada (\emph{Global Data Space}) & Broker \\
\\
API & Si & No \\
\\
QoS & 22 & 3 \\
\\
Interoperabilidad & Si & Parcial \\
\\
Rendimiento & Más de 1000 mensajes fiables por segundo por suscriptor & Típicamente desde cientos \\
& & (persistentes) hasta más de \\
& & 1000 (\emph{best effort}) mensajes \\
& & por segundo por suscriptor \\
\\
\emph{Real-Time} severo & Si & No \\
\\
Transporte & UDP por defecto (otros transportes como TCP pueden ser también usados) & TCP \\
\\
Control de suscripción & Particiones, tópicos con filtrado de mensajes & Tópicos con coincidencia \\
& & jerárquica \\
\\
Filtrado & Contenido/Tiempo & No \\
\\
Serialización de datos & CDR & N/A \\
\\
Estándares & RTPS y DDSI de OMG & Propuesto por OASIS el \\
& & estándar MQTT \\
\\
Codificación & Binaria & Binaria \\
\\
Modelo de licencia & Open Source y Licencia Comercial & Open Source y Licencia \\
& & Comercial \\
\\
Descubrimiento dinámico & Si & No \\
\\
Dispositivos móviles & Si & Si \\
(Android, iOS) & & \\
\\
Dispositivos 6LoWPAN & Si & Si \\
\\
Transacciones multifase & No & No \\
Seguridad & Específica del vendedor pero típicamente basada en SSL o TLS con control de acceso propietario & Simple Nombre de \\
& & usuario/Password, \\
& & Autenticación, SSL para \\
& & cifrado de datos \\
\\
\hline
\\
\caption{Comparativa de características entre DDS y MQTT.}
\label{ta:comparativa-dds-mqtt}
\end{longtable}
And this is a piece of the result:
Best Answer
Thanks for posting the code of your
longtable
environment. It would appear that the main problem is that whereas you intend to have three columns (each allowing text to wrap), you're currently specifying a total of six columns, alternatingl
andp
types.In addition to specifying just three columns (and removing the hard line breaks), I'd like to suggest making the following changes:
Since the column widths are quite narrow (5cm or less), it's probably better not to try to fully justify the contents, as doing so may create lines of text with very wide interword spaces. Better to use the
ragged2e
package and define a new column type that uses\RaggedRight
instead of full justification. In the code below, I use the\newcolumntype
instruction (which is provided by thearray
package) to create a new column type calledP
, which behaves very much like thep
type except that the contents will be typeset raggedright while allowing hyphenation.Instead of
\hline
, consider using the rule-drawing macros of thebooktabs
package, e.g.,\toprule
and\midrule
.(first page)
(second page)