I am using an mdframed
to a display large list of items. In this this list, there is one exception that a few of the items have, and I am trying to make a note of this via a footnote. The text of the footnote is the same for all the exceptions. So what I would like is:
- Multiple footnotes using the same symbol (in each mdframed)
- Each of the footnotes to link to the one piece of text at the end of each mdframed
I tried the hack below based on Making global footnotes inside a minipage with hyperref support, which gets me the same symbol for the footnote, but only the last footnote is properly linked.
Notes:
- If at all possible I would prefer to not have to do multiple runs. Since one instant of the footnote does not require multiple runs I think this should be doable without that.
References:
- Changing footnote symbol within mdframed
- Making global footnotes inside a minipage with hyperref support
Code:
\documentclass{article}
\usepackage{mdframed}
\usepackage{lipsum}
\usepackage{xcolor}
\usepackage[colorlinks=true]{hyperref}
\makeatletter
%% Adapted from https://tex.stackexchange.com/questions/119092/making-global-footnotes-inside-a-minipage-with-hyperref-support
\newcommand*{\MyFootnoteMark}{%
\footnotemark%
% \global\let\saved@Href@A\Hy@footnote@currentHref%
\addtocounter{footnote}{-1}%
}%
\newcommand*{\MyFootnoteText}[1]{%
%% \addtocounter{footnote}{-1}%
% \let\Hy@footnote@currentHref\saved@Href@A%
\footnotetext{#1}%
\stepcounter{footnote}%
}%
\makeatother
%https://tex.stackexchange.com/questions/175951/changing-footnote-symbol-within-mdframed
\makeatletter
\def\@fnsymbol#1{\ensuremath{\ifcase#1\or \dagger\or \ddagger\or
\mathsection\or \mathparagraph\or \|\or **\or \dagger\dagger
\or \ddagger\ddagger \else\@ctrerr\fi}}%
\renewcommand\thefootnote{\fnsymbol{footnote}}
\renewcommand\thempfootnote{\fnsymbol{mpfootnote}}
\makeatother
\newcommand*{\MyContent}[1][yellow!20]{%
\begin{mdframed}[backgroundcolor=#1]
\lipsum[1-2]
\begin{minipage}{\linewidth}\color{blue}
Hey, look at me.\MyFootnoteMark
\end{minipage}%
\par\lipsum[2]
\begin{minipage}{\linewidth}\color{blue}
Hey, look at me\MyFootnoteMark again.\par
\end{minipage}%
\par\lipsum[3-6]
\MyFootnoteText{This is the text that all the footnotes refers to.}
\end{mdframed}%
}%
\begin{document}
\MyContent[yellow!20]
\MyContent[green!20]
\end{document}