I'm trying to achieve something I thought would be basic functionality. Just a hyperlink where it appears (in a code listing). It would be better if it was possible to follow the link for a reader. But it returns an error message and is a source of painful confusion.
\begin{lstlisting}[language=bash, breaklines,escapechar=|]
$ wget https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/tcc/0.9.27+git20200814.62c30a4a-1/tcc_0.9.27+git20200814.62c30a4a.orig.tar.bz2
$ wget |\href{http://foo.com/MyFunctionDocs.html}{MyFunction}|(x);
$ wget |\href{http://foo.com/MyFunctionDocs.html}{https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/tcc/0.9.27+git20200814.62c30a4a-1/tcc_0.9.27+git20200814.62c30a4a.orig.tar.bz2}|(x);
$ tar -xvjf tcc_0.9.27+git20200814.62c30a4a.orig.tar.bz2
$ gcc --version
gcc (Ubuntu 11.2.0-19ubuntu1) 11.2.0
$ ./configure --cc=gcc
$ make
$ make install
\end{lstlisting}
How it looks (without the hyperlink).
The error message seems to have little or nothing to do with what I try to do.
Missing $ inserted.
./sections/3-method.tex, 110
You need to enclose all mathematical expressions and symbols with special markers. These special markers create a ‘math mode’.
Use $...$ for inline math mode, and [...]or one of the mathematical environments (e.g. equation) for display math mode.
This applies to symbols such as subscripts ( _ ), integrals ( \int ), Greek letters ( \alpha, \beta, \delta ) and modifiers (\vec{x}, \tilde{x}).
Learn more
<inserted text>
$
l.110 ...0.9.27+git20200814.62c30a4a.orig.tar.bz2}
|(x);
I've inserted a begin-math/end-math symbol since I think
you left one out. Proceed, with fingers crossed.
! Missing $ inserted.
<inserted text>
$
l.110 ...0.9.27+git20200814.62c30a4a.orig.tar.bz2}
|(x);
I've inserted something that you may have forgotten.
(See the <inserted text> above.)
With luck, this will get me unwedged. But if you
really didn't forget anything, try typing `2' now; then
my insertion and my current dilemma will both disappear.
Expand
The typography is broken. It seems to be because TeX tries to be smart and force me into math mode which has nothing to do with what I'm doing. The "solution" I used was from Inline links in code listings
The following attempts also failed miserably with broken typography.
$ wget |\href{http://foo.com/MyFunctionDocs.html}{https://launchpad.net/ubuntu/+archive}|
$ wget |\url{https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/tcc/0.9.27+git20200814.62c30a4a-1/tcc_0.9.27+git20200814.62c30a4a.orig.tar.bz2}|;
Minimal not working example follows. It is easy to see that nothing works. The rendering is broken in all attempts to create such a simple feature as a hyperlink.
\begin{lstlisting}[language=bash, breaklines,escapechar=|]
$ wget https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/tcc/0.9.27+git20200814.62c30a4a-1/tcc_0.9.27+git20200814.62c30a4a.orig.tar.bz2
$ wget |\href{https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/tcc/0.9.27+git20200814.62c30a4a-1/tcc_0.9.27+git20200814.62c30a4a.orig.tar.bz2}{https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/tcc/0.9.27+git20200814.62c30a4a-1/tcc\_0.9.27+git20200814.62c30a4a.orig.tar.bz2}|
$ wget |\href{https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/tcc/0.9.27+git20200814.62c30a4a-1/tcc\_0.9.27+git20200814.62c30a4a.orig.tar.bz2}{\nolinkurl{https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/tcc/0.9.27+git20200814.62c30a4a-1/tcc\_0.9.27+git20200814.62c30a4a.orig.tar.bz2}}|
$ wget |\url{https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/tcc/0.9.27+git20200814.62c30a4a-1/tcc_0.9.27+git20200814.62c30a4a.orig.tar.bz2}|
\end{lstlisting}





_properly. symbols - Escape character in LaTeX - TeX - LaTeX Stack Exchange – user202729 Oct 30 '22 at 04:51