Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
1  
Use \href{www.washingtonpost.com}{washington post} –  Yiannis Lazarides Nov 1 '11 at 7:55
add comment

1 Answer

up vote 15 down vote accepted

\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://www.tug.org/applications/hyperref/manual.html#x1-130004 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}
share|improve this answer
2  
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 '11 at 8:01
    
@Jake Good point. Fixed. –  N.N. Nov 1 '11 at 8:08
3  
@Jake: But one can change the appearence of the \urls via \urlsytle{<option>} –  Tobi Nov 1 '11 at 8:18
    
@Jake: It is possible to setup \href to format the link as typewriter font? –  Beni Bogosel Apr 11 '12 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 '12 at 21:14
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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