3

1) I'm a drawing triangles in latex, but I want the vertices A and B to be horizontal. In the code below vertices A and C are horizontal. I have problem changing the code.

2) I want to add a stripping/dashed line from C to a point D on the segment AB, representing the height of the triangle. Please help. This is my code:

\documentclass[margin=10pt]{standalone}
\usepackage{amsmath,tkz-euclide}
\usepackage{tikz}
\usetkzobj{all}

\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings,shapes}

\tikzset{
    myangle/.style={fill=green!20!white, draw=green!50!black,size=.3,opacity=.3},
    intnode/.style={circle,fill=black,inner sep=1pt,outer sep=0pt}
}

\begin{document}
\begin{tikzpicture}

% Drawing the triangle and the coordinates
\draw coordinate[label=left:A] (a) --++(60:6) coordinate[label=above:B] (b);

\path[name path=ac] (a)--++(0:8.5);
\path[name path=bc] (b)--++(-45:8);
\path[name intersections={of = ac and bc, by=c}];
\node[anchor=west] at (c) {C};

\draw[use as bounding box] (a)--(b)--(c)--cycle;

% Drawing the coordinates S and T
%\coordinate (s) at ($(a)!0.75!(b)$);

%\path[name path=incls] (s) --++ (-10:5);
\path[name path=altbc] (b) -- (c);
%\path[name intersections={of = incls and altbc, by=t}]; 

%\draw[dashed] (s) -- (t) node[intnode,label={right:{\color{black}\scriptsize $T$}}] (t) {};

% Angles
\tkzFindAngle(a,b,c)
\tkzGetAngle{angleABC};
\FPround\angleABC\angleABC{0}
\tkzFindAngle(c,a,b)
\tkzGetAngle{angleCAB};
\FPround\angleCAB\angleCAB{0}
\tkzFindAngle(b,c,a)
\tkzGetAngle{angleBCA};
\FPround\angleBCA\angleBCA{0}
%\tkzFindAngle(a,s,t)
%\tkzGetAngle{angleAST};
%\FPround\angleAST\angleAST{0}

\tkzMarkAngle[myangle](a,b,c)
\tkzLabelAngle[pos=.4](a,b,c){\tiny $\angleABC^\circ$}

\tkzMarkAngle[myangle](c,a,b)
\tkzLabelAngle[pos=0.5](c,a,b){\tiny $\angleCAB^\circ$}

\tkzMarkAngle[myangle](b,c,a)
\tkzLabelAngle[pos=0.45](b,c,a){\tiny $\angleBCA^\circ$}

%\tkzMarkAngle[myangle](a,s,t)
%\tkzLabelAngle[pos=0.4](a,s,t){\tiny $\angleAST^\circ$}

%\node[intnode,label={left:\scriptsize $S$}] at (s) {};
\end{tikzpicture}
\end{document}
4

in comment you actually ask new question ... if i understood you correctly, you ask something like this:

enter image description here

if i'm correct, than be so kind and ask new question, that i will be able provide code for above image there and in the first place other members on the site have possibilities to help you.

let me mentioned, that for your original question you receive two answers, it is time to select one of them for acceptation. and for follows-up question in your comments ask new question.

code is now available here.

4

pure tikzsolution:

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{angles, intersections, positioning, quotes}
\usepackage{siunitx}

\begin{document}
    \begin{tikzpicture}[
myangle/.style={angle radius=5mm, angle eccentricity=1.6,
                draw=green!50!black, fill=green!20!white}
                        ]
% Drawing the triangle and the coordinates
\coordinate[label=left:A]  (a);
\coordinate[label=right:B,right=8.5 of a] (b);
\path[name path=ac] (a) -- ++ ( 60:6.5);
\path[name path=bc] (b) -- ++ (135:8);
\path[name intersections={of = ac and bc, by=c}] node[label=C] at (c)  {};;
\draw (a)--(c)--(b)--cycle;
% Angles
\pic [myangle, "\ang{60}"] {angle = b--a--c};
\pic [myangle, "\ang{45}"] {angle = c--b--a};
\pic [myangle, "\ang{75}"] {angle = a--c--b};
\draw[dashed] (c) -- (c |- a) coordinate[label=below:D] (d);
    \end{tikzpicture}
\end{document}

enter image description here

  • 1
    @Eirik, if my answer solve your problem, please vote for it and even accept it (by clicking on up-pen and check mark at top left side of answer). this is way how on this site express "thank you". – Zarko Jan 19 '18 at 14:18
  • Can you help me extend this triangle to a quadrilateral such that angle BCE = 90degrees point E has the same y-coordinate as point A? – Eirik Jan 23 '18 at 11:29
  • but this is geometry question, isn't it? :-) at list is new one. as such in comment is not visible to others who will know how to do this and will be willing to answer ... apart this, i don't understand you, where should be E. on the same place as D? please clarify this in (new) question. – Zarko Jan 23 '18 at 11:40
  • The point E will be on the same line as the ray BA, having the same y-coordinate as point A and B, to the left of A. Angle BCE = 90. That means Angle ACE =15grader. That means you need to extend the the horisontal line and the line vil intersect with the angle constructed. – Eirik Jan 23 '18 at 12:04
3

Just for comparison, here is a version in Metapost wrapped up in luamplib, so you need to compile it with lualatex or workout how to adapt it for plain MP, or GMP + pdflatex.

enter image description here

\RequirePackage{luatex85}
\documentclass[border=5mm]{standalone}
\usepackage{luamplib}
\begin{document}
\mplibtextextlabel{enable}
\begin{mplibcode}
vardef mark_angle(expr a, b, c, s, tint) =
    save arc; path arc; 
    arc = fullcircle scaled 2s rotated angle (c-b) shifted b cutafter (b--a);
    fill b--arc--cycle withcolor 7/8[tint,white];
    draw arc;
    label("$" & decimal floor(0.5 + (angle (a-b) - angle (c-b)) mod 360) & "^\circ$", 
    b shifted ((s+9) * unitvector(point arctime 1/2 arclength arc of arc of arc - b)));
enddef;

beginfig(1);
    pair A, B, C, D;
    A = origin;
    B = 300 right; % rotated 15; % <- try this just to test generality
    C-A = whatever * (A-B) rotated 60;
    C-B = whatever * (A-B) rotated -45;
    C-D = whatever * (A-B) rotated 90;
    D = whatever[A,B];

    mark_angle(A,B,C,16,blue);
    mark_angle(B,C,A,16,red);
    mark_angle(C,A,B,16,blue);

    draw A--B--C--cycle;
    draw C--D dashed evenly withcolor 1/2 white;

    label.rt(decimal (abs(C-D)/abs(A-B)) , 1/2[C,D]);

    dotlabel.llft("A", A);
    dotlabel.lrt ("B", B);
    dotlabel.top ("C", C);
    dotlabel.bot ("D", D);
endfig;
\end{mplibcode}
\end{document}
1

You mean like this?

enter image description here

The code:

\documentclass[margin=10pt]{standalone}
\usepackage{amsmath,tkz-euclide}
\usepackage{tikz}
\usetkzobj{all}

\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings,shapes}

\tikzset{
    myangle/.style={fill=green!20!white, draw=green!50!black,size=.3,opacity=.3},
    intnode/.style={circle,fill=black,inner sep=1pt,outer sep=0pt}
}

\begin{document}
\begin{tikzpicture}

% Drawing the triangle and the coordinates
\draw coordinate[label=left:A] (a) --++(60:6) coordinate[label=above:C] (c);

\path[name path=ac] (a)--++(0:8.5);
\path[name path=bc] (c)--++(-45:8);
\path[name intersections={of = ac and bc, by=b}];
\node[anchor=west] at (b) {B};

\draw[use as bounding box] (a)--(c)--(b)--cycle;

\draw[dashed] (c) |- (b);%%%% DASHED LINE

% Drawing the coordinates S and T
%\coordinate (s) at ($(a)!0.75!(c)$);

%\path[name path=incls] (s) --++ (-10:5);
\path[name path=altbc] (c) -- (b);
%\path[name intersections={of = incls and altbc, by=t}]; 

%\draw[dashed] (s) -- (t) node[intnode,label={right:{\color{black}\scriptsize $T$}}] (t) {};

% Angles
\tkzFindAngle(a,c,b)
\tkzGetAngle{angleABC};
\FPround\angleABC\angleABC{0}
\tkzFindAngle(b,a,c)
\tkzGetAngle{angleCAB};
\FPround\angleCAB\angleCAB{0}
\tkzFindAngle(c,b,a)
\tkzGetAngle{angleBCA};
\FPround\angleBCA\angleBCA{0}
%\tkzFindAngle(a,s,t)
%\tkzGetAngle{angleAST};
%\FPround\angleAST\angleAST{0}

\tkzMarkAngle[myangle](a,c,b)
\tkzLabelAngle[pos=.4](a,c,b){\tiny $\angleABC^\circ$}

\tkzMarkAngle[myangle](b,a,c)
\tkzLabelAngle[pos=0.5](b,a,c){\tiny $\angleCAB^\circ$}

\tkzMarkAngle[myangle](c,b,a)
\tkzLabelAngle[pos=0.45](c,b,a){\tiny $\angleBCA^\circ$}

%\tkzMarkAngle[myangle](a,s,t)
%\tkzLabelAngle[pos=0.4](a,s,t){\tiny $\angleAST^\circ$}

%\node[intnode,label={left:\scriptsize $S$}] at (s) {};
\end{tikzpicture}
\end{document}

I just swapped all occurrences of B by C and C by B to make the segment AB horizontal.

To draw the vertical dashed line I used a pair of perpendicular lines that start on C, go down to the same y coordinate as B and then go right to B, like this: \draw[dashed] (c) |- (b);. Since the segment AB is continuous, the horizontal part of the dashed line disappears.

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.