19

When trying to create a list of weblinks using

\documentclass{report} 
\usepackage{hyperref} 

\begin{document}  

\begin{itemize}
\item \href{www.washingtonpost.com}
\item \href{www.newyorktimes.com}
\item \href{www.lemonde.fr}
\item \href{www.guardian.co.uk}
\item \href{www.spiegel.de}
\item \href{www.bbc.co.uk/news}
\end{itemize}

\end{document}

I run into an error stating \pdfendlink cannot be used in vertical mode. What is a better approach to achieve this, or how can I modify mine?

1
  • 1
    Use \href{www.washingtonpost.com}{washington post}
    – yannisl
    Nov 1, 2011 at 7:55

1 Answer 1

23

\href takes two arguments, \href[options]{URL}{text} where the first is a full URL and the second the link text, and formats the text as normal text (see http://mirrors.ctan.org/macros/latex/contrib/hyperref/doc/hyperref-doc.pdf for details). So you can fix your problem by adding a full URL in the first argument and adding a second argument, i.e. \href{http://www.washingtonpost.com}{www.washingtonpost.com}.

But the easiest way to fix it may be to replace \href with \url which formats the URL in typewriter font (I've added the protocol for completeness):

\documentclass{report} 
\usepackage{hyperref} 

\begin{document}  

\begin{itemize}
\item \url{http://www.washingtonpost.com}
\item \url{http://www.newyorktimes.com}
\item \url{http://www.lemonde.fr}
\item \url{http://www.guardian.co.uk}
\item \url{http://www.spiegel.de}
\item \url{http://www.bbc.co.uk/news}
\end{itemize}

\end{document}
5
  • 4
    Ah, much quicker answer. You might want to add to your answer that \href formats the link as normal text, while \url uses a typewriter font.
    – Jake
    Nov 1, 2011 at 8:01
  • @Jake Good point. Fixed.
    – N.N.
    Nov 1, 2011 at 8:08
  • 4
    @Jake: But one can change the appearence of the \urls via \urlsytle{<option>}
    – Tobi
    Nov 1, 2011 at 8:18
  • @Jake: It is possible to setup \href to format the link as typewriter font? Apr 11, 2012 at 20:57
  • 1
    @BeniBogosel: I don't think hyperref has a configuration option for this, but you could define a new command like \newcommand{\tthref}[2]{\href{#1}{\texttt{#2}}}, which will take two arguments (like \href): \tthref{<URL>}{<link text>}.
    – Jake
    Apr 11, 2012 at 21:14

You must log in to answer this question.

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