I am using longtable and I cannot find a way to adjust its column spacing. I want a table like this:

enter image description here

But I am getting this:

enter image description here

This is what I am doing for defining table size:

 \begin{longtable}{p{.1\textwidth} p{.2\textwidth} p{.2\textwidth}p{.3\textwidth}}
    xxxxx & xxxxx & xxx & xxxxx\\
  • Welcome! I'm afraid I don't understand the question. The second image seems to include 3 tables? Which one is the one you want to look like the first image? Could you please give us a small compilable document which produces a table with the layout you get now and explain exactly what changes you would like to implement? – cfr Jun 29 '15 at 19:23
  • Just look at the serial numbers, you will understand. I am using longtable for a table over multiple pages. I want to reduce the spacing between columns. – MrSingh Jun 29 '15 at 19:39
  • 1
    The first three columns should be l and the last column wants to be p{some wider value} – David Carlisle Jun 29 '15 at 20:19
  • @DavidCarlisle may be the 2 nd column is also p{length} – touhami Jun 29 '15 at 22:36
  • @touhami looks like a single compound word, so if you wanted to allow breaking, would need url package or similar to allow breaking on _ – David Carlisle Jun 29 '15 at 22:44

Package ltxtable allows the combination of longtable with tabularx column type X. The latter is useful for the last column with the description text. The first columns can be set via column type l. The indentation in the description part can be achieved via \hangindent and \hangafter (assuming there is only one paragraph).

Since the package ltxtable requires a separate file for the table, package filecontents is used, which allows the environment filecontents inside the document body. Also the file is overwritten each time and is therefore uptodate.

The larger line spacing between rows is achieved by redefining \arraystretch.



\begin{longtable}{lll>{\hangindent=1em\hangafter=1 }X}
\caption{Some parameters}\\
\# & Name & Type & Description \\
\# & Name & Type & Description \\
f1 & duration & Integer
  & Duration of the connection\\
f2 & protocol\_type & Nominal
  & Protocol type of the connection: TCP, UDP, ICMP\\
f3 & service & Nominal
  & http, ftp, smtp, telnet, \dots\ and others\\
f4 & flag & Nominal
  & Connection status: SF, S0, S1, S2, S3, OTH, REJ, RSTO, RSTOS0, SH,
f5 & src\_bytes & Integer
  & Bytes sent in one connection\\
f6 & dst\_bytes & Integer
  & Bytes received in one connection\\
f7 & land & Binary
  & If source and destination IP addresses and port numbers
  are equal, this variable is~1, else~0\\




Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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