2

I know this How to typeset a file path? I think that the PATH command works like making possible to use shorter PATH in URLs. I have documents in my filesystem which I often include in my notes. I would like to assign their folder location by the path -command. However, I am not sure if I use the right function because of unexpected result below.

Code

\documentclass{article}
\usepackage[obeyspaces]{url}
\begin{document}

\path{/Users/masi/Dropbox/Internal Diseases}

\url{PubMed Central, Table 3_ Diabetes Care. 2010 Jan; 33(Suppl 1)_ S62–S69. doi_  10.pdf} 

\end{document}

Output:

/Users/masi/Dropbox/Internal Diseases

PubMed Central, Table 3_ Diabetes Care. 2010 Jan; 33(Suppl 1)_ S62–S69. doi_  10.pdf 

Expected output:

/Users/masi/Dropbox/Internal Diseases/PubMed Central, Table 3_ Diabetes Care. 2010 Jan; 33(Suppl 1)_ S62–S69. doi_  10.pdf

2nd example having pseudocode

\documentclass{article}
\usepackage[obeyspaces]{url}
\begin{document}

\somePathCommand{/Users/masi/Dropbox/Internal Diseases}

\someHrefCommand{PubMed Central, Table 3_ Diabetes Care. 2010 Jan; 33(Suppl 1)_ S62–S69. doi_  10.pdf}{Diabetes Guideline}

\end{document}

which should print the link Diabetes Guideline i.e. having redirection to:

/Users/masi/Dropbox/Internal Diseases/PubMed Central, Table 3_ Diabetes Care. 2010 Jan; 33(Suppl 1)_ S62–S69. doi_  10.pdf

How can you typeset correctly the file path? I.e. use it with images, and do not print the actual path in the document as text.

  • 4
    Sorry, I have not understood the question. Both the \url command as the \path command work as expected. What's wrong with the outcome of \path{/Users/masi/Dropbox/Internal Diseases} in the image? – Heiko Oberdiek Sep 11 '15 at 10:35
  • 1
    The question contains an image. The purpose of \path is to print the path and it does print it. What do you expect it to do otherwise? And what is the relation to \url? – Heiko Oberdiek Sep 11 '15 at 12:28
  • 2
    What do you expect \path{/Users/masi/Dropbox/Internal Diseases} to do other than typesetting the argument? – Heiko Oberdiek Sep 11 '15 at 12:36
  • What's wrong with \path{/Users/masi/Dropbox/Internal Diseases/PubMed Central, Table 3_ Diabetes Care. 2010 Jan; 33(Suppl 1)_ S62–S69. doi_ 10.pdf} or \url{/Users/masi/Dropbox/Internal Diseases/PubMed Central, Table 3_ Diabetes Care. 2010 Jan; 33(Suppl 1)_ S62–S69. doi_ 10.pdf}? – Heiko Oberdiek Sep 11 '15 at 12:41
  • 1
    Sorry, but your question is pretty unclear; what do you mean by “use it with images, and do not print the actual path in the document as text”? You claim to want to print the path and then not to. This is contradictory. – egreg Sep 11 '15 at 12:43
1

I'm not sure if I fully understand your objective. I can offer the following observations:

  • The url package defines \path as an "alias" for \url. Using \path may be more mnemonic than using \url if the argument is the name of a "path" rather than an ordinary URL.

  • There's one important difference, though, between \url and \path: If the hyperref package is loaded, the argument of a \url instruction will be made into a hyperlink, whereas that's not the case with \path.

  • If the path/url is a long and unwieldy string, and if you wish to show just a short stub instead, be sure to load the hyperref package and to use that package's \href macro. This macro takes two arguments: (i) a URL-like string, and (ii) the "stub" that should be shown in the pdf file instead of the URL-like string.

enter image description here

% !TEX TS-program = xelatex
\documentclass{article}
\usepackage{fontspec}
\usepackage[spaces,obeyspaces]{url}
\usepackage[colorlinks=true,allcolors=blue]{hyperref}
\setlength\parindent{0pt} % just for this example
\begin{document}
output of \verb+\path+:

\path{/Users/masi/Dropbox/Internal Diseases/PubMed Central, Table 3_ Diabetes Care. 2010 Jan; 33(Suppl 1)_ S62–S69. doi_  10.pdf}

\bigskip
output of \verb+\url+:

\url{/Users/masi/Dropbox/Internal Diseases/PubMed Central, Table 3_ Diabetes Care. 2010 Jan; 33(Suppl 1)_ S62–S69. doi_  10.pdf}

\bigskip
output of \verb+\href+:

\href{/Users/masi/Dropbox/Internal Diseases/PubMed Central, Table 3_ Diabetes Care. 2010 Jan; 33(Suppl 1)_ S62–S69. doi_  10.pdf}{stub}
\end{document}
  • The output of the stub is wanted but without typing the preceding path /Users/masi/Dropbox/Internal Diseases/ every time. Is that possible? – Léo Léopold Hertz 준영 Sep 11 '15 at 13:08
  • If you don't want to show the substring /Users/masi/Dropbox/Internal Diseases/, just omit it from the argument of \url or \path. – Mico Sep 11 '15 at 13:15
  • I must confess I don't understand why you would want to show a long and complicated filename instead of a suitable stub, such as "Diabetes Care, 2010". Why would anyone care to be shown the full filename? – Mico Sep 11 '15 at 13:18
  • I want to create a link to the path (complete link) but show just a stub. I do not want to write long PATHs to my notes. – Léo Léopold Hertz 준영 Sep 11 '15 at 13:21
  • 1
    I think he is looking for href to link to the paper. Oh, already in the answer. Maybe set a macro for the filepath to use in href (if possible). – Johannes_B Sep 11 '15 at 13:54

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.