1

I would like the two lines of text to the right of the diagonal lines to be left aligned. Is there any way to do this?

\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}

enter image description here

  • Welcome to TeX-SE! Are you looking for anchor=west? – marmot Feb 26 at 6:10
2

You could use anchor=west to specify the location of the box via its leftmost point, or just 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}

enter image description here

1

There are many ways to do that, besides of marmot's methods. Here are three of them (I will add more if I find one in the future).

Method 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}

enter image description here

You can use polar coordinates instead of Cartesian coordinates. Also, this way is quite natural (I prefer this way) and doesn't require any TikZ libraries. However, this is not quite a standard way (\draw is not supposed to do this stuff, as far as I know).

Method 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}

enter image description here

This way use the standard command for inserting strings to TikZ pictures: \node. However, aligning the texts and controlling the positions are not really easy IMHO. You need positioning library.

Method 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}

enter image description here

This way uses \coordinate command with label option.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.