1

how is it possible to control the column width in a table having a very long text without space.

\begin{table}
  \begin{tabular}{l p{2cm}}
    datapath & /home/username/path/to/directory/very/long
 \end{tabular}
\end{table}

p{2cm} only works if the second column element was something like /home/ username/ path/ to/ directory /very /long. Am I doing something wrong here ?

4
  • 1
    use hyperref or url package then \url{/home/username/path/to/directory/very/long} to allow url to linebreak Sep 17, 2014 at 15:30
  • yes this works but I just did not want them to appear as hyperlink.
    – pasha
    Sep 17, 2014 at 16:09
  • Do you only want it to break on / or wherever the 2cm boundary falls? Sep 17, 2014 at 17:01
  • url package doesn't make it a link (hyoerref does by default, or you could turn that off probably) Sep 17, 2014 at 18:32

1 Answer 1

1

Borrow the idea from David but use \path instead (since it is a path)

\documentclass{article}
\usepackage{url}
\begin{document}
  \begin{table}
  \begin{tabular}{l p{2cm}}
    datapath & \path{/home/username/path/to/directory/very/long}
 \end{tabular}
\end{table}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .