TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need draw some picture, but I don't know how do that.

First, the simple graph with basic shapes, arrow,.... enter image description here

And then, draw a picture with math symbol or equation in math environment. Like that: enter image description here

Please help me draw two picture. And if you don't mind, please show me some tools which can help me draw easily and generate to latex code, or some document help me learnt quickly. Thanks for your help

share|improve this question
You can use TikZ to do this. Check out some of the examples in the manual: mirror.math.ku.edu/tex-archive/graphics/pgf/base/doc/generic/… – dustin Sep 9 '13 at 17:30
You can take a look at this question which discusses a number of tools to choose from. Which you choose and want to stick at depends on a number of factors including your need, available time and learning curve option. – Masroor Sep 9 '13 at 17:35
There are also some programs which can export graphics as tex-code. If your example pictures are vector graphics, you can for example use inkscape and "save as..." them as LaTeX-code with PSTricks. If you rather like TikZ (see previous comment) there also exist Add-ons for Inkscape to export as TikZ-code – samcarter Sep 9 '13 at 17:39
There are plenty of related questions on the site: Fully connected network diagram and Neural Network representation are quite similar (if not duplicates) and have very good answers. – Alan Munn Sep 9 '13 at 18:01
@dustin's link is now broken. Try this: texample.net/media/pgf/builds/pgfmanualCVS2012-11-04.pdf – daviewales Jun 18 '14 at 2:05
up vote 28 down vote accepted

One possibility; the first diagram was drawn using a matrix; the second one, using chains:



  matrix of nodes,
    inner sep=10pt
  nodes in empty cells,
  column sep=2cm,
  row sep=-9pt
\matrix[net] (mat)
|[plain]| \parbox{1.3cm}{\centering Input\\layer} & |[plain]| \parbox{1.3cm}{\centering Hidden\\layer} & |[plain]| \parbox{1.3cm}{\centering Output\\layer} \\
& |[plain]| \\
|[plain]| & \\
& |[plain]| \\
|[plain]| & |[plain]| \\
& & \\
|[plain]| & |[plain]| \\
& |[plain]| \\
|[plain]| & \\
& |[plain]| \\
\foreach \ai [count=\mi ]in {2,4,...,10}
  \draw[<-] (mat-\ai-1) -- node[above] {Input \mi} +(-2cm,0);
\foreach \ai in {2,4,...,10}
{\foreach \aii in {3,6,9}
  \draw[->] (mat-\ai-1) -- (mat-\aii-2);
\foreach \ai in {3,6,9}
  \draw[->] (mat-\ai-2) -- (mat-6-3);
\draw[->] (mat-6-3) -- node[above] {Ouput} +(2cm,0);

  inner sep=2pt,
  join = by -latex
  inner sep=2pt,
  join = by -latex
start chain=2,node distance=13mm
\node[on chain=2] 
  (x2) {$x_2$};
\node[on chain=2,join=by o-latex] 
\node[on chain=2,init] (sigma) 
\node[on chain=2,squa,label=above:{\parbox{2cm}{\centering Activate \\ function}}]   
\node[on chain=2,label=above:Output,join=by -latex] 
\begin{scope}[start chain=1]
\node[on chain=1] at (0,1.5cm) 
  (x1) {$x_1$};
\node[on chain=1,join=by o-latex] 
  (w1) {$w_1$};
\begin{scope}[start chain=3]
\node[on chain=3] at (0,-1.5cm) 
  (x3) {$x_3$};
\node[on chain=3,label=below:Weights,join=by o-latex] 
  (w3) {$w_3$};
\node[label=above:\parbox{2cm}{\centering Bias \\ $b$}] at (sigma|-w1) (b) {};

\draw[-latex] (w1) -- (sigma);
\draw[-latex] (w3) -- (sigma);
\draw[o-latex] (b) -- (sigma);

\draw[decorate,decoration={brace,mirror}] (x1.north west) -- node[left=10pt] {Inputs} (x3.south west);


enter image description here

share|improve this answer
Thanks. can you introduce me some document or software about tikz? – phuong Sep 10 '13 at 6:20
@phuong the pgf manual has numerous examples and some nice inroductory tutorials: mirrors.ctan.org/graphics/pgf/base/doc/generic/pgf/… There's also a shorter document: cremeronline.com/LaTeX/minimaltikz.pdf (I've never used this last one). – Gonzalo Medina Sep 10 '13 at 12:55
Thanks you for your document. It's very useful. I just need 1 requirement. on the second graph, I want to remove a vertical line of circle. I tried hard but not done. Would you please help me again? – phuong Sep 10 '13 at 17:01
@phuong Sure! The problem is I am not sure exactly which line you are referring to. Do you want to suppress the arrow going from "Bias b" to the "Sigma"? – Gonzalo Medina Sep 10 '13 at 17:49
No, not bias. I want to remove circles between x_1 & w_1; x_2 &w_2; x_3 and W_3. You can see again my graph on question to know exactly. – phuong Sep 11 '13 at 6:09

protected by Werner Jun 18 '14 at 1:36

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.