0

Can anyone tell me how to add href{} to \caption{} in figure environment? I keep getting TEX capacity exceeded error. My link in href{} contains underscore characters, escaping them doesn't help..

1
  • Welcome to TeX.SE. Please clarify what you're trying achieve with \href.
    – Mico
    May 7 '21 at 0:10
1

Did you want something like this--

Caption-href

Well, that can be achieved with this--

\documentclass{article}

\usepackage{graphicx}
\usepackage[colorlinks]{hyperref}

\begin{document}
  
  \begin{figure}[h]
    \centering
    \includegraphics[width=15em]{example-image-golden}
    \caption{More about the \href{https://en.wikipedia.org/wiki/Golden_ratio}
             {golden ration}}
  \end{figure}

\end{document}

Your questions are welcome in TeX.SE... if possible with a Minimum Working Example (MWE) to show what you tried. That will help contributors to better understand what you need, and not duplicate valuable work.

2
  • Thank you for your answer, when I run your code it works, but when I put in there my url, that is semanticscholar.org/paper/…, it doesn't work. May 7 '21 at 8:02
  • I didn't face any problem doing that too. I just changed the hyperlink and you can click here to see if it works for you. Maybe your LaTeX compiler parses hyperlinks somewhat differently. Have you tried doing it in Overleaf ?
    – Partha D.
    May 7 '21 at 13:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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