0

I am trying to insert a hyperlink--> http://pages.cs.wisc.edu/~cao/cs537/lecture17.txt in my document, but since its a text file the last part of that link is not working, and it is taking me to the homepage only. I have used the command

\href{http://pages.cs.wisc.edu/~cao/cs537/lecture17.txt}

The complete code

\documentclass{article} 
\usepackage[utf8]{inputenc}

\title{jgklgi} 
\author{mancdmejldmuxsvsyf} 
\date{February 2020}

\begin{document}

\maketitle

\section{Introduction} \usepackage{hyperref} \href{http://pages.cs.wisc.edu/~cao/cs537/lecture17.txt} 

\end{document}
Cragfelt
  • 4,005
Turing101
  • 149
  • works fine for me. Show a complete small example. – Ulrike Fischer Feb 19 '20 at 15:49
  • \documentclass{article} \usepackage[utf8]{inputenc}

    \title{jgklgi} \author{mancdmejldmuxsvsyf } \date{February 2020}

    \begin{document}

    \maketitle

    \section{Introduction} \usepackage{hyperref} \href{http://pages.cs.wisc.edu/~cao/cs537/lecture17.txt} \end{document}

    – Turing101 Feb 19 '20 at 15:54
  • 3
    \usepackage{hyperref} must be placed in the preamble and not in the body of the document. Your code should actually result in an error message about this. – leandriis Feb 19 '20 at 15:56
  • Still not working..The link just opens the homepage – Turing101 Feb 19 '20 at 15:57
  • Can anyone please post there implementation. I am using Overleaf latex editor and downloading the file in PDF, in which this phenomemnon is happening – Turing101 Feb 19 '20 at 15:58
  • Please read the hyerref manual. \href takes two mandatory arguments (URL and text). I would probably just use \url{URL} – daleif Feb 19 '20 at 16:00
  • 1
    The example has another problem, \href takes two arguments (the url and the link text) and not one. Please test out example code before you post it. In any case, the link works fine if I correct that (i.e., the text file is opened in the browser, Firefox in my case). Maybe your browser has some security setting that prevents you from opening text files? – Marijn Feb 19 '20 at 16:01
  • It is taking me to the homepage, but i want to open this (http://pages.cs.wisc.edu/~cao/cs537/lecture17.txt) complete link only. But it is only opening http://pages.cs.wisc.edu – Turing101 Feb 19 '20 at 16:01
  • 1
    Also, welcome to TeX.SE of course :) – Marijn Feb 19 '20 at 16:01
  • @marjin

    Can you post the code. It will be very helpful. I am a beginner in latex, started just few days ago

    – Turing101 Feb 19 '20 at 16:02
  • Also, your example will never compile without errors. Please never ignore errors. Overleaf runs its latex such that is there is an error the latex run still concludes, in doing so it has to make guesses. – daleif Feb 19 '20 at 16:02
  • @ Turing101 try either the code in the answer below, or use \href{http://pages.cs.wisc.edu/~cao/cs537/lecture17.txt}{link} (the second argument is link, which is the text that is shown in the pdf). – Marijn Feb 19 '20 at 16:08
  • Ok.Thanks brother. Now another thing, the links are appearing plain black as ordinary text, how to make them blue and underlined? – Turing101 Feb 19 '20 at 16:10
  • See for example https://en.wikibooks.org/wiki/LaTeX/Hyperlinks#Customization for a list of color options and an example on how to use these options. – Marijn Feb 19 '20 at 21:16

1 Answers1

2

Too large for comment

This works just fine

\documentclass{article}
\usepackage[utf8]{inputenc}
\title{test}
\author{test}

\usepackage{hyperref}
\begin{document}

\maketitle

\section{Introduction}
\url{http://pages.cs.wisc.edu/~cao/cs537/lecture17.txt}
\end{document}
daleif
  • 54,450