Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have several coordinate specified in TikZ, say

\coordinate (a) at (0.4, 1.7);
\coordinate (b) at (3.2, 1.7);
\coordinate (c) at (1.7, 4.7);
\coordinate (cog) at ($1/3*(a) + 1/3*(b) + 1/3*(c)$);

Now I'm trying to use the (cog) coordinate in PGF commands, for example:

\pgftransformshift{<the (cog) coordinate>}

I already tried putting in (cog) or cog but it doesn't work as desired. So my question is: How do I convert my coordinate specified in TikZ so that I can use it inside PGF commands?

share|improve this question

1 Answer 1

up vote 9 down vote accepted

Coordinates also have anchors (well, only center anchor) and that can be used for referencing.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\draw[style=help lines] (0,0) grid[step=1cm] (5,5);
\coordinate (a) at (0.4, 1.7);
\coordinate (b) at (3.2, 1.7);
\coordinate (c) at (1.7, 4.7);
\coordinate (cog) at ($1/3*(a) + 1/3*(b) + 1/3*(c)$);
\pgftransformshift{\pgfpointanchor{cog}{center}}
\draw (0,0) -- (2,2);
\end{tikzpicture}
\end{document}

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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