4

I'm writing the following documents. As you can see it's shown only on one page, so in order not to make it a colorful painting I have switched off the colored rectangle around the many links displayed in the final PDF.

Example

I want to display a colored rectangle only on some of these links. How can I do this? Based on my knowledge the option is an on/off one to be set in the preamble.

Here a MWE

\documentclass[11pt, a4]{article}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage[hidelinks]{hyperref}
\usepackage{fullpage}
\usepackage{fancyhdr}
\pagestyle{fancy}
\lhead{}
\chead{}
\rhead{} %\includegraphics[width=2.5cm]{Logo}}
\lfoot{\href{www.facebook.com}{www.facebook.com/mypage}}
\cfoot{}
\rfoot{\href{mailto: mymail@fmail.it}{mymail@fmail.it}}
\renewcommand{\headrulewidth}{0.0pt}
\renewcommand{\footrulewidth}{0.0pt}
\setlength\parindent{0pt}
\usepackage{lipsum}

% ----------------------------------------------------

\begin{document}

\thispagestyle{fancy}

\begin{center}
\includegraphics[width=200pt]{Image} \\[10pt]
\Huge \textbf{My Name} \\[5pt]
\Large My home town \\ My Birthday \\
\end{center}

\textbf{BIOGRAFY} \\

\lipsum[3]

\parbox{0.5\textwidth}{}

\vfill

Text with one hyperlink \href{www.facebook.com}    {www.facebook.com/mypage}  \\[10pt]

\textbf{Link with a colored rectangle} - \href{http://goo.gl}{www.goo.gl} \\
\textbf{Link with a colored rectangle} - \href{http://goo.gl}{www.goo.gl} \\[10pt]

\end{document}
3
  • 1
    Have you tried \hypersetup{} with your options in between (should be something that removes the hidelinks and then after the box sets it again)? – TeXnician May 6 '17 at 8:36
  • Do you mean setting off at the beginning and then set the option on locally with the command \hypersetup{} in the two lines where I want the rectangle to show on. – Francesco Bianchi May 6 '17 at 8:49
  • Yeah, I mean something like \hypersetup{colorlinks}\url{link}\hypersetup{hidelinks} (of course this makes color, but should be similar for boxes). – TeXnician May 6 '17 at 8:51
7

Here's a version with borders locally enabled:

links and rectangle

\documentclass[11pt, a4]{article}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[demo]{graphicx}
\usepackage[hidelinks]{hyperref}
\usepackage{fullpage}
\usepackage{fancyhdr}
\pagestyle{fancy}
\lhead{}
\chead{}
\rhead{} %\includegraphics[width=2.5cm]{Logo}}
\lfoot{\href{www.facebook.com}{www.facebook.com/mypage}}
\cfoot{}
\rfoot{\href{mailto: mymail@fmail.it}{mymail@fmail.it}}
\renewcommand{\headrulewidth}{0.0pt}
\renewcommand{\footrulewidth}{0.0pt}
\setlength\parindent{0pt}
\usepackage{lipsum}

% ----------------------------------------------------

\begin{document}

\thispagestyle{fancy}

\begin{center}
\includegraphics[width=200pt]{Image} \\[10pt]
\Huge \textbf{My Name} \\[5pt]
\Large My home town \\ My Birthday \\
\end{center}

\textbf{BIOGRAFY} \\

\lipsum[3]

\parbox{0.5\textwidth}{}

\vfill

Text with one hyperlink \href{www.facebook.com}    {www.facebook.com/mypage}  \\[10pt]

\hypersetup{pdfborder=1 1 1}
\textbf{Link with a colored rectangle} - \href{http://goo.gl}{www.goo.gl} \\
\textbf{Link with a colored rectangle} - \href{http://goo.gl}{www.goo.gl} \\[10pt]
\hypersetup{hidelinks}

\href{http://goo.gl}{Test}
\end{document}
3
  • 1
    You could use a group around the \hypersetup macros, you don't have to revert manually then. – user31729 May 6 '17 at 9:56
  • @ChristianHupfer Would be an option, but I don't think I need to add it as you stated it in the comments. – TeXnician May 6 '17 at 10:03
  • 1
    @TeXnician: That's why I wrote 'you could', not 'you should' ;-) – user31729 May 6 '17 at 10:05

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.