1

I am trying to link to a directory while being in a tabular environment. The path of the directory usually is pretty long and should linebreak at the boarders of the table. Additionally it would be great if the directory opens (on Windows machines) clicking on a link (or the directory-string itself).

I tried following code:

\documentclass[10pt]{article}
\usepackage{a4,graphicx}
\usepackage[hyphens]{url}
\usepackage{hyperref}

\begin{document}

\begin{tabular}{|ll|}
\hline   
\parbox{60mm}{\bf desiredOutput:} & \parbox[t]{80mm}{\url{\\\\this\\is\\my\\veryLongDirectory\\which\\should\_be\_lineBreaking\\only\_at\_the\_boarders\_of\\my\\table\\ABC\_abc\_DEF\_def}} \\
\parbox{60mm}{\bf withRef:}       & \parbox[t]{80mm}{\href{run:\\\\this\\is\\my\\veryLongDirectory\\which\\should\_be\_lineBreaking\\only\_at\_the\_boarders\_of\\my\\table\\ABC\_abc\_DEF\_def}{open dir works only here...}} \\
\parbox{60mm}{\bf badOutput:}     & \parbox[t]{80mm}{'\\\\this\\is\\my\\veryLongDirectory\\which\\should\_be\_lineBreaking\\only\_at\_the\_boarders\_of\\my\\table\\ABC\_abc\_DEF\_def'} \\
\hline
\end{tabular}

\end{document}

which gives me this output: enter image description here

In this example the produced string for the desiredOutput line is good although I would like to have the option to remove the box around the string. Also I don't want to open a browser on click. Therefore I created the reference which works fine (see line withRef).

How can I produce my desired links?

5
  • 2
    Have you tried \usepackage[colorlinks=true,breaklinks=true]{hyperref}?
    – user31729
    Oct 8, 2014 at 11:49
  • Thx @ChristianHupfer I didn't find those options. This just removes the boarder of the box which is nice. But what I want is a combination of the first two lines of the uploaded picture. Oct 8, 2014 at 11:59
  • 1
    See my answer, but I am not sure if this is what you requested
    – user31729
    Oct 8, 2014 at 12:41
  • 2
    You shouldn't use all this \parbox in the tabular. use the p-column type instead. Oct 8, 2014 at 13:15
  • @UlrikeFischer: That's true... I will update my answer according to your objection ;-)
    – user31729
    Oct 8, 2014 at 13:34

1 Answer 1

2

I am not sure if this is the desired feature:

The action (run/open) can be done using \href{run:url}{some text} and the the text as a url can be obtained using \nolinkurl{urlcontent}

\documentclass[10pt]{article}
\usepackage{a4,graphicx}
\usepackage[hyphens]{url}
\usepackage[colorlinks,breaklinks=true]{hyperref}

\begin{document}

\newcommand{\somecommand}[1]{%
\href{run:#1}{\nolinkurl{#1}}%
}%

\begin{tabular}{|ll|}
\hline
\parbox{60mm}{\bf Really desiredOutput??} & \parbox[t]{80mm}{\somecommand{\\\\this\\is\\my\\veryLongDirectory\\which\\should\_be\_lineBreaking\\only\_at\_the\_boarders\_of\\my\\table\\ABC\_abc\_DEF\_def}} \\
\tabularnewline
\hline
\tabularnewline
\parbox{60mm}{\bf desiredOutput:} & \parbox[t]{80mm}{\url{\\\\this\\is\\my\\veryLongDirectory\\which\\should\_be\_lineBreaking\\only\_at\_the\_boarders\_of\\my\\table\\ABC\_abc\_DEF\_def}} \\
\parbox{60mm}{\bf withRef:}       & \parbox[t]{80mm}{\href{run:\\\\this\\is\\my\\veryLongDirectory\\which\\should\_be\_lineBreaking\\only\_at\_the\_boarders\_of\\my\\table\\ABC\_abc\_DEF\_def}{open dir works only here...}} \\
\parbox{60mm}{\bf badOutput:}     & \parbox[t]{80mm}{'\\\\this\\is\\my\\veryLongDirectory\\which\\should\_be\_lineBreaking\\only\_at\_the\_boarders\_of\\my\\table\\ABC\_abc\_DEF\_def'} \\
\hline
\end{tabular}

\end{document}

enter image description here

4
  • This is exactly what I was looking for! Just two points: The coloring isn't OK but well I implemented urlcolor=black which works fine. What's not working is, that my string is named \\\\this\\is\\my... and not like in your picture. Oct 8, 2014 at 13:39
  • @EverythingRightPlace: Well, the color is your choice, I could not know of that, and for the `\\\` stuff: I will look later on
    – user31729
    Oct 8, 2014 at 13:40
  • I never asked for colored font ;) But everything is fine, the point with the wrong backslash is wondering me, because I use the same code. But it's not so important because I can simply use two different entries for the shown url and the used url for linking. Once again, thx! Oct 8, 2014 at 13:56
  • Btw. I have to change the filecolor, not the urlcolor! See en.wikibooks.org/wiki/LaTeX/Hyperlinks Oct 8, 2014 at 15:00

You must log in to answer this question.

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