2

I want to write URLs, but the stylesheet cannot be used with url or hyperref packages. Then if I copy the urls from my pdf file and paste them to the browser, tilde symbols become %2(+a weird character which looks like o with something on it) and I cannot reach the websites. What should I do with this problem?

  • %7e is nothing but ascii tilde... On my browser it automatically becomes ~ – Symbol 1 Sep 30 '16 at 3:58
  • %7e is the precent encodnig ( en.wikipedia.org/wiki/Percent-encoding ) of ~. However, does this question help you or answer your problem? tex.stackexchange.com/questions/10858/url-with-tilde-character – Ronny Sep 30 '16 at 4:54
  • 1
    You'll need to give us more details: all that url does is define \url and appropriate mechanisms to print URLs, so there's no obvious need for an alternative! – Joseph Wright Sep 30 '16 at 5:15
  • 2
    I am not aware that package url conflicts with other packages. What's the problem? – Heiko Oberdiek Sep 30 '16 at 5:56
  • 3
    @Nickel Please edit in an example: as Heiko says, it's hard to imagine a set up where url is not usable. – Joseph Wright Sep 30 '16 at 5:59
3

A primitive way of writing URLs is the \verb command:

\verb|http://example.org/~user/index.html#start|

Of course, this does not create any link, package hyperref can do this. But, some PDF viewers use a heuristics to detect links in text.

| improve this answer | |
2

Allows line breaking at /, -, _ and ~ characters (more can be added). I added sloppypar, since even this many breakpoints may stress the flushing algorithms.

\documentclass{article}
\usepackage[nopar]{lipsum}
%%%%%%%%%%%
\newcommand\fauxurl[1]{\bgroup\ttfamily\fauxurlhelp#1\relax\relax\egroup}
\def\fauxurlhelp#1#2\relax{%
  \ifx/#1#1\penalty0\else%
    \ifx-#1#1\penalty0\else%
      \ifx\_#1#1\penalty0\else%
        \ifx~#1\char"7E\penalty0\else#1%
  \fi\fi\fi\fi%
  \ifx\relax#2\relax\else\fauxurlhelp#2\relax\fi}
%%%%%%%%%%%
\begin{document}
\begin{sloppypar}
\lipsum[4]
\fauxurl{%
http://tex.stackexchange.com/questions/331979/is~there~a-good-way-to-write~urls-with-tilde-without-using-url-or-hyperref-packa%
}
\lipsum[2]
\end{sloppypar}
\end{document}

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy