Top Banner
Outline Introduction A Quick Tour of TikZ Computations and Programming inside TikZ Getting your Graphics into MBX Tips and Tricks Resources Graphics in MathBook XML Thomas W. Judson Stephen F. Austin State University April 27, 2016 Thomas W. Judson Stephen F. Austin State University Graphics in MathBook XML
26

Graphics in MathBook XML - ctlsfasufaculty.sfasu.edu/judsontw/talks/AIM-April-2016.pdf · Thomas W. Judson Stephen F. Austin State University ... are useful for drawing arcs, etc

Mar 06, 2018

Download

Documents

phamque
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Graphics in MathBook XML - ctlsfasufaculty.sfasu.edu/judsontw/talks/AIM-April-2016.pdf · Thomas W. Judson Stephen F. Austin State University ... are useful for drawing arcs, etc

OutlineIntroduction

A Quick Tour of TikZComputations and Programming inside TikZ

Getting your Graphics into MBXTips and Tricks

Resources

Graphics in MathBook XML

Thomas W. JudsonStephen F. Austin State University

April 27, 2016

Thomas W. Judson Stephen F. Austin State University Graphics in MathBook XML

Page 2: Graphics in MathBook XML - ctlsfasufaculty.sfasu.edu/judsontw/talks/AIM-April-2016.pdf · Thomas W. Judson Stephen F. Austin State University ... are useful for drawing arcs, etc

OutlineIntroduction

A Quick Tour of TikZComputations and Programming inside TikZ

Getting your Graphics into MBXTips and Tricks

Resources

Introduction

A Quick Tour of TikZ

Computations and Programming inside TikZ

Getting your Graphics into MBX

Tips and Tricks

Resources

Thomas W. Judson Stephen F. Austin State University Graphics in MathBook XML

Page 3: Graphics in MathBook XML - ctlsfasufaculty.sfasu.edu/judsontw/talks/AIM-April-2016.pdf · Thomas W. Judson Stephen F. Austin State University ... are useful for drawing arcs, etc

OutlineIntroduction

A Quick Tour of TikZComputations and Programming inside TikZ

Getting your Graphics into MBXTips and Tricks

Resources

The LATEX picture environment

I In the beginning graphics was created with the LATEX pictureenvironment or imported from a third party graphics packagesuch as Adobe Illustrator.

I With the LATEX picture environment, graphics are part of theLATEX source.

I Third party programs produced EPS files that could beinserted into a LATEX document.

Thomas W. Judson Stephen F. Austin State University Graphics in MathBook XML

Page 4: Graphics in MathBook XML - ctlsfasufaculty.sfasu.edu/judsontw/talks/AIM-April-2016.pdf · Thomas W. Judson Stephen F. Austin State University ... are useful for drawing arcs, etc

OutlineIntroduction

A Quick Tour of TikZComputations and Programming inside TikZ

Getting your Graphics into MBXTips and Tricks

Resources

Picture Environment Example

-reflection

horizontalaxis

-reflection

verticalaxis

-180◦

rotation

-identity

A

A

A

A

D

D

D

D

B

B

B

B

C

C

C

C

D

B

C

A

A

C

B

D

C

A

D

B

B

D

A

C

Thomas W. Judson Stephen F. Austin State University Graphics in MathBook XML

Page 5: Graphics in MathBook XML - ctlsfasufaculty.sfasu.edu/judsontw/talks/AIM-April-2016.pdf · Thomas W. Judson Stephen F. Austin State University ... are useful for drawing arcs, etc

OutlineIntroduction

A Quick Tour of TikZComputations and Programming inside TikZ

Getting your Graphics into MBXTips and Tricks

Resources

The Code for the Picture Environment

\begin{picture }(20 ,20)

\thicklines

\multiput (1 ,1)(0 ,5){4}{\ framebox (5,3){ }}

\thinlines

\put(7, 2.5){\ vector (1 ,0){6}}

\put (8.1 ,3){\ scriptsize \it reflection}

\put (7.9 ,1.5){\ scriptsize \it horizontal}

\put (9 ,.5){\ scriptsize \it axis}

\put(7, 7.5){\ vector (1 ,0){6}}

\put (8 ,8){\ scriptsize \it reflection}

\put (8.25 ,6.5){\ scriptsize \it vertical}

...

\end{picture}

Thomas W. Judson Stephen F. Austin State University Graphics in MathBook XML

Page 6: Graphics in MathBook XML - ctlsfasufaculty.sfasu.edu/judsontw/talks/AIM-April-2016.pdf · Thomas W. Judson Stephen F. Austin State University ... are useful for drawing arcs, etc

OutlineIntroduction

A Quick Tour of TikZComputations and Programming inside TikZ

Getting your Graphics into MBXTips and Tricks

Resources

Graphics Today

I Graphics formats include PDF, JPG, SVG, PNG, GIF, PS,EPS to name a few.

I TikZ and Asymptote can create graphics inside LATEX

I Sage to insert graphics in LATEX or MBX.

I Third party software packages such as Sage, xfig, Inkscape,Adobe Illustrator can be used to create a graphics file, whichcan be inserted into LATEX or MBX.

Thomas W. Judson Stephen F. Austin State University Graphics in MathBook XML

Page 7: Graphics in MathBook XML - ctlsfasufaculty.sfasu.edu/judsontw/talks/AIM-April-2016.pdf · Thomas W. Judson Stephen F. Austin State University ... are useful for drawing arcs, etc

OutlineIntroduction

A Quick Tour of TikZComputations and Programming inside TikZ

Getting your Graphics into MBXTips and Tricks

Resources

TikZ

PGF/TikZ (orginally developed by Till Tantau) is a tandem of languages for producingvector graphics. PGF is a lower-level language, while TikZ is a set of higher-levelmacros that use PGF.

I The code \tikz \draw (0pt,0pt) -- (20pt,6pt); yields

and \tikz \fill[orange] (0,0) circle (1ex); provides inline graphics.

I The code yields and provides inline graphics.

I Use \begin{tikzpicture}...\end{tikzpicture} for larger pictures.

I Many software packages (Inkscape, GeoGebra, MATLAB, R) will exportgraphics to TikZ.

Thomas W. Judson Stephen F. Austin State University Graphics in MathBook XML

Page 8: Graphics in MathBook XML - ctlsfasufaculty.sfasu.edu/judsontw/talks/AIM-April-2016.pdf · Thomas W. Judson Stephen F. Austin State University ... are useful for drawing arcs, etc

OutlineIntroduction

A Quick Tour of TikZComputations and Programming inside TikZ

Getting your Graphics into MBXTips and Tricks

Resources

A Double Spring-Mass System

x1 = 0 x2 = 0

m1 m1

wall wall

x1 x2

Thomas W. Judson Stephen F. Austin State University Graphics in MathBook XML

Page 9: Graphics in MathBook XML - ctlsfasufaculty.sfasu.edu/judsontw/talks/AIM-April-2016.pdf · Thomas W. Judson Stephen F. Austin State University ... are useful for drawing arcs, etc

OutlineIntroduction

A Quick Tour of TikZComputations and Programming inside TikZ

Getting your Graphics into MBXTips and Tricks

Resources

The Code

\begin{tikzpicture }[ scale =0.5]

\draw[very thick] (-2,0) -- (18 ,0);

\draw[dashed] (5,-1) node[below] {$x_1 = 0$} -- (5,4);

\draw[dashed] (11,-1) node[below] {$x_2 = 0$} -- (11 ,4);

\filldraw[fill=blue!20,draw=blue !50! black , thick] (4,0) -- (6,0) -- (6,2) -- (4,2) -- cycle;

\draw[ultra thick] (0,1) -- (1,1) (3,1) -- (4,1);

\draw[snake=coil ,segment length =5pt ,segment amplitude =5pt ,ultra thick] (1,1) -- (3 ,1);

\filldraw[fill=blue!20,draw=blue !50! black , thick] (10 ,0) -- (12,0) -- (12,2) -- (10 ,2) -- cycle;

\draw[ultra thick] (6,1) -- (7,1) (9,1) -- (10 ,1);

\draw[snake=coil ,segment length =5pt ,segment amplitude =5pt ,ultra thick] (7,1) -- (9 ,1);

...

\end{tikzpicture}

Thomas W. Judson Stephen F. Austin State University Graphics in MathBook XML

Page 10: Graphics in MathBook XML - ctlsfasufaculty.sfasu.edu/judsontw/talks/AIM-April-2016.pdf · Thomas W. Judson Stephen F. Austin State University ... are useful for drawing arcs, etc

OutlineIntroduction

A Quick Tour of TikZComputations and Programming inside TikZ

Getting your Graphics into MBXTips and Tricks

Resources

The TikZ Coordinate System

I A TikZ picture is laid out on a grid.

I The coordinate system starts at the lower left hand corner ofthe canvas.

I The canvas is made large enough to hold the picture.

I The unit length is 1cm (other units possible).

I The basic element are paths and nodes.

Thomas W. Judson Stephen F. Austin State University Graphics in MathBook XML

Page 11: Graphics in MathBook XML - ctlsfasufaculty.sfasu.edu/judsontw/talks/AIM-April-2016.pdf · Thomas W. Judson Stephen F. Austin State University ... are useful for drawing arcs, etc

OutlineIntroduction

A Quick Tour of TikZComputations and Programming inside TikZ

Getting your Graphics into MBXTips and Tricks

Resources

Paths

A path is a series of straight and curved line segments connecting coordinatepoints.

\draw (1,1) -- (2,2) -- (3,1);

\draw[very thick] (1,1) -- (2,2) -- (3,1) -- cycle;

\filldraw[green] (1,1) -- (2,2) -- (3,1) -- cycle;

Thomas W. Judson Stephen F. Austin State University Graphics in MathBook XML

Page 12: Graphics in MathBook XML - ctlsfasufaculty.sfasu.edu/judsontw/talks/AIM-April-2016.pdf · Thomas W. Judson Stephen F. Austin State University ... are useful for drawing arcs, etc

OutlineIntroduction

A Quick Tour of TikZComputations and Programming inside TikZ

Getting your Graphics into MBXTips and Tricks

Resources

Simple Shapes

It is possible to draw simple shapes such as rectangles, circles, and ellipses.

I \draw (0, 0) rectangle (2, 1);

I \draw[color=red] (0, 0) circle (.5);

I \draw (0, 0) ellipse (.7 and 0.5);

Thomas W. Judson Stephen F. Austin State University Graphics in MathBook XML

Page 13: Graphics in MathBook XML - ctlsfasufaculty.sfasu.edu/judsontw/talks/AIM-April-2016.pdf · Thomas W. Judson Stephen F. Austin State University ... are useful for drawing arcs, etc

OutlineIntroduction

A Quick Tour of TikZComputations and Programming inside TikZ

Getting your Graphics into MBXTips and Tricks

Resources

Polar Coordinates and Curved Lines

I Polar coordinates are useful for drawing arcs, etc.

\draw[color=green] (40:1) arc (40:160:1);

I Curved lines can be drawn with Bezier curves

\draw (0, 0) .. controls(0.25, 0.5) and (0.75, -0.5) .. (1,0);

Thomas W. Judson Stephen F. Austin State University Graphics in MathBook XML

Page 14: Graphics in MathBook XML - ctlsfasufaculty.sfasu.edu/judsontw/talks/AIM-April-2016.pdf · Thomas W. Judson Stephen F. Austin State University ... are useful for drawing arcs, etc

OutlineIntroduction

A Quick Tour of TikZComputations and Programming inside TikZ

Getting your Graphics into MBXTips and Tricks

Resources

Arrows and Lines

We can draw arrows and lines in various styles and thicknesses.

I \draw[->] (0, 0) -- (2,0);

I \draw[dashed,thin,|<<->|] (0, 0) -- (2,0);

I \draw[dotted,thick,o->|] (0, 0) -- (2,0);

I draw[densely dotted,very thick] (0, 0) -- (2,0);

I \draw[loosely dashed,ultra thick] (0, 0) -- (2,0);

Thomas W. Judson Stephen F. Austin State University Graphics in MathBook XML

Page 15: Graphics in MathBook XML - ctlsfasufaculty.sfasu.edu/judsontw/talks/AIM-April-2016.pdf · Thomas W. Judson Stephen F. Austin State University ... are useful for drawing arcs, etc

OutlineIntroduction

A Quick Tour of TikZComputations and Programming inside TikZ

Getting your Graphics into MBXTips and Tricks

Resources

Clipping and Scope

I After a \clip command, allsubsequent drawings are clipped,only the parts inside the clippingregion are drawn.

I Use the \scope environment torestrict the effect of clipping:

\begin{tikzpicture }[ scale =0.5]

\draw (-2, 1.5) rectangle (2, -1.5);

\begin{scope}

\clip (-0.5, 0) circle (1);

\clip ( 0.5, 0) circle (1);

\fill[color=gray] (-2,1.5)

rectangle (2, -1.5);

\end{scope}

\draw (-0.5, 0) circle (1);

\draw ( 0.5, 0) circle (1);

\end{tikzpicture}

Thomas W. Judson Stephen F. Austin State University Graphics in MathBook XML

Page 16: Graphics in MathBook XML - ctlsfasufaculty.sfasu.edu/judsontw/talks/AIM-April-2016.pdf · Thomas W. Judson Stephen F. Austin State University ... are useful for drawing arcs, etc

OutlineIntroduction

A Quick Tour of TikZComputations and Programming inside TikZ

Getting your Graphics into MBXTips and Tricks

Resources

Nodes

I Nodes are added to paths after the path is drawn.

A x2

\draw[->] (0, 0) node {A} -- (2,0) node {$x^2$};

I Nodes have options

Ax2

\draw[->] (0, 0) node[above] {A} -- (2,0) node[right] {$x^2$};

I Nodes can named for later reference and placed at a point independent ofa path.

Thomas W. Judson Stephen F. Austin State University Graphics in MathBook XML

Page 17: Graphics in MathBook XML - ctlsfasufaculty.sfasu.edu/judsontw/talks/AIM-April-2016.pdf · Thomas W. Judson Stephen F. Austin State University ... are useful for drawing arcs, etc

OutlineIntroduction

A Quick Tour of TikZComputations and Programming inside TikZ

Getting your Graphics into MBXTips and Tricks

Resources

Naming and Navigating Nodes

\begin{tikzpicture }[ scale=2,

transform shape]

\tikzstyle{every node}

= [circle ,fill=blue !30]

\node (a) at (0, 0) {A};

\node (b) at +(0: 1.5) {B};

\node (c) at +(60: 1.5) {C};

B \foreach \from/\to

in {a/b, b/c, c/a}

\draw [->] (\from) -- (\to);

\end{tikzpicture}A B

C

Thomas W. Judson Stephen F. Austin State University Graphics in MathBook XML

Page 18: Graphics in MathBook XML - ctlsfasufaculty.sfasu.edu/judsontw/talks/AIM-April-2016.pdf · Thomas W. Judson Stephen F. Austin State University ... are useful for drawing arcs, etc

OutlineIntroduction

A Quick Tour of TikZComputations and Programming inside TikZ

Getting your Graphics into MBXTips and Tricks

Resources

Computations in TikZ

\begin{tikzpicture}

\tikzstyle{every node }=[draw ,shape=circle ];

\node (v0) at (0:0) {$v_0$};

\node (v1) at ( 0:1) {$v_1$};

\node (v2) at ( 72:1) {$v_2$};

\node (v3) at (2*72:1) {$v_3$};

\node (v4) at (3*72:1) {$v_4$};

\node (v5) at (4*72:1) {$v_5$};

\draw (v0) -- (v1)

(v0) -- (v2)

(v0) -- (v3)

(v0) -- (v4)

(v0) -- (v5);

\end{tikzpicture}

v0 v1

v2v3

v4v5

Thomas W. Judson Stephen F. Austin State University Graphics in MathBook XML

Page 19: Graphics in MathBook XML - ctlsfasufaculty.sfasu.edu/judsontw/talks/AIM-April-2016.pdf · Thomas W. Judson Stephen F. Austin State University ... are useful for drawing arcs, etc

OutlineIntroduction

A Quick Tour of TikZComputations and Programming inside TikZ

Getting your Graphics into MBXTips and Tricks

Resources

Loops in TikZ

\begin{tikzpicture}

\draw[->] (-5.5,0) -- (5.5 ,0) node [below] {$\ mathbb{R}$};

\foreach \x in {-5,...,5}

\draw (\x, 0.1) -- (\x, -0.1) node [below] {\x};

\end{tikzpicture}

R-5 -4 -3 -2 -1 0 1 2 3 4 5

Thomas W. Judson Stephen F. Austin State University Graphics in MathBook XML

Page 20: Graphics in MathBook XML - ctlsfasufaculty.sfasu.edu/judsontw/talks/AIM-April-2016.pdf · Thomas W. Judson Stephen F. Austin State University ... are useful for drawing arcs, etc

OutlineIntroduction

A Quick Tour of TikZComputations and Programming inside TikZ

Getting your Graphics into MBXTips and Tricks

Resources

TikZ into MBX

The MBX source

<figure xml:id="figure -firstlook03-rc -circuit">

<image xml:id=" firstlook03-rc -circuit">

<latex -image -code ><![CDATA[

\begin{tikzpicture }[ scale =0.4]

...

\end{tikzpicture }]]>

</latex -image -code >

</image >

<caption >An RC circuit </caption >

</figure >

Thomas W. Judson Stephen F. Austin State University Graphics in MathBook XML

Page 21: Graphics in MathBook XML - ctlsfasufaculty.sfasu.edu/judsontw/talks/AIM-April-2016.pdf · Thomas W. Judson Stephen F. Austin State University ... are useful for drawing arcs, etc

OutlineIntroduction

A Quick Tour of TikZComputations and Programming inside TikZ

Getting your Graphics into MBXTips and Tricks

Resources

will produce the following graphic in the appropriate form (PDF for LATEX and SVG forHTML).

E(t)

+

R

CI (t)

Thomas W. Judson Stephen F. Austin State University Graphics in MathBook XML

Page 22: Graphics in MathBook XML - ctlsfasufaculty.sfasu.edu/judsontw/talks/AIM-April-2016.pdf · Thomas W. Judson Stephen F. Austin State University ... are useful for drawing arcs, etc

OutlineIntroduction

A Quick Tour of TikZComputations and Programming inside TikZ

Getting your Graphics into MBXTips and Tricks

Resources

Sage Plots into MBX

The MBX source

<figure xml:id="figure -systems02-nullclines -competing -species -1">

<image xml:id=" systems02-nullclines -competing -species -1">

<sageplot >

a = 2

xmin = 0

...

vector_field = plot_vector_field( (f/n,g/n), (x,xmin ,xmax), (y,ymin ,ymax) )

xnullcline = implicit_plot(f, (x,xmin ,xmax), (y,ymin ,ymax), color=’green ’, legend_label=’$x$-nullcline ’)

...

result = vector_field + solution + starting_point + Q_arrow + xnullcline + ynullcline

result

</sageplot >

</image >

<caption >Nullclines for the case <m>\beta = 2</m></caption >

</figure >

Thomas W. Judson Stephen F. Austin State University Graphics in MathBook XML

Page 23: Graphics in MathBook XML - ctlsfasufaculty.sfasu.edu/judsontw/talks/AIM-April-2016.pdf · Thomas W. Judson Stephen F. Austin State University ... are useful for drawing arcs, etc

OutlineIntroduction

A Quick Tour of TikZComputations and Programming inside TikZ

Getting your Graphics into MBXTips and Tricks

Resources

will produce the following graphic in the appropriate form (PDF for LATEX and SVG forHTML).

0 0.20.40.60.8 1 1.21.4

x(t)

00.20.40.60.8

11.21.4

y(t)

Thomas W. Judson Stephen F. Austin State University Graphics in MathBook XML

Page 24: Graphics in MathBook XML - ctlsfasufaculty.sfasu.edu/judsontw/talks/AIM-April-2016.pdf · Thomas W. Judson Stephen F. Austin State University ... are useful for drawing arcs, etc

OutlineIntroduction

A Quick Tour of TikZComputations and Programming inside TikZ

Getting your Graphics into MBXTips and Tricks

Resources

Tips, Tricks, and Cautions

I Come up with an intelligent labelling scheme.

I To prevent conflicts with MBX reserved characters, use

<![CDATA[\ begin{tikzpicture}

...

\end{tikzpicture }]]>

I Dont change units without a reason, use the scale and transform

shape options of tikzpicture

I Be careful with XeLaTeX. It does not always work well with TikZ.

I Try out your plots in SageMathCloud first.

Thomas W. Judson Stephen F. Austin State University Graphics in MathBook XML

Page 25: Graphics in MathBook XML - ctlsfasufaculty.sfasu.edu/judsontw/talks/AIM-April-2016.pdf · Thomas W. Judson Stephen F. Austin State University ... are useful for drawing arcs, etc

OutlineIntroduction

A Quick Tour of TikZComputations and Programming inside TikZ

Getting your Graphics into MBXTips and Tricks

Resources

Resources

I Lots of examples at http://www.texample.net/tikz/

I Many of these examples came fromhttp://altermundus.fr/pages/downloads/remember beamer.pdf,http://www.statistiker-wg.de/pgf/tutorials.htm,http://www.tug.org/pracjourn/2007-1/mertz/,http://tex.stackexchange.com,andhttp://www.math.uni-leipzig.de/~hellmund/LaTeX/pgf-tut.pdf

I Till Tantau’s PGF/TikZ manualhttp://mirror.unl.edu/ctan/graphics/pgf/base/doc/pgfmanual.pdf

Thomas W. Judson Stephen F. Austin State University Graphics in MathBook XML

Page 26: Graphics in MathBook XML - ctlsfasufaculty.sfasu.edu/judsontw/talks/AIM-April-2016.pdf · Thomas W. Judson Stephen F. Austin State University ... are useful for drawing arcs, etc

OutlineIntroduction

A Quick Tour of TikZComputations and Programming inside TikZ

Getting your Graphics into MBXTips and Tricks

Resources

Thanks for Listening

Thomas W. Judson, Associate ProfessorDepartment of Mathematics and StatisticsStephen F. Austin State University

EMAIL: [email protected]

Slides available at http://faculty.sfasu.edu/judsontw/

Thomas W. Judson Stephen F. Austin State University Graphics in MathBook XML