1

I am trying to use \href to link to a web address that contains hyphens (e.g. http://hyphenated-webpage.com) within a minipage environment, e.g.

\usepackage{hyperref}
\begin{minipage}[t]{0.5\textwidth}
     Web: \href{http://hypehated-webpage}{{\color{blue}Webpage}}
\end{minipage}

In my document \href works fine within minipage for non-hyphenated addresses, e.g.

\usepackage{hyperref}

\begin{minipage}[t]{0.5\textwidth}
     Web: \href{http://nonhypehatedwebpage}{{\color{blue}Webpage}}
\end{minipage}

And hyphenated addresses also work fine outside of minipage, e.g.

\usepackage{hyperref}

\begin{minipage}[t]{0.5\textwidth}
   ...
\end{minipage}

     Web: \href{http://hypehated-webpage}{{\color{blue}Webpage}}

But as soon as I include a hyphenated \href web address within the minipage environment, the resulting PDF link does not work. It's completely dud.

Any suggestions?

Minimal example:

\documentclass[10pt,a4paper]{article}

\usepackage{geometry}
\usepackage[sc]{mathpazo}
\usepackage[usenames,dvipsnames]{color} 
\usepackage{hyperref}
\usepackage{alltt}

\begin{document} 

\vspace{0.1in}

\begin{minipage}[t]{0.5\textwidth}
\begin{alltt}   \rmfamily
Company
Department 
Address Line 1
Address Line 2
Office: number
\end{alltt}

\end{minipage}
\begin{minipage}[t]{0.5\textwidth}
\begin{alltt}   \rmfamily
Web: \href{http://www.boredpanda.com/worst-domain-names/}{{\color{blue}Link}}
E-mail: \href{mailto:}{\color{blue}email 1} (Head office) 
        \href{mailto:}{\color{blue}email 2} (Other office)
Company reg: number 
Other Info
\end{alltt}
\end{minipage}

\end{document}
  • Hi and welcome, can you modify your post to include a short but compilable test case that lets us reproduce the hyphenation issue with minimal effort? – Johannes_B Mar 26 '15 at 20:11
  • No problem - included above with random hyphenated web address. Dan – Daniel Mar 26 '15 at 20:56
  • You should check similar questions like tex.stackexchange.com/questions/49788/… – John Kormylo Mar 26 '15 at 21:13
  • The panda link works for me, is that the one you meant? – Johannes_B Mar 26 '15 at 21:15
  • John, that's the link I mean. It doesn't work at all when I compile the example above... I'm compiling on TexShop (for mac) via typeset > PDFtex > Latex. – Daniel Mar 26 '15 at 21:27
2

It took me a while to realize that the OP was only using alltt to avoid having to insert \\ at the end of each line. Note: adding spaces before \rmfamily seems to create an extra line.

\documentclass[10pt,a4paper]{article}

\usepackage{geometry}
\usepackage[sc]{mathpazo}
\usepackage[usenames,dvipsnames]{color} 
\usepackage{hyperref}
\usepackage{alltt}

\begin{document} 

\vspace{0.1in}

\begin{minipage}[t]{0.5\textwidth}
\begin{alltt}\rmfamily
Company
Department 
Address Line 1
Address Line 2
Office: number
\end{alltt}
\end{minipage}
\begin{minipage}[t]{0.5\textwidth}
Web: \href{http://www.boredpanda.com/worst-domain-names/}{\color{blue}Link}\\
E-mail: \href{mailto:}{\color{blue}email 1}\\
(Head office) \href{mailto:}{\color{blue}email 2}\\
(Other office)\\
Company reg: number\\
Other Info
\end{minipage}

\end{document}

removing alltt

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.