TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Consider the code below. In the scope environment, I am using a clip to keep the ellipse between the points. From reading, I know with the let command I can access the coordinates of the points by defining them in the let command \p2 = (P2). Can I access the coordinates to use in the clip?

The goal is so if I change P2, the clip will change too.

  \documentclass[tikz, border=5mm]{standalone}
  \usetikzlibrary{arrows,calc, decorations.markings, intersections}


    dot/.style = {outer sep = +0pt, inner sep = +0pt, shape = circle, draw = black, label = {#1}},
    small dot/.style = {minimum size = 1pt, dot = {#1}},
    big dot/.style = {minimum size = 2pt, dot = {#1}},
    line join = round, line cap = round, >=triangle 45
    \node[ fill = black, big dot = {below: \(F\)}] (F) at (0, 0) {};
    \node[ fill = black, big dot = {below: \(P_1\)}] (P1)  at (2, 0) {};
    \node[ fill = black, big dot = {above right=.25cm:\(P_2\)}] (P2) at (-2, 2) {};    

    \begin{scope}[decoration = {markings,
        mark = at position 0.5 with {\arrow{>}}
      \clip (2, 0) -- (-2, 0) -- (-2, 2.2) -- (2, 2.2) -- cycle;
      \draw[name path global = ellp, postaction = decorate] let
        \p0 = ($(P2) - (F)$),
        \p1 = ($(P1) - (P2)$)
      in (P2|-P1) ++ (\x1, 0) arc (0:100: \x1 and \y0);                                         

\path[name path = aux1] (P2) circle [radius = 1bp];
\draw[name intersections = {of = ellp and aux1}, -latex] (P2) --
\draw [-latex] (P2) --

share|improve this question
What do you mean? You can use (\p2) as well as \x2 and \y2 (in the canvas) after you add \p2 = (P2), though I would add this first, so that you can use \p2 in the calculation of the other nodes, too. — Or do you mean something like \clip (P1) rectangle (P2);? – Qrrbrbirlbel Jun 23 '13 at 21:27
@Qrrbrbirlbel so I can just go into the clip coordinates and add \x2 and \y2 as is? – dustin Jun 23 '13 at 21:30
up vote 1 down vote accepted

Answering directly your question: yes, you can use the let..in syntax as part of a \clip command. For example:

\clip let \p1=(P2) in (\x1,\y1) rectangle (P1);

This will allow you to do some arithmetic on the individual x and y coordinates, but you have a drawback: you need to specify the units of the constants you add or substract, as for example:

\clip let \p1=(P2) in (\x1 + 0.5cm, \y1) rectangle (P1);

if you don't specify the units, tikz will use pt as the default. And since points are very small, you won't see any change simply with \x1+0.5.

Specifying the units is not optimal, since it will make the figure not easily scalable. If you give the option x=5mm, for example, all dimensionless coordinates will be halved, but your 0.5cm constant will not.

A better solution is to use calc expressions, as in:

\clip ($(P2)+(0.5, 0)$) rectangle (P1);

this not only has a clearer syntax, but also works without specifying the dimensions of the (0.5, 0) constant, and thus makes the image easily scalable. Note that to use these kind of expressions \usetikzlibrary{calc} is required (but you had it anyway).

share|improve this answer
Well, whether it is a better solution to use calc expressions I’ll leave that undecided. But it is certainly better to use the rectangle path operator here. Without calc, you can also do \clip [shift=(right:.5)] P2) rectangle (P1); or {(.5,0)} of course. (This is also true for the second code snipped so you don’t need to specify the unit for the 0.5cm part making it flexible to changes in the coordinate system.) – Qrrbrbirlbel Jun 24 '13 at 21:24

Your Answer


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.