3

yshift is not working with points defined by 'tkz-euclide'

How to make it work?

\documentclass[border=5mm]{standalone}
\usepackage{tkz-euclide}
\usetkzobj{all}

\begin{document}

\begin{tikzpicture}[scale=1.5]

\tkzDefPoint(0,0){A}
\tkzDefPoint(2,0){B}

\tkzDrawSegment(A,B)

\tkzDrawPoints(A,B)
\tkzLabelPoints[below](A,B) 

%not working
\begin{scope}[yshift=-1cm]
\draw [|<->|] (A) -- node[above]{2 cm} (B);
\end{scope}

%working
\begin{scope}[yshift=-1cm]
\draw [|<->|] (0,0) -- node[above]{2 cm} (2,0);
\end{scope}

\end{tikzpicture}
\end{document}

enter image description here

1
  • If you really need the shift inside the scope, you have to write \begin{scope}[transform canvas={yshift=-1cm}] instead of \begin{scope}[yshift=-1cm]. But you should be careful when using transform canvas key. Also, it is necessary to adjust the bounding box that is calculated incorrectly in such case.
    – Marian G.
    Commented May 30, 2019 at 10:53

2 Answers 2

2

Now i got a solution....

\draw [|<->|,>=stealth] ([yshift=1cm]A) -- node[above]{2 cm} ([yshift=1cm]B);

\documentclass[border=5mm]{standalone}
\usepackage{tkz-euclide}
\usetkzobj{all}

\begin{document}

\begin{tikzpicture}[scale=1.5]

\tkzDefPoint(0,0){A}
\tkzDefPoint(2,0){B}

\tkzDrawSegment(A,B)

\tkzDrawPoints(A,B)
\tkzLabelPoints[below](A,B) 

%now working
\draw [|<->|,>=stealth] ([yshift=1cm]A) -- node[above]{2 cm} ([yshift=1cm]B);


%working
\begin{scope}[yshift=-1cm]
\draw [|<->|] (0,0) -- node[above]{2 cm} (2,0);
\end{scope}

\end{tikzpicture}
\end{document}
2

A solution with tkz-euclide

\documentclass[border=5mm]{standalone}
\usepackage{tkz-euclide}

\begin{document}

\begin{tikzpicture}[scale=1.5]

\tkzDefPoint(0,0){A}
\tkzDefPoint(2,0){B}

\tkzDrawSegment(A,B)
\tkzDrawPoints(A,B)

\tkzLabelPoints[below](A,B) 
\tkzDrawSegment[|<->|]([yshift=-1cm]A,[yshift=-1cm]B)
\tkzLabelSegment[above]([yshift=-1cm]A,[yshift=-1cm]B){$2$ cm}

\end{tikzpicture}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .