# Using the perpendicular coordinate system with tikzmark

How do I refer to the coordinate that is the meeting point of the perpendiculars drawn from a tikz mark and a coordinate?

I'd like to use this to align images to bullet points in my beamer presentation, for example,

\documentclass[xcolor={svgnames}]{beamer}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{calc,positioning,tikzmark}

\begin{document}

\begin{frame}
\frametitle{Latent Variable Models}

\begin{itemize}
\item Item 1 \tikzmark{a}
\begin{itemize}
\item sub item 1
\item sub item 2
\item sub item 3
\item sub item 4
\end{itemize}
\item Item 2 \tikzmark{b}
\begin{itemize}
\item sub item 1
\item sub item 2
\item sub item 3
\item sub item 4
\end{itemize}
\end{itemize}
\begin{tikzpicture}[remember picture, overlay]
\draw[use as bounding box] (current page.north west) rectangle (current page.south east);
\node (mark) at (5cm,0) {m};
\node (a) at (pic cs:a) {a};
\node (b) at (pic cs:b) {b};
\node (p) at (a -| mark) {p};
\node (q) at (b -| mark) {q};
\node (x) at (pic cs:a -| mark) {x};
\node (y) at (pic cs:b -| mark) {y};
\end{tikzpicture}
\end{frame}

\end{document}


Here p and q appear correctly, but x and y do not. It seems like the reason this doesn't work is that the perpendicular operator |- doesn't understand the picture coordinate reference. If I did \node (y) at (mark |- pic cs:b) {y}; instead, I get the error "unknown coordinate system 'mark |- pic'".

• I don't know where do you want to place x and y, but \node (x) at ({pic cs:a} -| mark) {x}; draws x over p. – Ignasi Jun 11 '13 at 7:06
• @Ignasi Indeed, if the code worked correctly, I should have x over p. I wanted to achieve the same effect without having to define a new node a. – arunchaganty Jun 11 '13 at 17:15

I'm pretty sure that this is the same underlying issue as that in Combining |- and !.5! in TikZ (see my answer there for the gory details), namely that there are two pieces of complicated syntax in (pic cs:a -| mark) which TikZ has to figure out: the pic cs:a and the -|. The problem is that it checks for the cs: syntax first before the -| syntax and so it passes the whole thing off to the cs: processor and never looks at the -| (it looks for a tikzmark with name a -| mark).

What you want is for the checks to happen the other way around because you want it to notice the -| first and only afterwards look at the cs:. So you need to protect the pic cs:a part from the processor in the first pass. The way to do that is to enclose it in braces, as Ignasi says in his comment. This ensures that TikZ sees the -| first and only sees the pic cs:a when it is fed back into the parser.

Thus:

\documentclass[xcolor={svgnames}]{beamer}
%\url{https://tex.stackexchange.com/q/118584/86}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{calc,positioning,tikzmark}

\begin{document}

\begin{frame}
\frametitle{Latent Variable Models}

\begin{itemize}
\item Item 1 \tikzmark{a}
\begin{itemize}
\item sub item 1
\item sub item 2
\item sub item 3
\item sub item 4
\end{itemize}
\item Item 2 \tikzmark{b}
\begin{itemize}
\item sub item 1
\item sub item 2
\item sub item 3
\item sub item 4
\end{itemize}
\end{itemize}
\begin{tikzpicture}[remember picture, overlay]
\draw[use as bounding box] (current page.north west) rectangle (current page.south east);
\node (mark) at (5cm,0) {m};
\node (a) at (pic cs:a) {a};
\node (b) at (pic cs:b) {b};
\node (p) at (a -| mark) {p};
\node (q) at (b -| mark) {q};
\node (x) at ({pic cs:a} -| mark) {x};
\node (y) at ({pic cs:b} -| mark) {y};
\end{tikzpicture}
\end{frame}

\end{document}


Produces:

• Ah, thanks @Andrew! I tried using parentheses (e.g. ((pic cs:a) -| mark)) to no avail. – arunchaganty Jun 11 '13 at 17:12