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.

TikZ compiles the following code and renders a line segment with endpoints $A$ and $C$ and with a point $B$ between these endpoints. It also marks the length of $\overline{AB}$ as $x$ and the length of $\overline{BC}$ as $y$.

Above this diagram, I would like to have the length of $\overline{AC}$ marked as $z$. The following is a description of how it should be marked. A "|" should be drawn above the endpoints, a line with arrowheads between the two "|" should be drawn, and the letter "z" should be set in the middle of this line. (I think the overlay command is used to set the letter "z".)

\documentclass[10pt]{amsart}
\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings}
\usepackage{tkz-euclide}
\usetkzobj{all}

\begin{document}

\begin{tikzpicture}
\tikzset{
mydot/.style={
  fill,
  circle,
  inner sep=1.5pt
  }
}
\path (150:4.5) coordinate (A) (150:1.5) coordinate (B) (0:0) coordinate (C);
\draw (A)
-- (B) node [midway, above]{$x$} -- (C) node [midway, above]{$y$}  -- (A) -- cycle;
\node[mydot,label={below left:$A$}] at (A) {};
\node[mydot,label={below left:$B$}] at (B) {};
\node[mydot,label={below left:$C$}] at (C) {};
\end{tikzpicture}

\end{document}
share|improve this question

1 Answer 1

up vote 3 down vote accepted

Something like

enter image description here

is obtained adding

\draw[|<->|] ($(A)!5mm!90:(C)$)--node[fill=white] {$z$} ($(C)!5mm!-90:(A)$);

Explanation

($(A)!5mm!90:(C)$) is a new coordinate placed at 5mm of (A) and forming an angle of 90 degrees respect to the line (A) -- (C) (It corresponds to the upper extreme).

More information about Distance modifiers in the page 145 of pgfmanual 3.0.0.

Full Code

\documentclass[10pt]{amsart}
\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings}
\usepackage{tkz-euclide}
\usetkzobj{all}

\begin{document}

\begin{tikzpicture}
\tikzset{
mydot/.style={
  fill,
  circle,
  inner sep=1.5pt
  }
}
\path (150:4.5) coordinate (A) (150:1.5) coordinate (B) (0:0) coordinate (C);
\draw (A)
-- (B) node [midway, above]{$x$} -- (C) node [midway, above]{$y$}  -- (A) -- cycle;
\node[mydot,label={below left:$A$}] at (A) {};
\node[mydot,label={below left:$B$}] at (B) {};
\node[mydot,label={below left:$C$}] at (C) {};
\draw[|<->|] ($(A)!5mm!90:(C)$)--node[fill=white] {$z$} ($(C)!5mm!-90:(A)$);
\end{tikzpicture}

\end{document}
share|improve this answer
    
What does "$(A)!5mm!90:(C)$" instruct TikZ to draw? What is 5mm? How does this instruct TikZ to draw a line parallel to $\overline{AC}$? What does "($(C)!5mm!-90:(A)$)" instruct TikZ to draw? –  user60254 Aug 30 at 17:47
    
@user60254 View Edit for some explanation. –  skpblack Aug 30 at 18:00

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.