# A question on feasible region

I faced a difficulty to name the corner point of the feasible region determined by the below LaTeX/TikZ code, who can help me.

\begin{figure}[htpb]
\centering
\begin{tikzpicture}

\draw[gray!50, thin, step=0.5] (-2,-2) grid (14,14);
\draw[very thick,->] (-2,0) -- (14,0) node[right] {$x$};
\draw[very thick,->] (0,-2) -- (0,14) node[above] {$y$};

\foreach \x in {-2,...,14} \draw (\x,0.5) -- (\x,-0.5) node[below] {\tiny\x};
\foreach \y in {-2,...,14} \draw (-0.5,\y) -- (0.5,\y) node[right] {\tiny\y};

\fill[blue!50!cyan,opacity=0.3] (0,0)-- (0,5) -- (6,11) -- (8,10) --(13,0) --cycle;
\put(0,0){A}\put(0,5){B}\put(6,11){C}\put(8,10){D}\put(13,0){E}
\draw (-2,3) -- node[above,sloped] {\tiny$-x+y\leq5$} (9,14);
\draw (6,14) -- node[above,sloped] {\tiny$2x+y\leq26$} (14,-2);
\draw (0,14) -- node[above right,sloped] {\tiny$2x+4y\leq56$} (14,7);

\end{tikzpicture}
\caption{Feasible Region of the problem}
\label{fig:ch3:c2}
\end{figure}

-
Are you trying to mix xypic or PSTricks or picture mode with TikZ syntax? \put commands should not be there. –  percusse Feb 27 '13 at 16:16
I want to give name for each corner points. I tried to use for instance \put (0,0){A}\put (0,5){B} \put(6,11){C} \put(8,10){D} \put(13,0){E}, but it doesn't work. –  ftolessa Feb 27 '13 at 16:21
I think the command you need is \node at (0,0) {A};. –  JLDiaz Feb 27 '13 at 16:23
Or also \coordinate (A) at (0,0); –  Claudio Fiandrino Feb 27 '13 at 16:28
Welcome to TeX.sx! No need to add thanks, simply upvote any good replies you may receive. It is our preferred way to show appraciation, it makes posts more concise. –  Peter Jansson Feb 27 '13 at 16:30

As percusse said in his comment: \put has nothing to do in a TikZ picture.

You probably want to use \node (with text) or \coordinate (saves the coordinate under a name). I used a combination of both (and a loop to save TikZ macros and my mind).

First the actual points are saved under a name (A, B, …):

\coordinate (<name>) at (<x>, <y>);


and with the help of the label option a node is added so that a reader can identify the points by their name. Instead of the label option, I could have used a \node which adds the text.

\foreach \x/\y/\t/\p in {0/0/A/below left,
0/5/B/above left,
6/11/C/above,
8/10/D/below left,
13/0/E/above right}{% as two commands are used, those need to be
% enclosed in { } so that they both are looped.
\coordinate (\t) at (\x,\y);
\node[\p] at (\t) {\t};
}


In the \fill command I have used the stored coordinate names.

In the second example I have used the the intersections library to let TikZ find the right points. You can now change the lines and TikZ does the rest for you.

## Code

\documentclass[tikz]{standalone}
\usetikzlibrary{intersections}
\begin{document}
\begin{tikzpicture}
\draw[gray!50, thin, step=0.5] (-2,-2) grid (14,14);
\draw[very thick,->] (-2,0) -- (14,0) node[right] {$x$};
\draw[very thick,->] (0,-2) -- (0,14) node[above] {$y$};

\foreach \x in {-2,...,14} \draw (\x,0.5) -- (\x,-0.5) node[below] {\tiny\x};
\foreach \y in {-2,...,14} \draw (-0.5,\y) -- (0.5,\y) node[right] {\tiny\y};

\foreach \x/\y/\t/\p in {0/0/A/below left,
0/5/B/above left,
6/11/C/above,
8/10/D/below left,
13/0/E/above right}
\coordinate[label={\p:\t}] (\t) at (\x,\y);
\fill[blue!50!cyan,opacity=0.3] (A) -- (B) -- (C) -- (D) -- (E) -- cycle;

\draw (-2,3) -- node[above,sloped]       {\tiny$-x+y\leq5$}   (9,14);
\draw (6,14) -- node[above,sloped]       {\tiny$2x+y\leq26$} (14,-2);
\draw (0,14) -- node[above right,sloped] {\tiny$2x+4y\leq56$} (14,7);
\end{tikzpicture}

\begin{tikzpicture}
\draw[gray!50, thin, step=0.5] (-2,-2) grid (14,14);
\draw[very thick,->, name path=x axis] (-2,0) -- (14,0) node[right] {$x$};
\draw[very thick,->, name path=y axis] (0,-2) -- (0,14) node[above] {$y$};

\foreach \x in {-2,...,14} \draw (\x,0.5) -- (\x,-0.5) node[below] {\tiny\x};
\foreach \y in {-2,...,14} \draw (-0.5,\y) -- (0.5,\y) node[right] {\tiny\y};

\draw[name path=line 1] (-2,3) -- node[above,sloped]       {\tiny$-x+y\leq5$}   (9,14);
\draw[name path=line 2] (6,14) -- node[above,sloped]       {\tiny$2x+y\leq26$} (14,-2);
\draw[name path=line 3] (0,14) -- node[above right,sloped] {\tiny$2x+4y\leq56$} (14,7);

\tikzset{
name intersections={of=y axis and x axis, name=A},
name intersections={of=y axis and line 1, name=B},
name intersections={of=line 1 and line 3, name=C},
name intersections={of=line 3 and line 2, name=D},
name intersections={of=x axis and line 3, name=E},
}
\foreach \t/\p in {A/below left,
B/above left,
C/above,
D/below left,
E/above right}
\node[fill,circle,minimum size=6\pgflinewidth,inner sep=0pt,label={\p:\t}] at (\t) {};
\fill[blue!50!cyan,opacity=0.3] (A) -- (B) -- (C) -- (D) -- (E) -- cycle;
\end{tikzpicture}
\end{document}


-