答案1
据我理解,您有两个相邻的页面,一个在右侧,其中包含某个 PDF 文件中的页面,另一个在左侧,您想要在其中添加注释。然后,您需要绘制从左到右的线条,跨越页面边界。
以下方法与 s 类似tikzmark
,您可以使用宏\annotline
定义下一页的坐标(页面左上角为原点,单位为厘米),以便绘制一条线。然后,宏将从您放置宏的位置开始绘制一条线,该线朝向页面的右边缘,向上或向下翻转,直到到达下一页坐标的高度,然后再次向右翻转。您可以使用宏\annotlinebreakdist
定义从页面的右边缘到线的垂直部分的距离。
在下一页上,您可以使用宏\printannotlines
绘制从页面左边距开始到相关坐标的剩余线条。宏会自动绘制到那时尚未完成的所有线条。
您可以使用 Ti钾Z 样式。如果线条重叠,您可以使用第二个可选参数将线条的垂直部分向右或向左移动。使用第一个可选参数,您可以将线条的起点向左或向右移动。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\tikzset{
annotline/.style={
very thick, red
},
annotline start/.style={
},
annotline end/.style={
->
}
}
\ExplSyntaxOn
\dim_new:N \l_annotline_breakdist_dim
\dim_set:Nn \l_annotline_breakdist_dim { 1cm }
\NewDocumentCommand{\annotlinebreakdist}{ m }{
\dim_set:Nn \l_annotline_breakdist_dim { #1 }
}
\clist_new:N \l_annotline_allxpos_clist
\clist_new:N \l_annotline_allypos_clist
\int_new:N \l_annotline_currid_int
\int_new:N \l_annotline_lastid_int
\NewDocumentCommand{\annotline}{ O{0pt} O{0pt} m m }{%
\clist_put_right:Nn \l_annotline_allxpos_clist { #3 }
\clist_put_right:Nn \l_annotline_allypos_clist { #4 }
\int_incr:N \l_annotline_currid_int
\begin{tikzpicture}[remember~picture, overlay]
\coordinate (annotline-\int_use:N\l_annotline_currid_int -start) at
([xshift=#1,yshift=.5ex]0,0);
\coordinate (annotline-\int_use:N\l_annotline_currid_int -start-break) at
([xshift={-1*\dim_use:N\l_annotline_breakdist_dim+#2}]current~page.east);
\coordinate (annotline-\int_use:N\l_annotline_currid_int -start-margin) at
([shift={(0,-1*#4)}]current~page.north~east);
\draw[annotline, annotline~start]
(annotline-\int_use:N\l_annotline_currid_int -start) --
(annotline-\int_use:N\l_annotline_currid_int -start -| annotline-\int_use:N\l_annotline_currid_int -start-break) |-
(annotline-\int_use:N\l_annotline_currid_int -start-margin);
\end{tikzpicture}
}
\dim_new:N \l_annotline_currxpos_dim
\dim_new:N \l_annotline_currypos_dim
\NewDocumentCommand{\annotlineend}{ m }{%
\dim_set:Nn \l_annotline_currxpos_dim { \clist_item:Nn \l_annotline_allxpos_clist #1 cm }
\dim_set:Nn \l_annotline_currypos_dim { \clist_item:Nn \l_annotline_allypos_clist #1 cm }
\begin{tikzpicture}[remember~picture, overlay]
\coordinate (annotline-#1-end-margin) at
([shift={(0,-1*\int_use:N\l_annotline_currypos_dim)}]current~page.north~west);
\coordinate (annotline-#1-end) at
([shift={(\dim_use:N\l_annotline_currxpos_dim,-1*\dim_use:N\l_annotline_currypos_dim)}]current~page.north~west);
\draw[annotline, annotline~end]
(annotline-#1-end-margin) --
(annotline-#1-end);
\end{tikzpicture}
}
\NewDocumentCommand{\printannotlines}{}{%
\int_incr:N \l_annotline_lastid_int
\foreach \i in {\int_use:N\l_annotline_lastid_int,...,\int_use:N\l_annotline_currid_int} {
\annotlineend{\i}
}
\int_set:Nn \l_annotline_lastid_int \l_annotline_currid_int
}
\ExplSyntaxOff
\begin{document}
\annotlinebreakdist{2cm}
Some very interesting thing \annotline[0pt][10pt]{8}{5}
Some other interesting thing \annotline[0pt][-10pt]{12}{10}
\vspace{10cm}
Yet another interesting thing \annotline{16}{7.5}
\newpage
\noindent
\includegraphics[width=\textwidth]{example-image-a}
\printannotlines
\newpage
Again some very interesting thing \annotline{10}{10}
\newpage
\noindent
\includegraphics[width=\textwidth]{example-image-a}
\printannotlines
\end{document}
如果您希望在注释旁边有一条垂直线,则可能需要使用包含注释的节点:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\tikzset{
annotline/.style={
very thick, red
},
annotline start/.style={
},
annotline end/.style={
->
},
annotline box/.style={
inner sep=0pt,
text width=5cm,
}
}
\ExplSyntaxOn
\dim_new:N \l_annotline_breakdist_dim
\dim_set:Nn \l_annotline_breakdist_dim { 1cm }
\NewDocumentCommand{\annotlinebreakdist}{ m }{
\dim_set:Nn \l_annotline_breakdist_dim { #1 }
}
\clist_new:N \l_annotline_allxpos_clist
\clist_new:N \l_annotline_allypos_clist
\int_new:N \l_annotline_currid_int
\int_new:N \l_annotline_lastid_int
\NewDocumentEnvironment{annotlinebox}{ O{0pt} O{0pt} m m +b }{%
\clist_gput_right:Nn \l_annotline_allxpos_clist { #3 }
\clist_gput_right:Nn \l_annotline_allypos_clist { #4 }
\int_gincr:N \l_annotline_currid_int
\begin{tikzpicture}[remember~picture]
\node[annotline~box] (annotline-\int_use:N\l_annotline_currid_int -box) at (0,0) { { #5 } };
\begin{scope}[overlay]
\coordinate (annotline-\int_use:N\l_annotline_currid_int -start) at
([xshift=#1]annotline-\int_use:N\l_annotline_currid_int -box.north~east);
\coordinate (annotline-\int_use:N\l_annotline_currid_int -start-break) at
([xshift={-1*\dim_use:N\l_annotline_breakdist_dim+#2}]current~page.east);
\coordinate (annotline-\int_use:N\l_annotline_currid_int -start-margin) at
([shift={(0,-1*#4)}]current~page.north~east);
\draw[annotline, annotline~start]
(annotline-\int_use:N\l_annotline_currid_int -box.south~east -| annotline-\int_use:N\l_annotline_currid_int -start) --
(annotline-\int_use:N\l_annotline_currid_int -start) --
(annotline-\int_use:N\l_annotline_currid_int -start -| annotline-\int_use:N\l_annotline_currid_int -start-break) |-
(annotline-\int_use:N\l_annotline_currid_int -start-margin);
\end{scope}
\end{tikzpicture}
}{}
\dim_new:N \l_annotline_currxpos_dim
\dim_new:N \l_annotline_currypos_dim
\NewDocumentCommand{\annotlineend}{ m }{%
\dim_set:Nn \l_annotline_currxpos_dim { \clist_item:Nn \l_annotline_allxpos_clist #1 cm }
\dim_set:Nn \l_annotline_currypos_dim { \clist_item:Nn \l_annotline_allypos_clist #1 cm }
\begin{tikzpicture}[remember~picture, overlay]
\coordinate (annotline-#1-end-margin) at
([shift={(0,-1*\int_use:N\l_annotline_currypos_dim)}]current~page.north~west);
\coordinate (annotline-#1-end) at
([shift={(\dim_use:N\l_annotline_currxpos_dim,-1*\dim_use:N\l_annotline_currypos_dim)}]current~page.north~west);
\draw[annotline, annotline~end]
(annotline-#1-end-margin) --
(annotline-#1-end);
\end{tikzpicture}
}
\NewDocumentCommand{\printannotlines}{}{%
\int_incr:N \l_annotline_lastid_int
\foreach \i in {\int_use:N\l_annotline_lastid_int,...,\int_use:N\l_annotline_currid_int} {
\annotlineend{\i}
}
\int_set:Nn \l_annotline_lastid_int \l_annotline_currid_int
}
\ExplSyntaxOff
\begin{document}
\annotlinebreakdist{2cm}
\begin{annotlinebox}{8}{5}
Some very interesting thing
\end{annotlinebox}
\vspace{10cm}
\begin{annotlinebox}{12}{10}
Some other interesting thing \\
which is a bit longer \\
than the other
\end{annotlinebox}
\newpage
\noindent
\includegraphics[width=\textwidth]{example-image-a}
\printannotlines
\end{document}