使用 hyperref 在 tabularx 中提供脚注

使用 hyperref 在 tabularx 中提供脚注

我想创建自己的命令来处理与内部的hyperref不兼容问题。我无法使用选项。footnotestabularxhyperfootnotes=falsehyperref

看来我已经得到了我想要的东西,但我对 LaTeX 的经验还不够。

问题在于:

  1. 脚注显示三次,而不是一次。
  2. 數字錯誤。
  3. 缺少链接。

代码:

\documentclass{article}
\usepackage{tabularx}
\usepackage{xparse}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}

\usepackage[%
%    hyperfootnotes=false,
]{hyperref} 

\newcommand\tikznode[3][]%
    {\tikz[remember picture,baseline=(#2.base)]
        \node[minimum size=0pt,inner sep=0pt,#1](#2){#3};%
    }


\begin{document}
Some text. This is the main text.\footnote{This is a footnote in the main text.}

\fbox{
    \begin{minipage}{\linewidth}
        This is a quotation with a footnote in it.\footnote{A footnote in the minipage} The footnote is numbered independently of the rest of the text\footnote{test}.
\end{minipage}
}

\fbox{
    \begin{minipage}[t]{\textwidth}
        \tikzstyle{every picture}+=[remember picture]
        \renewcommand{\arraystretch}{1.00}
        \newcounter{cntasterisk}
        \newcommand{\TypeAsterisk}{\stepcounter{cntasterisk}\tikznode{gw-\arabic{cntasterisk}}{*}}
        \newcounter{cntoption}
        \newcommand{\OptionAsterisk}[1]{\stepcounter{cntoption}\tikznode{op-\arabic{cntoption}}{#1}}
        \NewDocumentCommand{\TypeName}{sm}{%
            \IfBooleanTF{#1}{%
                {\bf #2}&\multicolumn{2}{l|}{}\\[1ex]%
            }{%
                {\bf #2}&\multicolumn{2}{l|}{}\\%
            }
        }
        \NewDocumentCommand{\OptName}{sm}{%
            \IfBooleanTF{#1}{%
                &\multicolumn{2}{l|}{\OptionAsterisk{\it #2:}}\\[1ex]%
            }{%
                &\multicolumn{2}{l|}{\OptionAsterisk\it #2:}\\%
            }
        }
        \NewDocumentCommand{\OptValue}{smm}{%
            \IfBooleanTF{#1}{%
                &\makebox[1ex]{}{\bf #2}&#3\\[1ex]%
            }{%
                &\makebox[1ex]{}{\bf #2}&#3\\%
            }
        }

        \newcommand\savedfootnotes{}        
        \newcommand\MyFootnote[1]{%
            \stepcounter{mpfootnote}$^\textrm{\scriptsize\thempfootnote}$
            \xdef\savedfootnotes%
            {\unexpanded\expandafter{\savedfootnotes}\noexpand\footnotetext{#1}}%
        }

         \begin{tabularx}{\textwidth}{|l<{\makebox[1em]{}}|l@{\makebox[2ex]{--}\makebox[1ex]{}}X|}
        \hline
        \TypeName{name\TypeAsterisk\TypeAsterisk\TypeAsterisk\TypeAsterisk}
        \hline
        \OptName{option 1}
        \hline
        \OptValue{V1}{vlaue 1}
        \hline
        \OptValue{V2}{vlaue 2\MyFootnote{whatever}}
        \hline
        \OptValue{V3}{vlaue 3\MyFootnote{anything}}
        \hline
        \OptName{option 2}
        \hline
        \OptValue{V4}{vlaue 4}
        \hline
        \OptValue{V5}{vlaue 5}
        \hline
        \OptName{option 3\MyFootnote{even more}}
        \hline
        \OptValue{V6}{vlaue 6}
        \hline
        \OptName{option 4}
        \hline
        \OptValue{X\textit{n}}{special}
        \hline
        \end{tabularx}

        \savedfootnotes

        \begin{tikzpicture}[overlay]
        \foreach \x in {1,...,\arabic{cntasterisk}} {%
            \draw [red, -{Stealth}, thick] (gw-\x) |- (op-\x);
            }
        \end{tikzpicture}

        text\footnote{text}

   \end{minipage}
}
\end{document}

在此处输入图片描述

相关内容