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 ?

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

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.