0

I'm writing a paper for college. In this paper, we're discussing geometric shapes: both polygons and polyhedra. In my build up for a general formula for the area of a polygon, I'm using the triangle as a starting point. I'd like a line segment, bisector, of the triangle labeled at "h" for the all-to-familiar A=1/2bh of a triangle's area. Here's my minimal working example:

\documentclass[letterpaper,11pt]{article}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\usepackage{tkz-euclide}

\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\node[minimum size=3cm,regular polygon,regular polygon sides=3] (a) {};
\draw (a.corner 1) -- (a.corner 2) -- node[below] {b} (a.corner 3) -- cycle;
\draw (a.corner 1) -- node[right]{$h$} (0,-0.75);
\end{tikzpicture}
\end{figure}
\end{document}

Which yeilds this triangle. You'll notice that the top bisector isn't "quite right." Although, perhaps workable, I'd like it to look better. Help is much appreciated because I'm quite new to this.

I've learned, through this site, using the geometry subpackage/library/whatever of tikz for the polygons. I'm struggling though whole bisector thing though. I found tkz-euclide at this post but it seems a bit heavyweight for what I'm trying to accomplish. I'm really just looking for a line from the top of the triangle to the midpoint of the vertices of the base with a nice "h" label next to it. Whatever help can be given is great.

Thanks,
Andy

  • I think "top bisector isn't quite right" is a viewer problem. Did you try to zoom on it? – Ignasi Oct 26 '16 at 17:38
1

Do you want something like this? The anchor (a.south) denotes the point on the edge of the node directly below the center. Note that you could also use (a.north) or (a.90) (in this case) in place of (a.corner 1). I've also drawn the triangle when the node is created instead of doing it by manually later.

\documentclass[tikz, border=3pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}

\begin{document}
\begin{tikzpicture}
\node[draw, minimum size=3cm,regular polygon,regular polygon sides=3] (a) {};
\draw (a.corner 1) -- node[right]{$h$} (a.south) node[below]{$b$};
\end{tikzpicture}
\end{document}

triangle

  • This is fascinating! Can you explain more fully the syntax/relations being used? Sorry, but I'm in a crash-course for tikz and it's taking its toll. Oh, interesting, I didn't know one could draw the polygon with options to the \node[......] (a) {} command. That's cool. – Andrew Falanga Oct 27 '16 at 16:58
  • The syntax (<node>.<angle>) is called a border anchor, and gives the point on the border of the node at the specified angle (from the center, I guess, but the actual reference point may vary by node shape). There are lots of other anchors, and which ones are available (and what they mean) depends on the node shape. To see what anchors your node shape offers, you can consult Section 67 (Shape Library) of the tikz/pgf manual. To learn more about the placement of nodes, see Sections 17.5 (Positioning Nodes) and 17.9 (Placing Nodes on a Line or Curve Implicitly) of the same manual. – Emma Oct 27 '16 at 17:33
0

I can not reproduce your problem. anyway, sww if the folowing change of your code gives better result:

\documentclass[letterpaper,11pt]{article}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
%\usepackage{tkz-euclide}

\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\node[minimum size=3cm,regular polygon,regular polygon sides=3] (a) {};
\draw (a.corner 1) -- (a.corner 2) -- node[below] {b} (a.corner 3) -- cycle;
\draw (a.corner 2 -| a.corner 1) -- node[right]{$h$} (a.corner 1);
\end{tikzpicture}
\end{figure}
\end{document}

enter image description here

  • Thank you. Can you explain to me what this means, "(a.corner 2 -| a.corner 1)"? I get the nodes but what is -| doing? – Andrew Falanga Oct 27 '16 at 16:53
  • (a.corner 2 -| a.corner 1) determine coordinate of intersection of the horizontal line through a.corner 2 and vertical line through ą.corner 1, i.e.: -| means orthogonal coordinate. I encourage you to read PGF ˛TikZ Manual. In part III "TikZ ist kein Zeichenprogram" – Zarko Oct 27 '16 at 17:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.