使用 todonotes 连接脚注和文本的线

使用 todonotes 连接脚注和文本的线

由于我对文档在后台的结构了解不多(或者说一无所知……),以及正文和脚注区域是否是完全独立的实体,我完全不知道我的愿望是否可行:我想使用 todonotes 将脚注中的注释与正文中的某个单词用一条线连接起来。基本上,我希望注释像脚注所在的内联注释一样显示,并将它们像边注一样连接到文本。

我已经设法将内联注释做成脚注,但当我尝试将边注做成脚注时,连接注释和锚点的线还在,但注释却完全消失了。这就是为什么我认为可能根本无法将文本主体与脚注区域连接起来……

以下是带有内联注释作为脚注的 MWE:

\documentclass[fontsize=10, twoside=true]{scrbook}

\usepackage[british]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{mathptmx}
\usepackage{soul}
\usepackage[table,dvipsnames]{xcolor}
\usepackage{blindtext}
\usepackage[ruled]{manyfoot}
\usepackage[textsize=small,colorinlistoftodos,prependcaption=true]{todonotes} 

\setkomafont{sectioning}{\normalfont}

\DeclareRobustCommand{\hlyellow}[1]{{\sethlcolor{Goldenrod}\hl{#1}}}

\newcommand{\medium}[3][]{\hlyellow{#2}\todo[tickmarkheight=0.1cm, color=Goldenrod, #1]{#3}} %----> with this, I define a quick-to-type command for including my notes; in the original document, I have four of them, which is why I created a new command instead of re-definining the standard command; it takes three arguments: #1 is the (optional) title (inserted with the usual caption=), #2 are the words in the text to which the note applies, & #3 is the text of the actual note; thickmarkheight of course doesn't work here, as there is no line to display

\newfootnote{todos} %----> with the following code snippet, I define a new footnote type, as I still need default footnotes in my document and I don't want to have a mark here
\newcounter{footnotetodos}
\newcommand{\footnotetodos}{%
    \stepcounter{footnotetodos}%
    \Footnotemark\thefootnotetodos \Footnotetexttodos\thefootnotetodos}
\renewcommand{\thefootnotetodos}{}

\presetkeys%
{todonotes}%
{inline}
{noinlinepar}{}

\makeatletter
\renewcommand{\@todonotes@drawInlineNote}{%
    \if@todonotes@dviStyle%
    {\if@todonotes@inlinepar\par\noindent\fi%
        \begin{tikzpicture}[remember picture]%
            \draw node[inlinenotestyle] {};
        \end{tikzpicture}%
        \if@todonotes@inlinepar\par\fi}%
    \if@todonotes@authorgiven%
    {\noindent \@todonotes@useSizeCommand \@todonotes@author:\,\@todonotes@text}%
    \else%
    {\noindent \@todonotes@useSizeCommand \@todonotes@text}%
    \fi
    {\if@todonotes@inlinepar\par\noindent\fi%
        \begin{tikzpicture}[remember picture]%
            \draw node[inlinenotestyle] {};
        \end{tikzpicture}%
        \if@todonotes@inlinepar\par\fi}%
    \else%
    {\if@todonotes@inlinepar\par\noindent\fi%
        \footnotetodos{{\hspace{-1.25em}} %---->this is the line I included to get the inline-to-dos into the footer with the newly created footnote type and to skip the indent usually reserved for the footnote mark(er)
            \begin{tikzpicture}[remember picture]%
                \draw node[inlinenotestyle,font=\@todonotes@useSizeCommand]{%
                    \if@todonotes@authorgiven%
                    {\noindent \@todonotes@author:\,\@todonotes@text}%
                    \else%
                    {\noindent \@todonotes@text}%
                    \fi};%
            \end{tikzpicture}%
        }%
        \if@todonotes@inlinepar\par\fi}%
    \fi}%
\makeatother

\begin{document}
    \listoftodos[To Dos for this document]
    \vspace{1cm}
    This is an example paragraph to showcase my use of the single to-do-note in the \medium[caption=This is the title]{footnotes}{This is the text of the note, not of the highlighted text.}. \blindtext
\end{document}

下面是带有消失边注的 MWE:

\documentclass[fontsize=10, twoside=true]{scrbook}

\usepackage[british]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{mathptmx}
\usepackage{soul}
\usepackage[table,dvipsnames]{xcolor}
\usepackage{blindtext}
\usepackage[ruled]{manyfoot}
\usepackage[textsize=small,colorinlistoftodos,prependcaption=true]{todonotes} 

\setkomafont{sectioning}{\normalfont}

\DeclareRobustCommand{\hlyellow}[1]{{\sethlcolor{Goldenrod}\hl{#1}}}

\newcommand{\medium}[3][]{\hlyellow{#2}\todo[tickmarkheight=0.1cm, color=Goldenrod, #1]{#3}} %----> with this, I define a quick-to-type command for including my notes; in the original document, I have four of them, which is why I created a new command instead of re-definining the standard command; it takes three arguments: #1 is the (optional) title (inserted with the usual caption=), #2 are the words in the text to which the note applies, & #3 is the text of the actual note; thickmarkheight of course doesn't work here, as there is no line to display

\newfootnote{todos} %----> with the following code snippet, I define a new footnote type, as I still need default footnotes in my document and I don't want to have a mark here
\newcounter{footnotetodos}
\newcommand{\footnotetodos}{%
    \stepcounter{footnotetodos}%
    \Footnotemark\thefootnotetodos \Footnotetexttodos\thefootnotetodos}
\renewcommand{\thefootnotetodos}{}

\makeatletter
\renewcommand{\@todonotes@drawMarginNote}{%
    \if@todonotes@dviStyle%
    \begin{tikzpicture}[remember picture]%
        \draw node[notestyle] {};%
    \end{tikzpicture}\\%
    \begin{minipage}{\@todonotes@textwidth}%
        \if@todonotes@authorgiven%
        \@todonotes@useSizeCommand \@todonotes@author \@todonotes@text%
        \else%
        \@todonotes@useSizeCommand \@todonotes@text%
        \fi%
    \end{minipage}\\%
    \begin{tikzpicture}[remember picture]%
        \draw node[notestyle] (inNote) {};%
    \end{tikzpicture}%
    \else%
    \let\originalHbadness\hbadness%
    \hbadness 100000%
    \footnotetodos{ %----> This is where I want them to be treated as footnotes
    \begin{tikzpicture}[remember picture,baseline=(X.base)]%
        \node(X){\vphantom{\@todonotes@useSizeCommand X}};%
        \if@todonotes@authorgiven%
        \draw node[notestyle,font=\@todonotes@useSizeCommand,anchor=north] (inNote) at (X.north)%
        {\@todonotes@author};%
        \node(Y)[below=of X]{};%
        \draw node[notestyle,font=\@todonotes@useSizeCommand,anchor=north] (inNote) at (X.south)%
        {\@todonotes@text};%
        \else%
        \draw node[notestyle,font=\@todonotes@useSizeCommand,anchor=north] (inNote) at (X.north)%
        {\@todonotes@text};%
        \fi%
    \end{tikzpicture}%
    }
    \hbadness \originalHbadness%
    \fi}%
\makeatother

\begin{document}
    \listoftodos[To Dos for this document]
    \vspace{1cm}
    This is an example paragraph to showcase my use of the single to-do-note in the \medium[caption=This is the title]{footnotes}{This is the text of the note, not of the highlighted text.}. \blindtext
\end{document}

最优雅的方法是创建一个全新的命令,该命令由 \usepackage[footnote]{todonotes} 触发,并且是所有内联注释命令 + 脚注更改的精确副本。但由于我不需要“真正的”内联注释,我认为这个相当快速而粗糙的解决方案就足够了。

相关内容