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.

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
add comment

1 Answer 1

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
add comment

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.