I would like to product just the graphic and not the surrounding page. Essentially, I would like a box of white around the graphic, but not an entire page's worth.
I found this answer, and I am able to compile the MWE from Peter Grill's answer. I understand that I should change the \documentclass to standalone; However, I cannot make the answer work for my example. It produces a blank pdf (not a white page, just nothing). This is a modified version of this example of an MLP, to have two hidden layers instead of just one:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\def\layersep{2.5cm}
\begin{tikzpicture}[shorten >=1pt,->,draw=black!50, node distance=\layersep,transform canvas={scale=1.5}]
\tikzstyle{every pin edge}=[<-,shorten <=1pt]
\tikzstyle{neuron}=[circle,fill=black!25,minimum size=17pt,inner sep=0pt]
\tikzstyle{input neuron}=[neuron, fill=green!50];
\tikzstyle{output neuron}=[neuron, fill=red!50];
\tikzstyle{hidden neuron}=[neuron, fill=blue!50];
\tikzstyle{hidden2 neuron}=[neuron, fill=blue!50];
\tikzstyle{annot} = [text width=4em, text centered]
% Draw the input layer nodes
\foreach \name / \y in {1,...,4}
% This is the same as writing \foreach \name / \y in {1/1,2/2,3/3,4/4}
\node[input neuron, pin=left:Input \#\y] (I-\name) at (0,-\y) {};
% Draw the hidden layer nodes
\foreach \name / \y in {1,...,5}
\path[yshift=0.5cm]
node[hidden neuron] (H-\name) at (\layersep,-\y cm) {};
% Draw the hidden layer nodes
\foreach \name / \y in {1,...,5}
\path[yshift=0.5cm]
node[hidden2 neuron] (H2-\name) at (\layersep*2,-\y cm) {};
% Draw the output layer nodes
\foreach \name / \y in {1,...,3}
\path[yshift=0.5cm]
node[output neuron,pin=right:Class \#\y] (O-\name) at (\layersep*3,-\y cm) {};
% Connect every node in the input layer with every node in the
% hidden layer.
\foreach \source in {1,...,4}
\foreach \dest in {1,...,5}
\path (I-\source) edge (H-\dest);
% Connect every node in the first hidden layer with every node in the
% second hidden layer.
\foreach \source in {1,...,5}
\foreach \dest in {1,...,5}
\path (H-\source) edge (H2-\dest);
% Connect every node in the hidden layer with the output layer
\foreach \source in {1,...,5}
\foreach \dest in {1,...,3}
\path (H2-\source) edge (O-\dest);
% Annotate the layers
\node[annot,above of=H-1, node distance=1cm] (hl) {Hidden layer 1};
\node[annot,above of=H2-1, node distance=1cm] (hl) {Hidden layer 2};
\node[annot,right of=hl] {Output layer};
\end{tikzpicture}
\end{document}
This produces a page with the picture on it. I want a page the size of the picture. How can I do that?
\pagestyle{empty}
compile, then in a terminal run the pdf throughpdfcrop file.pdf
– daleif Jan 23 '17 at 19:43