tikz의 텍스트 노드 좌표는 상자의 중심을 지정합니다. 상자의 왼쪽 가장자리를 지정하는 방법이 있습니까?

tikz의 텍스트 노드 좌표는 상자의 중심을 지정합니다. 상자의 왼쪽 가장자리를 지정하는 방법이 있습니까?

대각선 오른쪽에 있는 두 줄의 텍스트를 왼쪽 정렬하고 싶습니다. 이를 수행할 수 있는 방법이 있습니까?

\begin{tikzpicture}

\node[text] at (2,4) {/p/};

\draw (2.5,4) -- (5,5);
\draw (2.5,4) -- (5,3);

\node[text,align=left] at (7.2,5) {\textipa{[b]} / [+voice] \_\_ [+voice]};
\node[text,align=left] at (6.5,3) {[p] / elsewhere};

\end{tikzpicture}

여기에 이미지 설명을 입력하세요

답변1

을 사용하여 anchor=west가장 왼쪽 지점을 통해 상자의 위치를 ​​지정하거나 right.

\documentclass{article}
\usepackage{tikz}
\usepackage{tipa}
\begin{document}
\begin{tikzpicture}
 \node at (2,4) {/p/};
 \draw (2.5,4) -- (5,5) node[right,align=left] {\textipa{[b]} / [+voice] \_\_ [+voice]};
 \draw (2.5,4) -- (5,3) node[right,align=left] {[p] / elsewhere};
\end{tikzpicture}

\begin{tikzpicture}
 \node at (2,4) {/p/};
 \draw (2.5,4) -- (5,5) node[anchor=west,align=left] {\textipa{[b]} / [+voice] \_\_ [+voice]};
 \draw (2.5,4) -- (5,3) node[anchor=west,align=left] {[p] / elsewhere};
\end{tikzpicture}
\end{document}

여기에 이미지 설명을 입력하세요

답변2

마모트의 방법 외에도 여러 가지 방법이 있습니다. 여기에 세 가지가 있습니다(나중에 찾으면 더 추가하겠습니다).

방법 1

\documentclass[tikz,margin=3mm]{standalone}
\begin{document}
\begin{tikzpicture}
\draw (0,0) node[right] {Something} -- (-2,-1) node[left] {Dummy text} -- (0,-2) node[right] {Hello World};
\end{tikzpicture}
\end{document}

여기에 이미지 설명을 입력하세요

데카르트 좌표 대신 극좌표를 사용할 수 있습니다. 또한 이 방법은 매우 자연스럽고(저는 이 방법을 선호합니다) Ti가 필요하지 않습니다.케이Z 라이브러리. 그러나 이것은 표준적인 방법이 아닙니다( \draw내가 아는 한 이 작업을 수행해서는 안 됩니다).

방법 2

\documentclass[tikz,margin=3mm]{standalone}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\node (x) {Something};
\node[below left=1cm and 2cm of x.south west] (o) {Dummy text};
\node[below right=1cm and 2cm of o.south east] (y) {Hello World};
\draw (x.west)--(o.east)--(y.west);
\end{tikzpicture}
\end{document}

여기에 이미지 설명을 입력하세요

이 방법은 Ti에 문자열을 삽입하기 위한 표준 명령을 사용합니다.케이Z 사진: \node. 그러나 텍스트를 정렬하고 위치를 제어하는 ​​것은 정말 쉬운 일이 아닙니다. IMHO. 도서관이 필요합니다 positioning.

방법 3

\documentclass[tikz,margin=3mm]{standalone}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\coordinate[label=right: Something] (x);
\coordinate[label=right: Hello World,below=2cm of x] (y);
\coordinate[label=left: Dummy text,below left=1cm and 2cm of x] (o);
\draw (x)--(o)--(y);
\end{tikzpicture}
\end{document}

여기에 이미지 설명을 입력하세요

이 방법은 옵션 \coordinate과 함께 명령을 사용합니다 label.

관련 정보