0

enter image description here

How can I draw the attached picture in LaTeX?

cfr
  • 198,882
  • 3
    Welcome ! see : http://meta.tex.stackexchange.com/questions/1436/welcome-to-tex-sx – flav Dec 01 '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 http://www.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 01 '16 at 21:20
  • Thank you so much for your answer. But, I need help for prepare this picture, emergency. Then, I will learn TikZ in the appropriate time. With the best regards. – mahdi dehghani Dec 01 '16 at 21:24
  • 1
    http://www.ursoswald.ch/LaTeXGraphics/picture/picture.html might give you some ideas where to start. – samcarter_is_at_topanswers.xyz Dec 01 '16 at 23:08
  • 2
    Since you already have this picture, why do you want to redraw it with LaTeX? – Paul Gaborit Dec 01 '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 01 '16 at 23:33
  • I am sorry for your decision. Why you less my points? – mahdi dehghani Dec 02 '16 at 08:57
  • Not everyone likes this type of question (the "here is an image, please provide code that reproduces it" type), so sometimes they get downvotes. Don't let it bother you though, just try to learn from the answer you just got, and other answers on the site, so that the next time you can do the simple parts of an image yourself, and then ask us for the more complicated parts when/if you get stuck. – Torbjørn T. Dec 02 '16 at 09:56
  • Welcome to TeX.SX. Questions about how to draw specific graphics that just post an image of the desired result are really not reasonable questions to ask on the site. Please post a minimal compilable document showing that you've tried to produce the image and then people will be happy to help you with any specific problems you may have. See minimal working example (MWE) for what needs to go into such a document. – Martin Schröder Dec 02 '16 at 14:59

2 Answers2

3

Just about does it...

\documentclass[tikz,border=5]{standalone}
\usetikzlibrary{intersections}
\begin{document}
\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);
\end{tikzpicture}
\end{document}

enter image description here

Mark Wibrow
  • 70,437
  • 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 03 '16 at 16:15
1

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.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{intersections}

\begin{document}
\begin{tikzpicture}[extended line/.style={shorten >=-#1,shorten <=-#1}, extended line/.default=1cm]
\pgfmathsetmacro\d{0}
\pgfmathsetmacro\e{2}
\pgfmathsetmacro\f{4}
\pgfmathsetmacro\m{0.4}
\pgfmathsetmacro\q{3}
\pgfmathsetmacro\a{-1}
\pgfmathsetmacro\b{2}
\pgfmathsetmacro\c{5}

\coordinate[label=above:$A$](A)at(\a,\m*\a+\q);
\coordinate[label=above:$B$](B)at(\b,\m*\b+\q);
\coordinate[label=above:$C$](C)at(\c,\m*\c+\q);
\coordinate[label=below:$D$](D)at(\d,0);
\coordinate[label=below:$E$](E)at(\e,0);
\coordinate[label=below:$F$](F)at(\f,0);

\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);
\end{tikzpicture}
\end{document}
josky
  • 391
  • 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: http://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 02 '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 02 '16 at 10:27