I'm trying to link a directory from a server in my document, and because it's Windows notation, only backslashes are allowed: \\server\path\to\dir.

However using the hyperref package, I can't get this to work.

\href{run:\backslash\backslash server\backslash path\backslash to\backslash dir}{link}

results in odd escape characters, and

\href{run:\textbackslash\textbackslash server\textbackslash path\textbackslash to\textbackslash dir}{link}

results in a compilation error. Any help please?

Edit: Since this document is for internal use only, it's mainly a question of backslashes in URLs since this is the escape character.

  • Have you tried it with /? – Werner May 4 '17 at 16:57
  • 1
    Yes, / is not a valid notation for accessing the directory unfortunately. – Joshua Detwiler May 4 '17 at 16:59
  • Doesn't \href{run:\\\\server\\path\\dir}{link} work? – Ulrike Fischer May 4 '17 at 17:24
  • Oh I see, that does work. I thought \\ was a way of introducing newlines, not the backslash escape. – Joshua Detwiler May 4 '17 at 17:34
  • not that it matters but that that isn't a URL, URL always use / it's a local file path. – David Carlisle May 4 '17 at 17:46

You can use \\ to escape the backslash:

  • Is there around having to use `\`? It's tedious to have to copy URLs and manually add the additional backslash. Seems like a major shortcoming of the command. – Lloyd Christmas Mar 26 '18 at 19:52

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.