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.

I would like to have an obtuse triangle with vertices A, B, and C drawn. The lengths of the sides are to be labeled a, b, and c. If the angle at C is the obtuse angle, the height of the triangle is to be drawn as a dashed line segment from A, and the side BC is to be extended as a dashed line segment to the point P of its intersection with the dashed line segment indicating the height of the triangle.

I would also like the angle marked with one "|" to be an interior angle, and I would like the lengths of the sides to be outside the triangle. What does [auto] in \tkzLabelSegment[auto] tell TikZ to draw?

I guess that a command like \tkzDefPointWith[orthogonal normed,K=blah](B,C) is to be used. Is there a manual describing some of the commands of tkz-euclide? I just saw that there is a command \tkzDefTriangle[equilateral] for having TikZ calculate the coordinates of the third vertex of a triangle given its two other vertices so as to get an equilateral triangle.

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


\begin{document}

\begin{tikzpicture}

\tkzDefPoint(0,-1){C}
\tkzDefPoint(4,1){B}
\tkzDefPoint(-1,3){A}


\tkzLabelPoint[left](A){$A$}
\tkzLabelPoint[right](B){$B$}
\tkzLabelPoint[below](C){$C$}


\tkzDrawSegment[green!60!black](A,C)
\tkzDrawSegment[green!60!black](C,B)
\tkzDrawSegment[green!60!black](B,A)

\tkzLabelSegment[auto](B,A){$c$}
\tkzLabelSegment[auto,swap](B,C){$a$}
\tkzLabelSegment[auto,swap](C,A){$b$}


\tkzMarkAngle[size=1cm,color=cyan,mark=|](C,B,A)
\tkzMarkAngle[size=1cm,color=cyan,mark=||](C,A,B)
\end{tikzpicture}

\end{document}
share|improve this question
2  
Providing MWE with an image of its output is recommended to ease us understanding your case at a glance. –  In PSTricks we trust Aug 24 at 15:14
    
What prompted you to choose "cyanide-based food" as your user name? How do I include the diagram that TikZ draws from my code on this site? I like the code that Mark Wibrow provided. It gives me the diagram that I wanted. I still have questions regarding my code. Why is an exterior angle drawn at C? Why are the lengths of the sides written inside the triangle? –  user60254 Aug 24 at 22:55
    
Regarding the username, it is randomly chosen just for fun as usual. Regarding uploading your diagram, see my answer here (click). I am preparing my own answer for you. –  In PSTricks we trust Aug 25 at 4:43

4 Answers 4

up vote 6 down vote accepted

Something like this?

\documentclass[tikz, border=5]{standalone}
\begin{document}
\begin{tikzpicture}
\path (120:3) coordinate (A) (0:3) coordinate (B) (0:0) coordinate (C);
\draw (A) 
  -- (B) node [at start, above left] {$A$} node [midway, above] {$c$}
  -- (C) node [at start, right]      {$B$} node [midway, below] {$a$}
  -- (A) node [at start, below]      {$C$} node [midway, below] {$b$}
  -- cycle;
\draw [dashed] (A) |- (C) node [midway, below left] {$P$};
\draw (0:.5) arc (0:120:.5) (60:.4) -- (60:.6);
\end{tikzpicture}
\end{document}

enter image description here

or this...

\documentclass[tikz, border=5]{standalone}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\path (80:3) coordinate (A) (-30:3) coordinate (B) (0:0) coordinate (C);
\draw (A) 
  -- (B) node [at start, above left] {$A$} node [midway, right] {$c$}
  -- (C) node [at start, right]      {$B$} node [midway, below] {$a$}
  -- (A) node [at start, below]      {$C$} node [midway, left]  {$b$}
  -- cycle;
\coordinate (P) at ($(B)!(A)!(C)$);
\draw [dashed] (A) -- (P) node [below left] {$P$} -- (C);
\draw ($(C)!0.5cm!(B)$) arc (-30:80:.5cm) node [midway, sloped] {$|$};
\end{tikzpicture}
\end{document}

enter image description here

share|improve this answer
    
This is a diagram of an obtuse triangle indicating its height. This is the diagram that I said that I wanted. I should have specified that I do not want any sides of the triangle to be horizontal or vertical. To draw the dashed line segments indicating the height of such a triangle, you cannot use "\draw [dashed] (A) |- (C)node [midway, below left] {$P$};". Can you give me the code for instructing TikZ to draw such a triangle? –  user60254 Aug 24 at 23:45
    
@user60254, The calc library can be used for this, see my updated answer. Note that the position of the labels has to be changed as this is not done automatically. –  Mark Wibrow Aug 25 at 6:00
    
This is the diagram that I wanted! (You have an error in your code. You have "node [below left] {$P$} -- (C)". You are missing a comma between "below" and "left".) –  user60254 Aug 29 at 19:00
    
This is the diagram that I wanted! (You have an error in your code. You are missing a comma between "below" and "left" in the command to typeset the letter "P".) –  user60254 Aug 29 at 20:00
    
@user60254 actually below left is a valid option. If it produces an error for you, then you may need to update your PGF version. –  Mark Wibrow Aug 31 at 7:15

A PSTricks solution using the pst-eucl package:

\documentclass{article}

\usepackage{pst-eucl}

\def\Label[#1]#2#3#4{
  \pcline[linestyle = none, offset = #1](#2)(#3)
  \ncput*{$#4$}
}

\begin{document}

\psset{unit = 0.9}
\begin{pspicture}(-0.35,-0.5)(12.5,8.4)
  \pnode(0,0){P}
  \pstTriangle(0,8){A}(12,0){B}(4,0){C}
 \psset{CodeFig, CodeFigColor = blue, LabelSep = 0.7}
  \pstMarkAngle{C}{A}{B}{$\alpha$}
  \pstMarkAngle{A}{B}{C}{$\beta$}
  \pstMarkAngle{B}{C}{A}{$\gamma$}
  \Label[8pt]{A}{B}{c}
  \Label[8pt]{B}{C}{a}
  \Label[-8pt]{A}{C}{b}
  \pstProjection{P}{C}{A}[P]
  \pstProjection[PointName = none]{A}{P}{C}[Q]
\end{pspicture}

\end{document}

output1

or

\documentclass{article}

\usepackage{pst-eucl}

\def\Label[#1]#2#3#4{
  \pcline[linestyle = none, offset = #1](#2)(#3)
  \ncput*{$#4$}
}

\begin{document}

\psset{unit = 0.9}
\begin{pspicture}(-0.35,-0.5)(12.5,8.4)
  \pnode(0,0){P}
  \pstTriangle(0,8){A}(12,0){B}(4,0){C}
 \psset{CodeFig, CodeFigColor = blue, LabelSep = 0.8, MarkAngle = 90}
  \pstMarkAngle[Mark = MarkHash]{C}{A}{B}{$\alpha$}
  \pstMarkAngle[Mark = MarkHashh]{A}{B}{C}{$\beta$}
  \pstMarkAngle[Mark = MarkHashhh]{B}{C}{A}{$\gamma$}
  \Label[8pt]{A}{B}{c}
  \Label[8pt]{B}{C}{a}
  \Label[-8pt]{A}{C}{b}
  \pstProjection{P}{C}{A}[P]
  \pstProjection[PointName = none]{A}{P}{C}[Q]
\end{pspicture}

\end{document}

output2

share|improve this answer

What does [auto] in \tkzLabelSegment[auto] tell TikZ to draw?

auto is a tikz option to put the labels to the segments/curves such that they are not on the curve but next to it. If you add swap option additionally, tikz will mirror the label with respect to the line. See this example:

\documentclass{article}
\usepackage{tikz}
\begin{document}
  Without any option to label node:

  \begin{tikzpicture}
    \draw (0,0) -- node {1} (2,3);
  \end{tikzpicture}

  With the option \verb|auto|:

  \begin{tikzpicture}
    \draw (0,0) -- node[auto] {1} (2,3);
  \end{tikzpicture}

  With the option \verb|auto| and \verb|swap|:

  \begin{tikzpicture}
    \draw (0,0) -- node[auto,swap] {1} (2,3);
  \end{tikzpicture}
\end{document}

enter image description here

To draw the perpendicular you can use

\tkzDrawAltitude[dashed,color=magenta](C,B)(A)

which tells tikz to draw a perpendicular from A onto the segment CB.

Now the code with comments in it for explanation:

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


\begin{document}

\begin{tikzpicture}

\tkzDefPoint(0:0){C}
\tkzDefPoint(0:3){B}
\tkzDefPoint(120:3){A}



\tkzLabelPoint[left](A){$A$}
\tkzLabelPoint[right](B){$B$}
\tkzLabelPoint[below](C){$C$}

\tkzDrawSegment[green!60!black](A,C)
\tkzDrawSegment[green!60!black](C,B)
\tkzDrawSegment[green!60!black](A,B)

\tkzDrawAltitude[dashed,color=magenta](C,B)(A)   %% draw the perpendicular
\tkzGetPoint{P}                                  %% get the point P
\tkzLabelPoint[below](P){$P$}                    %% label the point P
\tkzDrawSegment[dashed,color=magenta](C,P)       %% draw CP

\tkzLabelSegment[auto,swap](B,A){$c$}
\tkzLabelSegment[auto](B,C){$a$}
\tkzLabelSegment[auto](C,A){$b$}


%% here use the correct order. For example, BCA is inner angle and ACB is outer angle
\tkzMarkAngle[size=0.5cm,color=cyan,mark=|](B,C,A)
\tkzMarkAngle[size=1cm,color=cyan,mark=||](C,A,B)
\tkzMarkAngle[size=1cm,color=cyan,mark=|||](A,B,C)

\end{tikzpicture}

\end{document}

enter image description here

Is there a manual describing some of the commands of tkz-euclide?

tkz-euclide-screen is the manual for tkz-euclide and unfortunately it is in French (Allain is French). But it has sample codes to illustrate almost all the commands. You can get it by texdoc tkz-euclide from your command line/terminal or from texdoc.net. You have to read tikz manual too along with tkz-euclide-screen.

share|improve this answer
    
Thanks for answering my questions regarding syntax and commands. Maybe I will use a French-to-English translation web site to read the manual that you suggested. –  user60254 Aug 29 at 19:09

Just for typing exercise with PSTricks.

\documentclass[pstricks,border=20pt,12pt]{standalone}
\usepackage{pst-eucl}

\begin{document}
\begin{pspicture}[CodeFigColor=.,shortput=nab](8,6)
    %
    % drawing the triangle
    \pstTriangle(0,6){A}(8,0){B}(3,0){C}
    %
    % projecting the point A onto BC (extension)
    \psline[linestyle=dashed](A|0,0)(C)
    \pstProjection[CodeFig]{B}{C}{A}[P]
    %
    % labeling and marking angles
    \psset{MarkAngleRadius=.5,LabelSep=1,MarkAngle=90}
    \pstMarkAngle[Mark=MarkHash]{C}{A}{B}{$\alpha$}
    \pstMarkAngle[Mark=MarkHashh]{A}{B}{C}{$\beta$}
    \pstMarkAngle[Mark=MarkHashhh]{B}{C}{A}{$\gamma$}
    %
    % labeling sides
    \psset{linestyle=none}
    \pcline(A)(B)^{$c$}
    \pcline(A)(C)_{$b$}
    \pcline(C)(B)_{$a$}
\end{pspicture}

\end{document}

enter image description here

Animated version

\documentclass[pstricks,border=20pt,12pt]{standalone}
\usepackage{pst-eucl}

\def\Atom#1{%
\begin{pspicture}[CodeFigColor=.,shortput=nab,saveNodeCoors,NodeCoorPrefix=N](8,6)
    %
    % drawing the triangle
    \pstTriangle(8,0){B}(3,0){C}(6;#1){A}
    %
    % projecting the point A onto BC (extension)
    \psline[linestyle=dashed](A|0,0)(C)
    \pstProjection[CodeFig]{B}{C}{A}[P]
    %
    % labeling and marking angles
    \psset{MarkAngleRadius=.5,LabelSep=1,MarkAngle=90}
    \pstMarkAngle[Mark=MarkHash]{C}{A}{B}{$\alpha$}
    \pstMarkAngle[Mark=MarkHashh]{A}{B}{C}{$\beta$}
    \pstMarkAngle[Mark=MarkHashhh]{B}{C}{A}{$\gamma$}
    %
    % labeling sides
    \psset{linestyle=none}
    \pcline(A)(B)^{$c$}
    \pcline(A)(C)_{$b$}
    \pcline(C)(B)_{$a$}
\end{pspicture}}

\begin{document}
\multido{\i=30+5}{13}{\Atom{\i}}
\end{document}

enter image description here

share|improve this answer

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.