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?
Asked
Active
Viewed 640 times
2 Answers
5
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.
Heiko Oberdiek
- 271,626
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}
Steven B. Segletes
- 237,551

%7eis nothing but ascii tilde... On my browser it automatically becomes~– Symbol 1 Sep 30 '16 at 03:58%7eis the precent encodnig ( https://en.wikipedia.org/wiki/Percent-encoding ) of~. However, does this question help you or answer your problem? http://tex.stackexchange.com/questions/10858/url-with-tilde-character – Ronny Sep 30 '16 at 04:54urldoes is define\urland appropriate mechanisms to print URLs, so there's no obvious need for an alternative! – Joseph Wright Sep 30 '16 at 05:15urlconflicts with other packages. What's the problem? – Heiko Oberdiek Sep 30 '16 at 05:56urlis not usable. – Joseph Wright Sep 30 '16 at 05:59