latexpdflatexxelatex

href for a link with special characters does not work in latex


I want to compile the following:

href{https://www.econometrics-with-r.org/3.1-estimation-of-the-population-mean.html#:~:text=%23%20set%20seed%20for,%23%3E%20%5B1%5D%208.257893}{this link.}

> \frametitle {Link to Highlighted Text} You can access the URL with th\ETC.
! File ended while scanning use of \frame.
<inserted text> 
                \par 
<*> main.tex
            
I suspect you have forgotten a `}', causing me
to read past where you wanted me to stop.
I'll try to recover; but if the error is serious,
you'd better type `E' or `X' now and fix your file.

But it is completely unrelated to frametitle. The problem is with # sign and other special characters.


Solution

  • You can try to decode the url then escape the # characters, i.e. replacing it with \#.

    BTW, the decoded URL I got is https://www.econometrics-with-r.org/3.1-estimation-of-the-population-mean.html#:~:text=# set seed for,#> [1] 8.257893