我希望在頁邊註之間有箭頭,我透過\tikzmarknode
(圖 1)實現了這一點。但如果一個標記位於另一頁上,則該方法不起作用(圖 2)。
我想要的是一條連續的線,一直延伸到頁面末尾,然後重新出現在下一頁的頂部(圖 3)。
微量元素:
\documentclass[10pt,oneside]{scrbook}
\usepackage{lipsum}
\usepackage[left=32.5mm, right=22.5mm, top=25mm, bottom=20mm, marginparsep=3mm]{geometry}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\usepackage{marginnote}
\renewcommand*{\marginfont}{\footnotesize\itshape}
\begin{document}
\marginnote{\tikzmarknode{a}{Thermoplast}}
\lipsum[1]
\marginnote{\tikzmarknode{b}{teilkristallin}}
\lipsum[1]
\marginnote{\tikzmarknode{c}{aliphatisch}}
\begin{tikzpicture}[remember picture, overlay, shorten >=1.5mm, shorten <=1.5mm,->]
\draw ([xshift=10pt]a.south west) to ([xshift=10pt]b.north west);
\draw ([xshift=10pt]b.south west) to ([xshift=10pt]c.north west);
\end{tikzpicture}
% \lipsum[1-6] % Works fine
\lipsum[1-7] % Doesn't work
\marginnote{\tikzmarknode{d}{aliphatisch}}
\begin{tikzpicture}[remember picture, overlay, shorten >=1.5mm, shorten <=1.5mm,->]
\draw ([xshift=10pt]c.south west) to ([xshift=10pt]d.north west);
\end{tikzpicture}
\end{document}
答案1
圖書館tikzmark
附有一張支票\iftikzmarkoncurrentpage
。這使我們能夠區分情況
- 目前頁面上沒有任何節點(目前頁面可能位於兩個要連接的後續標記的頁面之間),
- 當前頁面的第一個節點,
- 目前頁面上的第二個節點,
- 兩個節點都在同一頁上。
這些情況在巨集中區分\ConnectTikZmarknodes
,巨集也透過分頁符號連接節點。它用於eso-pic
避免要求用戶在多個頁面上添加巨集。由於附帶的良好檢查,tikzmark
可以(並且,如果連接運行在多個頁面上,也是必要的)\ConnectTikZmarknodes
在實際定義節點之前添加。
\documentclass[10pt,oneside]{scrbook}
\usepackage{lipsum}
\usepackage[left=32.5mm, right=22.5mm, top=25mm, bottom=20mm, marginparsep=3mm]{geometry}
\usepackage{tikzpagenodes}
\usepackage{eso-pic}
\usetikzlibrary{tikzmark}
\usepackage{marginnote}
\renewcommand*{\marginfont}{\footnotesize\itshape}
\makeatletter
\newcommand\PageOfTikzmark[1]{%
\csname save@pg@\csname save@pt@\tikzmark@pp@name{#1}\endcsname\endcsname}
\makeatother
\newcommand{\ConnectTikZmarknodes}[3][]{\AddToShipoutPictureFG{%
\begin{tikzpicture}[remember picture, overlay, shorten >=1.5mm,
shorten <=1.5mm,#1]
\iftikzmark{#2}{\edef\pageA{\PageOfTikzmark{#2}}}{\edef\pageA{-1}}%
\iftikzmark{#3}{\edef\pageB{\PageOfTikzmark{#3}}}{\edef\pageB{-1}}%
\iftikzmarkoncurrentpage{#2}
\edef\myflag{1}%
\else
\edef\myflag{0}%
\fi
\iftikzmarkoncurrentpage{#3}
\edef\myflag{\the\numexpr\myflag+2}%
\fi
\ifcase\myflag
\or
\draw[-] ([xshift=10pt]#2.south west)
to ([xshift=10pt]#2.south west|-current page text area.south);
\or
\draw[->] ([xshift=10pt]#3.north west|-current page text area.north)
to ([xshift=10pt]#3.north west);
\or
\draw[->] ([xshift=10pt]#2.south west)
to ([xshift=10pt]#3.north west);
\fi
\ifnum\value{page}>\pageA
\ifnum\value{page}<\pageB
\draw ([xshift=20pt]current page text area.north east) to
([xshift=20pt]current page text area.south east);
\fi
\fi
\end{tikzpicture}}}
\begin{document}
\marginnote{\tikzmarknode{a}{Thermoplast}}
\lipsum[1]
\marginnote{\tikzmarknode{b}{teilkristallin}}
\ConnectTikZmarknodes{a}{b}
\lipsum[1]
\marginnote{\tikzmarknode{c}{aliphatisch}}
\ConnectTikZmarknodes{b}{c}
\lipsum[1-7] % works fine
\marginnote{\tikzmarknode{d}{aliphatisch}}
\ConnectTikZmarknodes{c}{d}
\ConnectTikZmarknodes{d}{e}
\lipsum[1-23]
\marginnote{\tikzmarknode{e}{unproblematisch}}
\end{document}