# Having all links underlined with dotted line

so I'm trying to figure out how to have all links underlined with a dotted line. The furthest I got with this and this is:

\documentclass{article}
\usepackage{xcolor,soul,lipsum}
\usepackage{tikz}
\def\@pdfborder{0 0 1}% Overrides border definition set with colorlinks=true
\def\@pdfborderstyle{/S/U/W 0}
\newcommand{\udot}[1]{%
\tikz[baseline=(todotted.base)]{
\node[inner sep=-1pt,outer sep=0pt] (todotted) {#1};
\draw[dotted] (todotted.south west) -- (todotted.south east); }%}%
\newcommand{\myhy}[2]{\udot{\hyperref[#1]{\color{black}\setulcolor{white}\ul{#2}}}}
\begin{document}
\section{To See}\label{tosee}
\vskip2cm
This is \myhy{tosee}{just to see} what it looks like\footnote{\lipsum[1]}. \lipsum[1-2]
\end{document}


The problem is I want to have formatted in this way every singe link in a document (including links to footnotes, webpages, etc.). Any ideas?

-

What you should do is override the \ref, \hyperref, \footnote commands, and any other command that you use to link. The following code should give you a starting point:

\documentclass{article}
\usepackage{lipsum}
\usepackage{tikz}

\usetikzlibrary{calc}

\makeatletter

% --- save the box to be displayed (so that e.g. footnote counters do not
%     get incremented twice)
% --- calculate the width of the box for later use
\tikz[baseline=(todotted.base)]{
\draw[dotted, thick]
($(todotted.base)-(.5\link@width,2pt)$) -- +(\link@width,0);
}%
}

\makeatother

\AtBeginDocument{%
% --- replace \ref command
\let\oldref=\ref
% --- replace hyperref command
\let\oldhyperref=\hyperref
% --- replace footnote command
\let\oldfootnote=\footnote
% --- replace cite command
\let\oldcite=\cite
% --- introduce secref command
\newcommand\secref[1]{\hyperref[#1]{Section \oldref{#1}}}
}

\begin{document}

\section{To See}\label{tosee}
This is Section \ref{tosee}; or refer to it like \secref{tosee}.
This is \hyperref[tosee]{just to see} what it looks like\footnote{\lipsum[1]}. \lipsum[1-2]

The code introduces a new command, \formatlink, which, as the name suggests, formats a link. Its only argument is the text that is to be underlined with dots. The code for \formatlink is about the same as what you wrote in your question, with minor changes for better appearance.
Next, the code inside \AtBeginDocument (which gets executed at the \begin{document} command) overrides the \ref, \hyperref, and footnote commands. It also adds a new command called \secref, which could be used to refer to sections in such a way that the word "Section" also gets underlined.
For illustration purposes, I have changed the code of \formatlink code slightly, so that every link shows up as a red box; the result is: