4

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:

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}
1

I don't really know what I am doing! I should be sleeping!

Add \addtocounter{Hfootnote}{-1}% additionally.

\documentclass{article}
\usepackage{mdframed}
\usepackage{lipsum}
\usepackage{xcolor}

\usepackage[colorlinks=true]{hyperref}

\makeatletter
%% Adapted from http://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}%
    \addtocounter{Hfootnote}{-1}%     Added
}%

\newcommand*{\MyFootnoteText}[1]{%
%%  \addtocounter{footnote}{-1}%
%   \let\Hy@footnote@currentHref\saved@Href@A%
    \footnotetext{#1}%
    \stepcounter{footnote}%
    \stepcounter{Hfootnote}%      %% Added
}%
\makeatother


%http://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}

enter image description here

Another ugly hack to bring back the symbols in the footnote

\documentclass{article}
\usepackage{mdframed,footnote}
\usepackage{lipsum}
\usepackage{xcolor}
\usepackage{xparse}

\usepackage[colorlinks=true]{hyperref}

\makeatletter
%% Adapted from http://tex.stackexchange.com/questions/119092/making-global-footnotes-inside-a-minipage-with-hyperref-support
\newcommand*{\MyFootnoteMark}{%
    \footnotemark%
    \addtocounter{footnote}{-1}%
    \addtocounter{Hfootnote}{-1}%     Added
}%

\newcommand{\MyFootnoteText}[1]{%
    \footnotetext[\numexpr\value{footnote}+1\relax]{#1}%
    \refstepcounter{footnote}%
    \refstepcounter{Hfootnote}%      %% Added
}%
\makeatother


%http://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

\NewDocumentCommand{\MyContent}{O{yellow!20}O{}}{%
\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}
  • This almost works. The links for the yellow mdframed are correct. But the links for the green mdframed block link back to the footnote in the yellow block. – Peter Grill May 11 '14 at 20:04
  • Harish, just noticed that the footnote marks are not showing up in the footnotes itself. Only the text shows up. Any ideas as to why? Otherwise it seems to work great. – Peter Grill May 12 '14 at 8:46
  • @PeterGrill Added another ugly hack!. – user11232 May 12 '14 at 11:15

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.