0

I am creating a table which has file name, source and destination file paths, and a short description of each file. The description and flag fields have spaces so the line break can be automatic.

MWE:

\documentclass[a4paper]{article}
\usepackage{tabu}
\usepackage{longtable}
\usepackage{lipsum}

\begin{document}
\begin{longtabu} to \linewidth {|X[1 , l ] |X[1 , l ] | X[1 , l ]| X[.2\linewidth , l ]| X[1 , l ]|}\firsthline\hline
    % -----------------These are headings----------------------------------%
    Filename & Source & Destination & Flag & Functions \\ \hline
    %
    \endfirsthead
    %
    \multicolumn{5}{c}%
    {{\bfseries  Continued from previous page}} \\ \hline
    %
    Filename & Source & Destination & Flag & Functions \\ \hline
    \endhead
    %
    \hline \multicolumn{5}{|r|}{{Continued on next page}} \\ \hline
    \endfoot
    %
    \hline
    \multicolumn{5}{|r|}{{Concluded}} \\ \hline
    \endlastfoot
    %-----------Headings end---------------------------------
    %--------------------------table body starts-------------------
    somereallylongpathtoafile & somereallyreallylongpathtoafile & somereallylongpathtoafile & somereallylongpathtoafile & description of the said file \\
    somereallylongpathtoafile & somereallyreallylongpathtoafile & somereallylongpathtoafile & somereallylongpathtoafile & description of the said file \\
    somereallylongpathtoafile & somereallyreallylongpathtoafile & somereallylongpathtoafile & somereallylongpathtoafile & description of the said file \\
    somereallylongpathtoafile & somereallyreallylongpathtoafile & somereallylongpathtoafile & somereallylongpathtoafile & description of the said file \\
    .
    .
    .
    %--------------------------table body ends-------------------
\end{longtabu}
%===============================================================
\end{document}

My question is:

What should be the ideal line break for a file path? Should it be at slashes (folders) or should it be within folder names? and how?

Also, in [a4paper]{article} class what is the \linewidth or \textwidth size? That way, I can fix the table column width and let the forced line break to happen.

Below is the output which I get.

A really long table with long file paths

abyshukla
  • 411

1 Answers1

1

Some elements that may help you :

  1. I think the best way is to make the hyphenation on the slashes.
  2. To view the values of \textwidth and \linewidth for a precise place in your document, you could use the package layout that may help you printing the values inside the output document (view code below).
  3. A way to help you making your hyphenations on your table is to use the url package (view code below).

Here is the code that prints the values of \textwidth and \linewidth in the output document at the specified place and that make the hyphenations for you :

\documentclass[a4paper]{article}
\usepackage{layouts}
\usepackage{url}
\begin{document}
textwidth: \printinunitsof{cm}\prntlen{\textwidth}

linewidth: \printinunitsof{cm}\prntlen{\linewidth}

\path{C:/salut/coucou/coucou/coucou/coucouc/coucou/coucou/coucou/coucou/coucou/coucou/coucou/coucou/coucou/coucou/coucou/coucou/coucou/coucou/coucou/coucou/coucou/coucou/coucou/coucou/coucou/coucou/coucou/coucou/}
\end{document}

And here is the output : enter image description here

EDIT

Concerning your example, somereallylongpathtoafile will not be treated by the url package if it doesn't contain slashes. So you may need some more stuff in this case.

Damien Dtx
  • 706
  • 4
  • 11
  • Lol, thank you. somereallylongpathtoafile is really of no use without the slashes. Btw, my Preamble has hyperref package too. Won't that conflict with url? – abyshukla Feb 23 '16 at 10:45
  • I haven't try it, but according to this post http://tex.stackexchange.com/questions/1863/which-packages-should-be-loaded-after-hyperref-instead-of-before, I would recommend to load hyperref add the end of your preamble. – Damien Dtx Feb 23 '16 at 10:49
  • Thanks for your post. It had me figured that 5 column table in an a4paper was a bad idea. So decided to use a3paper and the geometry package to change the page margins. The table now looks good. – abyshukla Feb 23 '16 at 11:27