mdframed 中的多个脚注引用同一文本

mdframed 中的多个脚注引用同一文本

我正在使用mdframed显示大量项目列表。在此列表中,有一些项目有例外,我正试图通过脚注来记录这一点。脚注的文本与全部例外。所以我想要的是:

  • 多个脚注使用相同的符号(在每个 mdframed 中)
  • 每个脚注链接到结尾处的一段文字每个框架

我尝试过黑客以下基于在支持超链接的迷你页面内制作全局脚注,这使我的脚注获得了相同的符号,但只有最后一个脚注被正确链接。

笔记:

  • 如果可能的话我更愿意不是必须多次运行。由于脚注的一个瞬间不需要多次运行,我认为即使没有运行,也应该可以做到。

参考:

代码:

\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

我真的不知道我在做什么!我应该睡觉!

另行添加\addtocounter{Hfootnote}{-1}%

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

在此处输入图片描述

另一个丑陋的黑客手段,让脚注中的符号重新出现

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

相关内容