6

I have the following drawn in Tikz.

enter image description here

using the following code

\documentclass{article}
\usepackage{tikz}
\usepackage{tkz-euclide}
\begin{document}
\begin{tikzpicture}
\coordinate[label= above left:$O$] (O) at (0,0);
\draw (O) circle (3);
\coordinate[label = below left:$P$] (P) at (-90:3);
\coordinate (Q) at (-25:3);
\node at ([shift = {(-30:3.3)}]O.-35) {$Q$};
\draw (O)-- (P)-- (Q) -- cycle;
\coordinate[label = right:$R$] (R) at (6.5,-3);
\draw (R)--(P)--(Q)--cycle;
\draw (O) -- ($(P)!(O)!(Q)$) node[draw,pos=1,sloped, anchor = north east]{}node[pos=1.08]{$T$};
\end{tikzpicture}
\end{document}

I now want to add a sloped label above line QR that says "24 cm" and also one for line OT as "12 cm".

I want something like this

enter image description here

EDIT: I managed to get the sloped label, but how can I get arrows such as in the (badly hand drawn) image?

I used the following for the text

\draw (Q) -- (R) node[sloped, anchor = south east, pos =0.5]{$24 cm$};

How can I do this?

user860374
  • 1,165

1 Answers1

11

Without braces:

\documentclass{article}
\usepackage{tikz}
\usepackage{siunitx}
\usepackage{tkz-euclide}
\begin{document}
\begin{tikzpicture}
\coordinate[label= above left:$O$] (O) at (0,0);
\draw (O) circle (3);
\coordinate[label = below left:$P$] (P) at (-90:3);
\coordinate (Q) at (-25:3);
\node at ([shift = {(-30:3.3)}]O.-35) {$Q$};
\draw (O)-- (P)-- (Q) -- cycle;
\coordinate[label = right:$R$] (R) at (6.5,-3);
\draw (R)--(P)--(Q)-- node[above,sloped] {\SI{24}{\cm}}cycle;
\draw (O) -- ($(P)!(O)!(Q)$) node[draw,pos=1,sloped, anchor = north east]{}node[pos=1.08]{$T$} node[midway,above,sloped] {\SI{12}{\cm}};
\end{tikzpicture}
\end{document}

enter image description here

With braces:

\documentclass{article}
\usepackage{tikz}
\usepackage{siunitx}
\usepackage{tkz-euclide}
\usetikzlibrary{decorations.pathreplacing}
\begin{document}
\begin{tikzpicture}
\coordinate[label= above left:$O$] (O) at (0,0);
\draw (O) circle (3);
\coordinate[label = below left:$P$] (P) at (-90:3);
\coordinate (Q) at (-25:3);
\node at ([shift = {(-30:3.3)}]O.-35) {$Q$};
\draw (O)-- (P)-- (Q) -- cycle;
\coordinate[label = right:$R$] (R) at (6.5,-3);
\draw (R)--(P)--(Q)-- cycle;
\draw (O) -- ($(P)!(O)!(Q)$) coordinate (T) node[draw,pos=1,sloped, anchor = north east]{}node[pos=1.08]{$T$};
\draw[decorate,decoration={brace,raise=3pt}]
  (Q)  -- node[above=6pt,sloped] {\SI{24}{\cm}} (R);
\draw[decorate,decoration={brace,raise=3pt}]
  (O)  -- node[above=6pt,sloped] {\SI{12}{\cm}} (T);
\end{tikzpicture}
\end{document}

enter image description here

With dimension arrows:

\documentclass{article}
\usepackage{tikz}
\usepackage{siunitx}
\usepackage{tkz-euclide}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{tikzpicture}
\coordinate[label= above left:$O$] (O) at (0,0);
\draw (O) circle (3);
\coordinate[label = below left:$P$] (P) at (-90:3);
\coordinate (Q) at (-25:3);
\node at ([shift = {(-30:3.3)}]O.-35) {$Q$};
\draw (O)-- (P)-- (Q) -- cycle;
\coordinate[label = right:$R$] (R) at (6.5,-3);
\draw (R)--(P)--(Q)-- cycle;
\draw (O) -- ($(P)!(O)!(Q)$) coordinate (T) node[draw,pos=1,sloped, anchor = north east]{}node[pos=1.08]{$T$};

\coordinate (aux1) at ( $ (Q)!7pt!90:(R) $ );
\coordinate (aux2) at ( $ (R)!7pt!-90:(Q) $ );

\coordinate (aux3) at ( $ (O)!7pt!90:(T) $ );
\coordinate (aux4) at ( $ (T)!7pt!-90:(O) $ );

\draw[|<->|,>=latex]
  (aux1)  -- node[fill=white,sloped] {\SI{24}{\cm}} (aux2);
\draw[|<->|,>=latex]
  (aux3)  -- node[fill=white,sloped] {\SI{12}{\cm}} (aux4);
\end{tikzpicture}

\end{document}

enter image description here

Gonzalo Medina
  • 505,128
  • Thank you! :). I managed to get the text (see my edit), Can you please explain to me how I can get the arrows that I edited in the question? :) – user860374 Aug 10 '15 at 19:35
  • @DJS Give me some minutes. Please, ask all your requirements from the beginning. – Gonzalo Medina Aug 10 '15 at 19:42
  • Thank you! I really appreciate it :). I am very sorry - I only noticed that the graph looks unclear without arrows after I managed to get the label working. – user860374 Aug 10 '15 at 19:46
  • @DJS You're welcome. In my answer I had already added an option with braces, and in the last update, I added one option showing how to get dimension arrows. – Gonzalo Medina Aug 10 '15 at 19:47
  • This is perfect! :D. Exactly what I needed :). – user860374 Aug 10 '15 at 19:47
  • @DJS Glad I could help :) In the meantime, I updated the answer with an improvement in the option using dimension arrows. – Gonzalo Medina Aug 10 '15 at 20:18