In an answer to another question (here), a theorem is nicely linked to another file. When I try to use this to link to a website however (by filling in \url{www. ... .com} instead of ./file.pdf), this gives an error message (Tex capacity exceeded). Is there a way to overcome this problem?
Asked
Active
Viewed 186 times
1 Answers
3
You have to define the new theorem style as
\newtheoremstyle{linked}
{}% Space above, empty = `usual value'
{}% Space below
{\itshape}% Body font
{}% Indent amount (empty = no indent, \parindent = para indent)
{\bfseries}% Thm head font
{.}% Punctuation after thm head
{ }% Space after thm head: " " = normal interword space;
% \newline = linebreak
{\href{\thislink}{\thmname{#1} \thmnumber{#2}}\thmnote{ (#3)}}% Thm head spec
Then use linkthm as in
\begin{linkthm}{http://tex.stackexchange.com}
MWE (borrowed from that answer)
\documentclass{article}
\usepackage{amsthm}
\usepackage[colorlinks]{hyperref}
\newtheoremstyle{linked}
{}% Space above, empty = `usual value'
{}% Space below
{\itshape}% Body font
{}% Indent amount (empty = no indent, \parindent = para indent)
{\bfseries}% Thm head font
{.}% Punctuation after thm head
{ }% Space after thm head: " " = normal interword space;
% \newline = linebreak
{\href{\thislink}{\thmname{#1} \thmnumber{#2}}\thmnote{ (#3)}}% Thm head spec
\newtheorem{thm}{Theorem}[section] % normal theorems
\theoremstyle{linked}
\newtheorem{innlinkthm}[thm]{Theorem} % theorems with link
\newenvironment{linkthm}[1]
{\def\thislink{#1}\innlinkthm}
{\endinnlinkthm}
\begin{document}
\section{Theorems}
\begin{thm}
This is a normal theorem.
\end{thm}
\begin{linkthm}{http://tex.stackexchange.com}
This has a link.
\end{linkthm}
\begin{linkthm}{http://tex.stackexchange.com}[Attribution]
This has the same link.
\end{linkthm}
\end{document}
Output

karlkoeller
- 124,410
-
As a little extra, this works for both url's and links to files (pdf, flv,...) as I found out testing this solution. Thanks! – Dries Feb 12 '15 at 17:40