Text Formattinghyperref and tilde

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
bkarpuz
Posts: 124
Joined: Thu Dec 18, 2008 4:53 pm

hyperref and tilde

Post by bkarpuz »

Dear all,

I would like to hyperref my web page in latex.
I could not succeed to make the right code for my web page

Code: Select all

http://www2.aku.edu.tr/~bkarpuz
since there is a tilde in the address.

Any help will be appreciated very much.
thanks.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

hyperref and tilde

Post by gmedina »

Hi,

the \url command provided by the url package could be an option:

Code: Select all

\documentclass{article}
\usepackage{url}
\usepackage{hyperref}

\begin{document}

\url{http://www2.aku.edu.tr/~bkarpuz}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
bkarpuz
Posts: 124
Joined: Thu Dec 18, 2008 4:53 pm

hyperref and tilde

Post by bkarpuz »

ty gmedina, but when I use in the following way, its not giving the right output

Code: Select all

\documentclass[12pt]{article}

\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage[pdfstartview=FitV,bookmarks=false]{hyperref}
\usepackage{url}

\begin{document}
\title{Title here}
\author{Ba\c{s}ak Karpuz\thanks{\textbf{Address}. Department of Mathematics, Faculty of Science and Arts, ANS Campus, Afyon Kocatepe University, 03200 Afyonkarahisar, Turkey.\newline\textbf{Email}. bkarpuz@gmail.com\newline\textbf{Web page}. \url{http://www2.aku.edu.tr/~bkarpuz}}}

\maketitle

\end{document}
so what should be done now? :$

thanks again.
daleif
Posts: 199
Joined: Wed Nov 19, 2008 12:46 am

hyperref and tilde

Post by daleif »

expansion and protection problem, here is one solution

Code: Select all

\usepackage{url}
\urldef\myhomepage\url{http://www2.aku.edu.tr/~bkarpuz}
which worked in my test, then replace \url{...} in the author with \myhomepage
phi
Posts: 577
Joined: Tue Oct 21, 2008 8:10 pm

hyperref and tilde

Post by phi »

Use \urldef or \detokenize or \noexpand or \string. Note that hyperref loads url automatically; you don't have to load it explicitly. Here is an example showing all four possibilities (probably there are a lot more methods):

Code: Select all

\documentclass[12pt]{article}

\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage[pdfstartview=FitV,bookmarks=false]{hyperref}
%\usepackage{url}

\urldef\mysite\url{http://www2.aku.edu.tr/~bkarpuz}

\begin{document}
\title{Title here}
\author{Ba\c{s}ak Karpuz\thanks{\textbf{Address}. Department of Mathematics, Faculty of Science and Arts, ANS Campus, Afyon Kocatepe University, 03200 Afyonkarahisar, Turkey.\newline\textbf{Email}. bkarpuz@gmail.com\newline\textbf{Web page}. \mysite; \url{\detokenize{http://www2.aku.edu.tr/~bkarpuz}}; \url{http://www2.aku.edu.tr/\noexpand~bkarpuz}; \url{http://www2.aku.edu.tr/\string~bkarpuz}}}

\maketitle

\end{document}
bkarpuz
Posts: 124
Joined: Thu Dec 18, 2008 4:53 pm

hyperref and tilde

Post by bkarpuz »

thyank you very much. :oops:

I will use the following one

Code: Select all

\string~
SmithWillSuffice
Posts: 15
Joined: Fri Feb 23, 2007 9:29 am

hyperref and tilde

Post by SmithWillSuffice »

I use hyperref too, but not the url package.

Problem
: Using \~{} or \textasciitilde{} in the text display part of \href urls produces a raised tilde, which is acceptable because the tilde is really a diacritic mark, and as such should be used in accenting characters. But this doesn't conform to normal document use of "~" in web documents and unix cmds. The web use of ~ based and the use of ~ the unix cmdl shortcuts is abnormal, but understandable, and you should be able to typeset them.

To fix this for your LaTeX document to look nicer you can try

Code: Select all

\usepackage{textcomp}
...
\texttildelow{}
But this produces a tilde symbol that now looks to low (understandable since it is still supposed to be a diacritic).

Solution
So my preferred method of typesetting "~" in url's, or, if you do not want to load this extra package during tex'ing, just define a mid-tilde in your preamble

Code: Select all

\newcommand{\midtilde}{\raisebox{-0.25\baselineskip}{\textasciitilde}}
Alternatively, you might use the url package,

Code: Select all

\usepackage[lowtilde]{url}
which uses a faked mid-tilde in urls using the maths \sim
Support Free Software---It's Made for Everyone
Post Reply