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

enter image description here

\documentclass[pstricks,border=20pt]{standalone}
\usepackage{pst-eucl}

\begin{document}
\begin{pspicture}(3,3)
   \pstGeonode(0,0){A}(3,3){B}
   \pnode([nodesep=10pt]{B}A){A'}
   \pnode([nodesep=10pt]{A}B){B'}
   \psline(A)(A')
   \psline[linestyle=dashed,linecolor=red](A')(B')
   \psline(B')(B)
\end{pspicture}
\end{document}

What is the equivalent for ([nodesep=10pt]{B}A) in TikZ? In PSTricks it represents a point that is 10pt apart from A and on a line joining A and B.

share|improve this question
up vote 13 down vote accepted

You can use ($(A)!1cm!(B)$) to move a specific distance along the path as shown in the second image. The first image is the more usual usage to move a certain percentage along the line:

enter image description here

Code:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}
\begin{tikzpicture}
    \coordinate (A) at (0,4);
    \coordinate (B) at (3,6);
    \draw [thin, blue] (A) -- (B);
    \node [below] at (A) {A};
    \node [above] at (B) {B};


    \coordinate (A') at ($(A)!0.25!(B)$);
    \draw [ultra thick, red] (A) -- (A') node [above left,black] {(\$(A)!0.25!(B)\$)};
\end{tikzpicture}
\begin{tikzpicture}
    \coordinate (A) at (0,4);
    \coordinate (B) at (3,6);
    \draw [thin, blue] (A) -- (B);
    \node [below] at (A) {A};
    \node [above] at (B) {B};

    \coordinate (A') at ($(A)!1cm!(B)$);
    \draw [ultra thick, red] (A) -- (A') node [below right,black] {(\$(A)!1cm!(B)\$)};
\end{tikzpicture}

\end{document}
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.