From 0c69424be099ace48d39c430995d04e28de42823 Mon Sep 17 00:00:00 2001 From: Robin Clark Date: Tue, 30 Nov 2010 16:53:26 +0000 Subject: [PATCH] Lunchtime edit --- fmmd_data_model/fmmd_data_model.tex | 16 +++ fmmd_data_model/paper.tex | 6 + latex_examples/atoms-and-orbitals.tex | 134 +++++++++++++++++++++++ latex_examples/bridges-of-konigsberg.tex | 64 +++++++++++ latex_examples/neural-network.tex | 59 ++++++++++ 5 files changed, 279 insertions(+) create mode 100644 latex_examples/atoms-and-orbitals.tex create mode 100644 latex_examples/bridges-of-konigsberg.tex create mode 100644 latex_examples/neural-network.tex diff --git a/fmmd_data_model/fmmd_data_model.tex b/fmmd_data_model/fmmd_data_model.tex index 89a78fe..ab4a46e 100644 --- a/fmmd_data_model/fmmd_data_model.tex +++ b/fmmd_data_model/fmmd_data_model.tex @@ -307,5 +307,21 @@ paper { chapter } + + +\begin{figure} +\begin{tikzpicture} +\tikzstyle{every node} = [node distance=1.5cm] +\Vertex[x=0,y=0]{A} +\Vertex[x=1,y=0]{B} +\Vertex[x=0,y=1]{C} +\tikzstyle{LabelStyle}=[fill=white,sloped] +\tikzstyle{EdgeStyle}=[bend left] +\Edge[label=hullo]{B}{C} + +\end{tikzpicture} +\caption{graph} +\end{figure} + \vspace{60pt} \today diff --git a/fmmd_data_model/paper.tex b/fmmd_data_model/paper.tex index b9e042a..75851cf 100644 --- a/fmmd_data_model/paper.tex +++ b/fmmd_data_model/paper.tex @@ -3,6 +3,12 @@ \usepackage{graphicx} \usepackage{fancyhdr} \usepackage{tikz} +\usepackage{tkz-graph} +\usepackage{tkz-berge} +\usetikzlibrary{arrows,% + petri,% + topaths}% + \usepackage{amsfonts,amsmath,amsthm} \input{../style} \usepackage{ifthen} diff --git a/latex_examples/atoms-and-orbitals.tex b/latex_examples/atoms-and-orbitals.tex new file mode 100644 index 0000000..0b6cfd4 --- /dev/null +++ b/latex_examples/atoms-and-orbitals.tex @@ -0,0 +1,134 @@ +% Example drawings to help explain the VSEPR atom model to high school +% students. Although the actual model is three dimensional, these drawings +% are deliberately presented as two dimensional to gently introduce them to the +% concepts, before advancing to three dimensional models. +% +% Authors: Berteun Damman & Arne Röhrs + +\documentclass{article} +\usepackage{verbatim} + +\begin{comment} +:Title: Atoms and orbitals + + +Example drawings to help explain the `VSEPR atom model`_ to high school +students. Although the actual model is three dimensional, these drawings +are deliberately presented as two dimensional to gently introduce them to the +concepts, before advancing to three dimensional models. + +.. _VSEPR atom model: http://en.wikipedia.org/wiki/VSEPR_theory + +\end{comment} +\usepackage{tikz} +\usepackage[version=3]{mhchem} + + + +\pgfdeclarelayer{background} +\pgfdeclarelayer{foreground} +\pgfsetlayers{background,main,foreground} + +% For black & white suggestions are black!95 for the electron +% and a white background, or a simple shade for the orbitals. +\colorlet{electron}{blue!75} +\tikzset{orbital/.style={thick,draw=blue,fill opacity=.60}} +% Styles for orbitals with 0, 1 and 2 atoms respectively. +\tikzset{orbital 0/.style={orbital,fill=blue!25}} +\tikzset{orbital 1/.style={orbital,fill=blue!66}} +\tikzset{orbital 2/.style={orbital,fill=blue}} +\tikzset{atomcore/.style={shape=circle,thick,draw=red!40,minimum size=7mm, + font=\large\color{red!70!gray},fill=red!20,inner sep=0pt}} + +\def\orbheight{1.2} +\def\orbwidth{.6} + +% Parameters: #1 Rotation of the orbital +% #2 Coordinate where the orbital should be attached +% #3 Number of electrons to draw in the orbital +\newcommand{\orbital}[3]{ + \begin{scope}[rotate=#1,shift=(#2)] + % These points define the curve for the orbital. + \coordinate (c1) at (-\orbwidth, .6 * \orbheight); + \coordinate (c2) at (-\orbwidth, \orbheight); + \coordinate (c3) at (\orbwidth, \orbheight); + \coordinate (c4) at (\orbwidth, .6 * \orbheight); + \coordinate (top) at (0,\orbheight); + + %Coordinates of the electrons + \coordinate (e1) at (0, 0.45*\orbheight); + \coordinate (e2) at (0, 0.75*\orbheight); + \end{scope} + + % These are drawn on a background layer, so orbitals + % can overlap without covering the electrons, which + % visualises the role electrons play in chemical bonds. + \begin{pgfonlayer}{background} + \draw[orbital #3] (#2) .. controls (c1) and (c2) .. (top) .. + controls (c3) and (c4) .. (#2); + \end{pgfonlayer} + + % Draw the electrons + \ifnum#3>0 + \foreach \n in {1,...,#3} { + \shade[ball color=electron] (e\n) circle (1mm); + } + \fi +} + +% This allows to quickly place an atom. +% Parameters: #1 (Optional) Name of the center node +% #2 Text for the center node +% #3 A list of rotation-angle/anchor/number of electrons +\newcommand{\Atom}[3][AtomNode]{ + \node[atomcore] (#1) {\ce{#2}}; + \foreach \ang/\anchor/\n in {#3} { + \orbital{\ang}{#1.\anchor}{\n} + } +} + +\begin{document} + \pagestyle{empty} + + +% Note: Cells of matrices cannot contain layered pictures, +% therefore we use some old-fashioned scopes. +\begin{tikzpicture} + \Atom{B}{90/west/2,0/north/1,270/east/0,180/south/1} + \begin{scope}[xshift=4cm] + \Atom{H}{0/north/1} + \end{scope} + \begin{scope}[yshift=-4cm] + \Atom{C}{90/west/1,0/north/1,270/east/1,180/south/1} + \begin{scope}[xshift=4cm] + \Atom{Cl}{90/west/2,0/north/2,270/east/2,180/south/1} + \end{scope} + \end{scope} +\end{tikzpicture} + +\medskip + +\begin{tikzpicture} + \Atom{Cl}{90/west/2,0/north/2,270/east/1,180/south/2} + \begin{scope}[xshift=2.2cm] + \Atom{H}{90/west/1} + \end{scope} +\end{tikzpicture} + +\medskip + +\begin{tikzpicture} + \Atom{O}{45/north west/2,315/north east/1,225/south east/1,135/south west/2} + \begin{scope}[xshift=3.0cm] + \Atom{O}{45/north west/1,315/north east/2,225/south east/2,135/south west/1} + \end{scope} + + \begin{scope}[xshift=7.0cm] + \Atom{O}{45/north west/2,315/north east/1,225/south east/1,135/south west/2} + \begin{scope}[xshift=1.6cm] + \Atom{O}{45/north west/1,315/north east/2,225/south east/2,135/south west/1} + \end{scope} + \end{scope} +\end{tikzpicture} + +\end{document} diff --git a/latex_examples/bridges-of-konigsberg.tex b/latex_examples/bridges-of-konigsberg.tex new file mode 100644 index 0000000..c0d59c1 --- /dev/null +++ b/latex_examples/bridges-of-konigsberg.tex @@ -0,0 +1,64 @@ +% The seven bridges of Königsberg +% Author : Alain Matthes +% Encoding : UTF8 +% Engine : PDFLaTeX +\documentclass[]{article} +\usepackage[utf8]{inputenc} +\usepackage{fullpage} +\usepackage{fourier} +\usepackage{tikz} +%%%< +\usepackage{verbatim} +\usepackage[active,tightpage]{preview} +\PreviewEnvironment{tikzpicture} +\setlength\PreviewBorder{5pt}% +%%%> + +\begin{comment} +:Title: The seven bridges of Königsberg +:Slug: bridges-of-konigsberg + +The Seven Bridges of Königsberg is a famous historical problem in mathematics. Its negative resolution by Leonhard Euler in 1735 laid the foundations of graph theory and presaged the idea of topology. +\end{comment} + +\usetikzlibrary{arrows,% + shapes,positioning} + +\thispagestyle{empty} +\begin{document} + + The Seven Bridges of Königsberg is a famous historical problem in mathematics. Its negative resolution by Leonhard Euler in 1735 laid the foundations of graph theory and presaged the idea of topology. + + Abstract graph corresponding to bridges of Königsberg + +\begin{center} +\begin{tikzpicture}[node distance = 2 cm] + \useasboundingbox (-1,-1) rectangle (50,50); + \tikzset{VertexStyle/.style = {shape = circle, + ball color = orange, + text = black, + inner sep = 2pt, + outer sep = 0pt, + minimum size = 24 pt}} + \tikzset{EdgeStyle/.style = {thick, + double = orange, + double distance = 1pt}} + \tikzset{LabelStyle/.style = {draw, + fill = yellow, + text = red}} + \node[VertexStyle](A){A}; + \node[VertexStyle,right=of A](B){B}; + \node[VertexStyle,right=of B](C){C}; + \node[VertexStyle,above= 8 cm of B](D){D}; + \draw[EdgeStyle](B) to node[LabelStyle]{1} (D) ; + \tikzset{EdgeStyle/.append style = {bend left}} + \draw[EdgeStyle](A) to node[LabelStyle]{2} (B); + \draw[EdgeStyle](B) to node[LabelStyle]{3} (A); + \draw[EdgeStyle](B) to node[LabelStyle]{4} (C); + \draw[EdgeStyle](C) to node[LabelStyle]{5} (B); + \draw[EdgeStyle](A) to node[LabelStyle]{6} (D); + \draw[EdgeStyle](D) to node[LabelStyle]{7} (C); + + \end{tikzpicture} +\end{center} +\end{document} diff --git a/latex_examples/neural-network.tex b/latex_examples/neural-network.tex new file mode 100644 index 0000000..0fd83c8 --- /dev/null +++ b/latex_examples/neural-network.tex @@ -0,0 +1,59 @@ +\documentclass{article} + +\usepackage{tikz} +\usepackage{verbatim} + +\begin{comment} +:Title: Neural network +:Tags: Foreach + +The ``\foreach`` command is very useful for quickly creating structured graphics +like this neural network diagram. + +\end{comment} + +\begin{document} +\pagestyle{empty} + +\def\layersep{2.5cm} + +\begin{tikzpicture}[shorten >=1pt,->,draw=black!50, node distance=\layersep] + \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{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 output layer node + \node[output neuron,pin={[pin edge={->}]right:Output}, right of=H-3] (O) {}; + + % 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 hidden layer with the output layer + \foreach \source in {1,...,5} + \path (H-\source) edge (O); + + % Annotate the layers + \node[annot,above of=H-1, node distance=1cm] (hl) {Hidden layer}; + \node[annot,left of=hl] {Input layer}; + \node[annot,right of=hl] {Output layer}; +\caption{bollocks} +\end{tikzpicture} +% End of code +\end{document} +