Draw a picture in LaTeX

Please help me to draw the following picture in LaTeX: Thank you for all kind

migrated from math.meta.stackexchange.comFeb 3 '15 at 9:14

This question came from our discussion, support, and feature requests site for people studying math at any level and professionals in related fields.

• What have you tried? You could try TiKZ, or pstricks, or asymptote, or metapost, or includegraphics using a drawing you produce in a drawing package. Or you could write in capital letters in your tex file INCLUDE PICTURE 1 HERE, and then draw the picture by hand, and ask your publisher to put in a suitable illustration there. – Benjamin McKay Feb 3 '15 at 10:05

This should get you started (or use Hugos answer, to which he beat me by some minutes).

I didn't want to look up the intersection code, since generally, "draw this for me" questions without any work at all are not the best questions to be asked here on tex.SE.

\documentclass{standalone}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\draw (0,0) node [anchor=south east] {$$w$$} -- (1,0) node [anchor=south] {$$u$$} -- (0,-2) node [anchor=north] {$$v$$} -- cycle;
\draw (0,0) -- (2,0) node [anchor=west] {$$u_{s}$$} -- (0,-1) node [anchor=east] {$$v_{s}$$} -- cycle;
\draw (0.6,-0.6) node [anchor=north west] {$$tu+(1-t)v$$};
\end{tikzpicture}

\end{document} You can achieve it by using the tikz package. Here is the code:

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

\begin{document}

\begin{tikzpicture}
\coordinate (W) at (-2,-6);
\coordinate (Vs) at (-1,-3);
\coordinate (V) at (0,0);
\coordinate (U) at (5,0);
\coordinate (Us) at (9,0);

\draw (W) node[left]{v} -- (Vs) node[left]{$v_s$} -- (V) node[above]{w} -- (U) node[above]{u} -- (Us) node[above]{$u_s$};

\draw[name path=seg1] (5,0) -- (-2,-6);
\draw[name path=seg2] (-1,-3) -- (9,0);

\path [name intersections={of = seg1 and seg2}];
\coordinate (I)  at (intersection-1);

\draw (I) node[below, right]{tu+(1-t)v};
\end{tikzpicture}
\end{document} You can change the coordinates of the points if you need to. Just change the first lines to the appropriate coordinates.

• You could merge the three last lines to \node[name intersections={of = seg1 and seg2},below right] at (intersection-1) {$tu+(1-t)v$}; – Torbjørn T. Feb 3 '15 at 10:25
• In addition, try to avoid using the minimal class. – Claudio Fiandrino Feb 3 '15 at 11:08

Two other candidates: MetaPost and Asymptote, both drawing programs closely related to (La)TeX. One may prefer such solutions since they are (contrary to TeX, LaTeX and cie) full-fledged programming languages, and thus sometimes easier to handle.

With MetaPost:

input latexmp; setupLaTeXMP(textextlabel = enable, mode = rerun);
numeric u; u = cm ; pair W, Vs, V, U, Us, I ;
V = u*(-2, -6); Vs = u*(-1, -3); W = origin; U = (5u, 0); Us = (9u, 0);
I = whatever[V, U] = whatever[Vs, Us]; % The intersection
beginfig(1);
draw U -- V -- W -- Us -- Vs;
label.top("$w$", W); label.top("$u$", U); label.rt("$u_s$", Us);
label.lft("$v_s$", Vs); label.lft("$v$", V);
label.lrt("$tu+(1-t)v$", I);
endfig;
end.

To be compiled with LaTeX as TeX engine. In the command line, it needs something like this: mpost --tex = latex mypic.mp, or mptopdf --tex=latex mypic.mp if you prefer direct PDF output.

Result: The same picture with Asymptote now:

settings.outformat="pdf";
unitsize(1cm);
pair v = (-2, -6), vs = (-1, -3), w = (0, 0), u = (5, 0), us = (9, 0);
pair I = intersectionpoint(v -- u, vs -- us); // The intersection
draw (u -- v -- w -- us -- vs);
label("$w$", w, N); label("$u$", u, N); label("$u_s$", us, E);
label("$v_s$", vs, W); label("$v$", v, W);
label("$tu+(1-t)v$", I, SE);

To be compiled (in a Terminal) with an instruction like this: asy mypic.asy

The result: Note that with both programs the intersection point is easily and automatically computed.