tabularx 內有 hyperref 的註腳

tabularx 內有 hyperref 的註腳

我想製作自己的指令來處理hyperreffootnotesinside 的不相容問題tabularx。我無法使用hyperfootnotes=false的選項hyperref

看來我已經獲得了我想要的東西,但我在 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}

在此輸入影像描述

相關內容