Demonstration of TpX import capabilities

Alexander Tsyplakov January 31, 2006

Abstract TpX (http://tpx.sourceforge.net/) is a lightweight, easy-to-use graph- ical editor for Windows platform for creation of drawings and inclusion them into LATEX files in publication-ready form. It can also be used as a stand-alone editor for vector graphics. Under Windows most reasonable programs, which produce graphs, can either export them as EMF files, or copy to clipboard as EMF. TpX can im- port Enhanced Metafiles (EMF) though not 100% correctly. Old-style Win- dows Metafiles (WMF) are imported by converting them to EMF. TpX can also import simple SVG pictures. This document demonstrates TpX import capabilities. Examples are ex- ported from many well-known as well as less known Windows programs.

1 2

Contents

1 Forewarning 3

2 Some remarks 4

3 Windows metafile (EMF) import 5 3.1 Histogram from Mathematica ...... 5 3.2 Vector field from Mathematica ...... 6 3.3 3D plot from Mathematica ...... 7 3.4 3D plot from Matlab ...... 8 3.5 Contour plot in polar coordinates from Matlab ...... 9 3.6 Stem plot from Matlab ...... 10 3.7 Diagram from SmartDraw ...... 11 3.8 Flowchart from SmartDraw ...... 12 3.9 Chart from MS Excel #1 ...... 13 3.10 Chart from MS Excel #2 ...... 14 3.11 Table from MS Word ...... 15 3.12 Tulips, Microsoft clipart ...... 16 3.13 “No smoking”, SVG clipart from KOffice converted by Adobe Il- lustrator ...... 17 3.14 Tomato, EPS clipart from freeclipart.nu ...... 18 3.15 Brick wall bitmap image vectorized by AutoTrace ...... 19 3.16 3D plot from Gnuplot ...... 20 3.17 Multiple plot from Gnuplot ...... 21 3.18 Matrix plot from Statistica ...... 22 3.19 3D plot from SWP/MuPAD ...... 23 3.20 Function plot from OriginPro ...... 24 3.21 Bubble color plot from Axum ...... 25

4 (SVG) import 26 4.1 Polar plot from Gnuplot ...... 26 4.2 Scanned signature vectorized by AutoTrace ...... 27 4.3 Books, SVG clipart from openclipart.org created with Inkscape .. 28 4.4 “Symbols”, standard XFig example ...... 29 4.5 Diagram from OpenOffice ...... 31 4.6 XY plot from Grace ...... 32 4.7 MiKTeX logo imported as SVG via pstoedit ...... 33 3

1 Forewarning

The aim of this document is to show the potential of using TpX for importing Windows metafile and SVG graphics into LATEX documents and to reveal pos- sible complications related to using TpX for this purpose. The author has no intension to evaluate the programs which were used to create the pictures. Pos- sibly, some problems are due to misuse of those programs. Also, some problems might have been fixed in recent versions. 4

2 Some remarks

X TpX can add TEX formulas to graphs (see 3D plot from Gnuplot below). X It is possible to edit imported images and correct their deficiencies. For example, TpX can help to shift misplaced text labels. X Common problem with metafile images exported from Windows pro- grams is low resolution used to represent coordinates inside metafile. This causes bad quality of some metafile images. X Some programs use the same line width (e.g. 1 pixel) for all lines in metafile, though in other export formats (for example, PostScript) lines have different widths. X For some programs metafile is not the preferred export format and can be of lower quality than, for example, PostScript images. X Some features of the original metafile image are not preserved, like bitmaps, font styles. X It is possible to mimic the fonts of the original image to some extent, but it needs manual editing. In most cases fonts from LATEX are good enough anyway. X As SVG format is very rich TpX can understand only some basic subset of it. 5

3 Windows metafile (EMF) import

3.1 Histogram from Mathematica

20

15

10

5

14 16 18 20 22

Figure 1: Mathematica source

20

15

10

5

14 16 18 20 22

Figure 2: TpX output 6

3.2 Vector field from Mathematica

Figure 3: EPS file exported from Mathematica

Figure 4: TpX output 7

3.3 3D plot from Mathematica

0.5

0 1 -0.5 0.5 -1 -1 0 -0.5 0 -0.5 0.5 1

Figure 5: EPS file exported from Mathematica

0.5

0 1 - 0.5 0.5 - 1 - 1 0 - 0.5 0 - 0.5 0.5 1

Figure 6: TpX output

Comment: Mathematica exported EMF at low resolution. This could be seen from inaccurate tick marks. 8

3.4 3D plot from Matlab

1

0.8

0.6

0.4

0.2

0

−0.2

−0.4

−0.6

−0.8 4

2 4 2 0 0 −2 −2 −4 −4

Figure 7: EPS file exported from Matlab

1

0.8

0.6

0.4

0.2

0

-0.2

-0.4

-0.6

-0.8 4

2 4 2 0 0 -2 -2 -4 -4

Figure 8: TpX output

Comment: When exporting to EMF Matlab made all lines the same width. This was corrected manually to make dashed lines two times thinner. 9

3.5 Contour plot in polar coordinates from Matlab

90 1 120 60 0.8

0.6 150 30 0.4

0.2

180 0

210 330

240 300

270

Figure 9: EPS file exported from Matlab

90 1 120 60 0.8

0.6 150 30 0.4

0.2

180 0

210 330

240 300

270

Figure 10: TpX output 10

3.6 Stem plot from Matlab

0.2

0.15

0.1

0.05

0 Autocovariances −0.05

−0.1

−0.15

−0.2 0 2 4 6 8 10 12 14 16 18 20 Lag

Figure 11: EPS file exported from Matlab

0.2

0.15

0.1

0.05

0 Autocovariances -0.05

-0.1

-0.15

-0.2 0 2 4 6 8 10 12 14 16 18 20 Lag

Figure 12: TpX output 11

3.7 Diagram from SmartDraw

Figure 13: SmartDraw source

Figure 14: TpX output

Comment: SmartDraw (http://www.smartdraw.com/). Interiors of letters in trial copy logo were left white. 12

3.8 Flowchart from SmartDraw

Start / End Enter

Mike is No Wait 10 min. Decision Yes home

Speak to Mike is Yes Mike home Process

No No Say goodbye Too Connec- late tor Yes A B C D Direction 1 dog sad pick of 2 cat bad lock flow Go away 3 rat fat get 4 frog wet spot

Figure 15: SmartDraw source

Start / End Enter

Mike is No Wait 10 min. Decision Yes home

Speak to Mike is Yes Mike home Process

No No Say goodbye Too Connec- late tor Yes A B C D Direction 1 dog sad pick of 3 cat bad lock flow Go away 3 rat fat get 4 frog wet spot

Figure 16: TpX output

Comment: TEX bf and sf fonts were introduced by hand. 13

3.9 Chart from MS Excel #1

5

4 3 A 2 B 1 C

0 C 1 2 B 3 4 A 5 6

Figure 17: Excel source

5 4 3 A 2 B 1 C

0 C 1 2 B 3 4 A 5 6

Figure 18: TpX output

Comment: Hatching step in Excel source is very small, that is why the first figure seems pink. 14

3.10 Chart from MS Excel #2

any both cir

5

4

3

2

1

0 1 2 3 4 5 6

Figure 19: Excel source

any both cir

5

4

3

2

1

0 1 2 3 4 5 6

Figure 20: TpX output 15

3.11 Table from MS Word

Anyway

Nobody Try it or No buy it GBR 10 M 12/87 USA 9 F 11/87

Yes ESP 11 M 03/87 SWE 10 F 04/88

Figure 21: Word source

Anyway

Nobody Try it or No buy it GBR 10 M 12/87 USA 9 F 11/87 ESP 11 M 03/87 Yes SWE 10 F 04/88

Figure 22: TpX output

Comment: Word copies to clipboard in multiple formats including EMF. It is possible in principle (though could not be recommended) to cut and paste any Word text. 16

3.12 Tulips, Microsoft clipart

Figure 23: Clipart source

Figure 24: TpX output

Comment: Clipart was taken from MS site as EMF. It is quite easy to import MS clipart because it uses only polygons. 17

3.13 “No smoking”, SVG clipart from KOffice converted by Adobe Illustrator

Figure 25: PDF exported from Adobe Illustrator

Figure 26: TpX output

Comment: SVG was converted to PDF and EMF by Adobe Illustrator. 18

3.14 Tomato, EPS clipart from freeclipart.nu

Figure 27: Source EPS

Figure 28: TpX output

Comment: The source of image is http://www.freeclipart.nu site. EPS is not the original one, created with Adobe Illustrator. It was converted from EPS to EPS using epswrite device. Imported to TpX using pstoedit(http: //www.pstoedit.net/pstoedit). Free version of pstoedit somewhat distorted image by converting Bezier curves to polygons. 19

3.15 Brick wall bitmap image vectorized by AutoTrace

Figure 29: Source bitmap image

Figure 30: TpX output

Comment: AutoTrace is a free utility for converting bitmap into vector graph- ics (http://autotrace.sourceforge.net/). EMF is one of AutoTrace output formats. It mostly uses Bezier curves. 20

3.16 3D plot from Gnuplot

f(x,y) = sqrt(300-x**2-y**2)

f(x,y) 25-0.3*f(x, y)

18 17 22 16 15 20 14 13 12 18 11 10 16 14 12 10 5 10 -10 0 -5 0 -5 5 10-10

Figure 31: EPS produced by Gnuplot

√ f(x, y) = 300 − x2 − y2

f(x, y) 25 − 0.3 · f(x, y) 18 17 22 16 15 20 14 13 18 12 11 16 10 14 12 10 10 5 -10 0 -5 0 -5 5 −10 10

Figure 32: TpX output

Comment: Gnuplot is a free command-line driven function plotting utility (http://gnuplot.sourceforge.net/). Gnuplot has many ”terminals” for ex- porting graphics, including EMF and PostScript. This 3D plot was copied to Windows clipboard from Gnuplot window. (EMF terminal output lacked color surface). 21

3.17 Multiple plot from Gnuplot

ϕ = 0.1 ϕ = 0.9 4 10

2 5

Y series 0 Y series 0 -2

5 10 time 15 20 5 10 time 15 20

ϕ = 1 ϕ = 1.2 20 200

160

10 120 80 Y series Y series 0 40 0

5 10 time 15 20 5 10 time 15 20

Figure 33: EPS produced by Gnuplot

ϕ = 0.1 ϕ = 0.9 4 10

2 5

Y series 0 Y series

0

-2

time time 5 10 15 20 5 10 15 20

ϕ = 1 ϕ = 1.02 20 200

160

10 120

80 Y series Y series

0 40

0

time time 5 10 15 20 5 10 15 20

Figure 34: TpX output

Comment: Gnuplot treats different terminals somewhat differently 22

3.18 Matrix plot from Statistica

Matrix Plot

Body 8.8030

6.4528

4.1026

1.7523

-0.5979

-2.9481

-5.2983

-7.1808 -3.1808 0.8192 4.8192 8.8192 -1.9661 1.5727 5.1115 8.6503

8.6503 Brain

6.8809

5.1115

3.3421

1.5727

-0.1967

-1.9661

-5.2983 -0.5979 4.1026 8.8030 -3.8776 0.1224 4.1224 8.1224

Figure 35: Statistica source

Matrix Plot

Body 8.8030

6.4528

4.1026

1.7523

-0.5979

-2.9481

-5.2983

-7.1808 -3.1808 0.8192 4.8192 8.8192 -1.9661 1.5727 5.1115 8.6503

8.6503 Brain

6.8809

5.1115

3.3421

1.5727

-0.1967

-1.9661

-5.2983 -0.5979 4.1026 8.8030 -3.8776 0.1224 4.1224 8.1224

Figure 36: TpX output 23

3.19 3D plot from SWP/MuPAD

5 2.5 z 0 -2.5 -5 -5 -4 -2.5 -2 0 0 y 2 2.5 4 5 x

Figure 37: SWP/MuPAD source

5 2.5 z 0 -2.5 -5 -5 -4 -2.5 -2 0 0 y 2 2.5 x 4 5

Figure 38: TpX output

Comment: The graph was generated by MuPAD within Scientific WorkPlace (http://www.mackichan.com/). Axes labels were shifted manually in TpX . 24

3.20 Function plot from OriginPro

5 0

3 0

F 1 S m o o t h e d 1 _ F 1 e l 1 0 a c s

y t i l i

b 2 a b o r

P 0 . 5

0 . 0 1 0 . 0 1 0 . 1 1 1 0 L o g 1 0 s c a l e

Figure 39: PDF file exported from OriginPro

50

30

F1 Smoothed1˙F1 10

2

Probability scale 0.5

0.01 0.01 0.1 1 10 Log10 scale

Figure 40: TpX output

Comment: OriginPro (http://www.OriginLab.com/). OriginPro can export PDF and EPS. 25

3.21 Bubble color plot from Axum

V2: 5.9 to 7.6 10 7

5 Reference 5

0 V2 V2: 4.5 to 5.9 10 7

5 5

0 1.8 1.9 2.0 2.1 2.2 2.3 2.4 V3

Figure 41: EPS file exported from Axum

V2: 5.9 to 7.6 10 7

5 Reference 5

0 V2 V2: 4.5 to 5.9 10 7

5 5

0 1.8 1.9 2.0 2.1 2.2 2.3 2.4 V3

Figure 42: TpX output 26

4 Scalable vector graphics (SVG) import

4.1 Polar plot from Gnuplot

Figure 43: Source Gnuplot SVG as converted to EPS by Inkscape

Polar plot

2

1.5

1

0.5

Y 0

-2 -1.5 -1 -0.5 0 0.5 1 1.5 2 -0.5

-1

-1.5

-2 X

Figure 44: TpX output

Comment: Axes lines style was converted to dashed manually. 27

4.2 Scanned signature vectorized by AutoTrace

Figure 45: Scanned signature

Figure 46: TpX output

Comment: The picture was exported from AutoTrace as SVG and imported into TpX . 28

4.3 Books, SVG clipart from openclipart.org created with Inkscape

Figure 47: Screenshot from Adobe SVG viewer

Figure 48: TpX output

Comment: Public domain clipart by A. J. Ashton from http://openclipart. org/. SVG was imported with all colors lost (because TpX do not understand gradients). The colors were introduced manually to approximate original draw- ing. 29

4.4 “Symbols”, standard XFig example

CHARPIXEL

D Q

Q’

+

RT CT A0 Y0 A1 Y1 A2 Y2 A Q Y3 B Q’ Y4 E1 Y5 $\overline{E2}$Y6 − $\overline{E3}$Y7

+

Figure 49: EPS file produced by fig2dev 30

CHARPIXEL

D Q

Q’

+

RT CT A0 Y0 A1 Y1

A2 Y2 A Q Y3 B Q’ Y4

E1 Y5

E2 Y6

- E3 Y7

+

Figure 50: TpX output

Comment: An electrical and logic symbols figure from XFig (http://www. xfig.org) examples library. The figure was converted from FIG format to SVG using fig2dev (cygwin compilation). Many circles in SVG file have wrong radius (e.g. zero). Most probably, fig2dev had some bug. 31

4.5 Diagram from OpenOffice

Figure 51: EPS file exported from OpenOffice

Header 12 10 11 9 10 8 9 8 7 7 I 6 II 6 III 5 5 4 4 3 3 2 2 1 0 1 A B C D E

Figure 52: TpX output

Comment: The diagram was produced using OpenOffice.org Draw (http: //www.openoffice.org/). OpenOffice can export in many format including EPS and SVG. Stroke width was incorrect for SVG. 32

4.6 XY plot from Grace Sunspot data

1

0.8

0.6 sunspots 0.4

0.2

0 1700 1750 1800 1850 1900 1950 year

Tue Jan 24 02:57:19 2006

Figure 53: EPS file exported from Grace

Sunspot data

1

0.8

0.6 sunspots 0.4

0.2

0 1700 1750 1800 1850 1900 1950 year

Tue Jan 24 02:57:19 2006

Figure 54: TpX output

Comment: Grace (http://plasma-gate.weizmann.ac.il/Grace/) is a free plotting program which is available on Windows platform under Cygwin (http: //cygwin.com/). 33

4.7 MiKTeX logo imported as SVG via pstoedit

Figure 55: Original EPS file

Figure 56: TpX output

Comment: The logo was taken from MiKTeX (http://www.miktex.org/) documentation in EPS format. It was converted to SVG using pstoedit (http: //www.pstoedit.net/pstoedit) plot-svg format based on GNU libplot. The logo was rotated inside TpX .