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:

 \def\@pdfborder{0 0 1}% Overrides border definition set with colorlinks=true
  \def\@pdfborderstyle{/S/U/W 0}
\node[inner sep=-1pt,outer sep=0pt] (todotted) {#1};
\draw[dotted] (todotted.south west) -- (todotted.south east); }%}%
\section{To See}\label{tosee}
This is \myhy{tosee}{just to see} what it looks like\footnote{\lipsum[1]}. \lipsum[1-2]

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?

1 Answer 1


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:




   % --- 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
   % --- draw the link
   \node[inner sep=-1pt,outer sep=0pt] (todotted) {\usebox{\link@box}};
   \draw[dotted, thick] 
      ($(todotted.base)-(.5\link@width,2pt)$) -- +(\link@width,0); 


   % --- replace \ref command
   % --- replace hyperref command
   % --- replace footnote command
   % --- replace cite command
   % --- introduce secref command   
   \newcommand\secref[1]{\hyperref[#1]{Section \oldref{#1}}}


\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]
How about this?\footnote{And a second footnote}

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:

There are probably more commands to override, but it may help you on your way.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .