Tikz:使用相对定位匹配线位置

Tikz:使用相对定位匹配线位置

我正在尝试在正文(摘录自《圣经》)中的某些点之间绘制正交线,并使用tikzmark作为锚点和relative positioning形成线形。我需要对齐两条线的垂直部分(用作文本旁边的方括号),但无法对齐,因为它们基于 s 定义的不同位置tikzmark。我需要将第 7b-10b 节旁边的垂直线与第 2-7a 节旁边的垂直线对齐。我尝试使用该calc函数定义坐标,但没有成功。非常感谢您的帮助。

这是我的 MWE:

\documentclass[]{tufte-handout}

\title{Psalm 111}
\date{}

\usepackage{poetry}
\usepackage{tikz}
\usetikzlibrary{tikzmark,positioning,calc}

\begin{document}
\maketitle

\poemlinenumsfalse
\begin{poem} %requires the 'poetry' package
\textsuperscript{1}Praise the LORD!\tikzmark{1} \\
    I will praise the LORD with my whole heart, \\
    \hin In the assembly of the upright and in the congregation. \\
\textsuperscript{2} The works of the LORD are great,\tikzmark{2} \\
    \hin Studied by all who have pleasure in them. \\
\textsuperscript{3} His work is honorable and glorious, \\
    \hin And His righteousness endures forever. \\
\textsuperscript{4} He has made His wonderful works to be remembered; \\
    \hin The LORD is gracious and full of compassion. \\
\textsuperscript{5} He has given food to those who fear Him; \\
    \hin He will ever be mindful of His covenant. \\
\textsuperscript{6} He has declared to His people the power of His works, \\
    \hin In giving them the heritage of the nations. \\
\textsuperscript{7} The works of His hands are verity and justice;\tikzmark{7a} \\
    \hin All His precepts are sure.\tikzmark{7b} \\
\textsuperscript{8} They stand fast forever and ever, \\
    \hin And are done in truth and uprightness. \\
\textsuperscript{9} He has sent redemption to His people; \\
    \hin He has commanded His covenant forever: \\
    \hin \hin \hin Holy and awesome is His name. \\
\textsuperscript{10} The fear of the LORD is the beginning of wisdom; \\
    \hin A good understanding have all those who do \\
    \hin \hin His commandments.\tikzmark{10b} \\
    \hin \hin \hin His praise endures forever.\tikzmark{10c} \\
\end{poem}

\begin{tikzpicture}[remember picture, overlay]
\draw [gray] ([xshift=2pt, yshift=2pt]pic cs:2) -- ++(4.5,0) |- ([xshift=2pt, yshift=2pt]pic cs:7a);
\draw [gray] ([xshift=2pt, yshift=2pt]pic cs:7b) -- ++(7.5,0) |- ([xshift=2pt, yshift=2pt]pic cs:10b);
\end{tikzpicture}

\end{document}

输出如下: 在此处输入图片描述

答案1

coordinate我建议沿着你的路径添加s。

\draw [gray] ([xshift=2pt, yshift=2pt]pic cs:2) -- ++(4.5,0) coordinate (A) |- ([xshift=2pt, yshift=2pt]pic cs:7a);
\draw [gray] ([xshift=2pt, yshift=2pt]pic cs:7b)coordinate (B) --(A|-B) |- ([xshift=2pt, yshift=2pt]pic cs:10b);

使用相对定位匹配行位置

相关内容