enter image description here

How can I draw the attached picture in LaTeX?

  • 3
    Welcome ! see : meta.tex.stackexchange.com/questions/1436/welcome-to-tex-sx – flav Dec 1 '16 at 21:17
  • 4
    Welcome to TeX.SE! Simple :): (i) search on site for similar images (ii) select package, which you estimate that you can use/learn (iii) if this is TikZ, than look texample.net, where is a lot of examples (iv) show, what you try so far ... otherwise, this is do-it-for-me question ... – Zarko Dec 1 '16 at 21:20
  • 1
    ursoswald.ch/LaTeXGraphics/picture/picture.html might give you some ideas where to start. – user36296 Dec 1 '16 at 23:08
  • 2
    Since you already have this picture, why do you want to redraw it with LaTeX? – Paul Gaborit Dec 1 '16 at 23:30
  • 5
    @mahdidehghani That is really not how this site works. You may get lucky if some procrastinator like me finds your image appealing or challenging. Or you may not. Not a good strategy for an "emergency". \includegraphics{} is a good emergency measure. For urgent, but not emergency use, samcarter's suggestion is probably a good one. – cfr Dec 1 '16 at 23:33

I agree with the comments of the users, certainly more skilled than me, but I answer the same because it might be useful to others, especially the use of intersections and macro definitions.

You have to set the macro \a, \b, \c, \d, \e, \f to the x value you want, then the macro \m \q respectively to the upper line slope and intercept.


\begin{tikzpicture}[extended line/.style={shorten >=-#1,shorten <=-#1}, extended line/.default=1cm]


\draw[blue, name path=A--E](A)--(E);
\draw[blue, name path=B--D](B)--(D);
\draw[blue, name path=A--F](A)--(F);
\draw[blue, name path=C--D](C)--(D);
\draw[blue, name path=B--F](B)--(F);
\draw[blue, name path=C--E](C)--(E);

\path [name intersections={of=A--E and B--D,by=P}];
\path [name intersections={of=A--F and C--D,by=Q}];
\path [name intersections={of=B--F and C--E,by=R}];
\node[blue, above]at(P){$P$};
\node[blue, above]at(Q){$Q$};
\node[blue, above]at(R){$R$};

\draw [extended line=0.5cm] (A)--(B)--(C);
\draw [extended line=0.5cm] (D)--(E)--(F);
\draw [extended line=0.5cm, red , dashed] (P)--(Q)--(R);

\draw[red, ->] (\d-1,0)--(\f+1,0);
\draw[red, ->] (0,-1)--(0,\c);

\fill (A)circle(2pt) (B)circle(2pt) (C)circle(2pt) (D)circle(2pt) (E)circle(2pt) (F)circle(2pt);
\fill[blue] (P)circle(2pt) (Q)circle(2pt) (R)circle(2pt);
  • 2
    (+1) You are perhaps aware of this, but note that one should be a little bit careful about \pgfmathsetmacro and one letter macros (and other macro names, for that matter), as several one-letter macros are already defined: tex.stackexchange.com/questions/19111/short-names-for-macros. \pgfmathsetmacro, unlike \newcommand, does not check for existing definitions, so it will silently overwrite whatever that was. In this case you might be fine, as the definitions will be local to the tikzpicture environment I think, but something to keep in mind. – Torbjørn T. Dec 2 '16 at 10:02
  • @TorbjørnT. Thank you for your specifications. Your link is useful to keep in mind which variables can be edit. In a particular and specific case like this, I prefer not consider this caution. – josky Dec 2 '16 at 10:27

Just about does it...

\begin{tikzpicture}[dot/.style={insert path={ circle [radius=.05] }},
  line cap=round, line join=round, >=stealth]
\draw (0,2) -- (4,4)
  coordinate [pos=0.125] (A) coordinate [pos=0.5] (B) coordinate [pos=0.875] (C);

\draw (0,0) coordinate (O) -- (4,0) coordinate (O')
  coordinate [pos=0.2] (D) coordinate [pos=0.5] (E) coordinate [pos=0.8] (F);

\foreach \x/\y/\z in {A/E/F, B/D/F, C/D/E}{
  \draw [name path global=\x\y, blue!75!black] (\x) -- (\y);
  \draw [name path global=\x\z, blue!75!black] (\x) -- (\z); 

\foreach \x/\y/\z in {AE/BD/P, AF/CD/Q, BF/CE/R}
  \path [name intersections={of/.expanded=\x\space and \y, name=i}] 
    (i-1) coordinate (\z);

\draw [thick, orange, dashed, shorten >=-1cm, shorten <=-1cm] (P) -- (R);

\foreach \n in {A, B, C} \fill (\n) [dot] node [above] {\n};
\foreach \n in {D, E, F} \fill (\n) [dot] node [below] {\n};
\foreach \n/\a in {P/340, Q/280, R/330}
  \fill (\n) [dot] node [blue!75!black, anchor=\a] {\n};

\draw [ultra thick, ->, shorten >=-.125cm, red] (O) -- (O');
\draw [ultra thick, ->, red] (D) -- ++(0,3);

enter image description here

  • I just want to point out that (even without the intersections library) you do not need to name paths in order to get intersections of lines: you can just use, e.g., (intersection of A--E and B--D). – Emma Dec 3 '16 at 16:15

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.