Tikz: قم بتعيين قيمة X المناسبة للعقدة
سؤال
نتج هذا السؤال عن السؤال هنا
أريد أن تنتج دعامة مجعد تمتد على بعض خطوط النص. المشكلة هي أنه يجب عليّ محاذاة الإحداثيات X يدويًا ، وهو ليس حلاً نظيفًا.
حاليا أنا أستخدمها
\begin{frame}{Example}
\begin{itemize}
\item The long Issue 1
\tikz[remember picture] \node[coordinate,yshift=0.7em] (n1) {}; \\
spanning 2 lines
\item Issue 2
\tikz[remember picture] \node[coordinate, xshift=1.597cm] (n2) {};
\item Issue 3
\end{itemize}
\visible<2->{
\begin{tikzpicture}[overlay,remember picture]
\draw[thick,decorate,decoration={brace,amplitude=5pt}]
(n1) -- (n2) node[midway, right=4pt] {One and two are cool};
\end{tikzpicture}
} % end visible
\end{frame}
الذي ينتج النتيجة المرجوة:
الشيء غير المرضي هو أنه كان عليّ معرفة قيمة XShift البالغة 1.597 سم عن طريق التجربة والخطأ (أكثر أو أقل)
بدون حجة Xshift والنتيجة هي:
أعتقد أن هناك طريقة أنيقة لتجنب قيمة XShift الصريحة.
أفضل طريقة سيكون IMHO لحساب الحد الأقصى لقيمة x لعقدتين واستخدام هذا ، (كما هو مقترح بالفعل من قبل جيف)
ولكن سيكون من المفيد للغاية بالفعل أن تكون قادرًا على تحديد المطلقات المطلقة لكلا العقدتين مع الحفاظ على قيم Y الحالية. هذا من شأنه أن يتجنب الإجراء اللعين المتمثل في تكييف الوضع العشري الثالث لضمان أن الدعامة تبدو رأسية.
المحلول
هذا يتطلب \usetikzlibrary{calc}
. قد يكون هناك طريقة أنظف ، رغم ذلك.
مسح ال "xshift
"من العقدة n2
ثم استخدم:
\begin{tikzpicture}[overlay,remember picture]
\path (n2) -| node[coordinate] (n3) {} (n1);
\draw[thick,decorate,decoration={brace,amplitude=5pt}]
(n1) -- (n3);
\node[right=4pt] at ($(n1)!0.5!(n3)$) {One and two are cool};
\end{tikzpicture}
نصائح أخرى
إليك نسخة تستخدم مكتبة FIT التي لا تتطلب منك القلق بشأن الخط الأطول ، على حساب وضع علامة على كل سطر.
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing}
\usetikzlibrary{fit}
\newcommand{\bracemark}[1]{\tikz[remember picture] \node[inner sep=0pt] (#1) {\vphantom{X}};}
\begin{document}
\begin{frame}{Example}
\begin{itemize}
\item The long Issue 1 \bracemark{n1} \\
gratuitious long line of text \bracemark{n2} \\
spanning 3 lines \bracemark{n3}
\item Issue 2 \bracemark{n4}
\item Issue 3
\end{itemize}
\visible<2->{
\begin{tikzpicture}[overlay,remember picture]
\node [inner sep=0pt, fit=(n1) (n2) (n3) (n4)] (bracemarks) {};
\draw[thick,decorate,decoration={brace,amplitude=5pt}]
(bracemarks.north east) -- (bracemarks.south east) node[midway, right=4pt] {One and two are cool};
\end{tikzpicture}
} % end visible
\end{frame}
\end{document}
يتم تجنب YSHIFT المطلوب في عينة OP عن طريق جعل العقد العقد الفعلية (على عكس الإحداثيات) مع عرض X verth كنص.