Please help me to draw the following picture in LaTeX:
Thank you for all kind
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityPlease help me to draw the following picture in LaTeX:
Thank you for all kind
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.
\node[name intersections={of = seg1 and seg2},below right] at (intersection-1) {$tu+(1-t)v$};
Feb 3, 2015 at 10:25
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.