The gnuplottex package

Similar documents
Creating Plots with Gnuplot. May 18, 2017

Using context and tikz terminals for gnuplot in ConT E Xt

APPM 2460 PLOTTING IN MATLAB

Introduction to Scientific Typesetting Lesson 7: Graphics and Floats

Graphical Analysis with Gnuplot. Evangelos Pournaras, Izabela Moise

Basic statistical operations

L A TEX Document Formatting Examples

The basics of LaTeX. Cédric Buron. April 25, 2016

Package epsdice a scalable dice font

Compressed Images in PostScript and PDF with L A TEX HOWTO

The auto-pst-pdf package

M. R. C. van Dongen. ucc. LaTEX and Friends. Including External Pictures. Marc van Dongen.

Visualisation Lab: gnuplot

Trivial Experiments with pstricks manipulation

Creating Tables and Figures with L A T E X

Trivial Experiments with pstricks manipulation

Adding content to your Blackboard 9.1 class

1.7 Limit of a Function

Documentation for xcomment.sty

How to...create a Video VBOX Gauge in Inkscape. So you want to create your own gauge? How about a transparent background for those text elements?

FOR NUMERICAL POSTPROCESSING AND RESULT VISUALIZATION USING PGFPLOTS AND PGFPLOTSTABLE. Christian Feuersänger

The Honours Dissertation Class for L A TEX2e. Cara MacNish

Computational Approach to Materials Science and Engineering

ConTEXt. TPIC Conversion. category: ConTEXt Support Macros. version: date: March 19, author: Hans Hagen

MATH36032 Problem Solving by Computer. Publishable Quality Graphics

L A TEX in the Classroom

L A TEX Course at ICT School

Getting ready for L A TEX. Alexis Dimitriadis. Version: March 28, 2013

4.7 Approximate Integration

What is T E X? T E X and L A T E X Document preparation tools. Setting and casting type. What Knuth was setting. Setting and casting type

The asymptote package

Getting started with Latex

A Mini-Manual for GNUPLOT

mylatexformat Use mylatexformat to make a format based on the preamble of any LaTeX file 2011/02/12 version 3.4

Homework # You ll want to use some LaTeX editor to edit and compile your.tex files

Maximum and Minimum Slopes Wilfrid Laurier University

How to use abdnthesis.cls

Typesetting spectral sequences in L A TEX with luasseq.sty

The reflectgraphics package

Basic Graphs. Dmitry Adamskiy 16 November 2011

LaTeX. Information Literacy II EN(IL2) Course

The rtsched package for L A TEX (version 1.0)

Introduction to L A TEX

The FigSize Package. Anthony A. Tanbakuchi. v0.1 last revised 2002/3/18. Abstract

Gnuplot Tutorial. Gnuplot is a portable command-line driven graphing utility for - Linux, - MS Windows - Mac - Many other platforms.

Scientific Computing (G /G ) Homework 10 example

NAVIGATING UNIX. Other useful commands, with more extensive documentation, are

Intro to LATEX I. Aaron Erlich POLS/CSSS 510, Why LATEX? Programming Document Structure Floats Tables Lists Math

Lecture 5 of AMS 200 LaTeX Typesetting, Writing and

Will Robertson. Abstract

The abc package. Enrico Gregorio Enrico dot Gregorio at univr dot it 2008/03/03

L A TEX: Online module 6

EEPIC Extensions to epic and L A TEX Picture Environment Version 1.1

mnotes annotate documents with margin comments

1. Welcome. (1) Hello. My name is Dr. Christopher Raridan (Dr. R). (3) In this tutorial I will introduce you to the amsart documentclass.

L A TEX- Advanced Topics

Installing a Custom AutoCAD Toolbar (CUI interface)

Why Use Graphs? Test Grade. Time Sleeping (Hrs) Time Sleeping (Hrs) Test Grade

L A TEX3: from local to global A brief history and recent developments. Will Robertson and Frank Mittelbach

THE UNIVERSITY OF AKRON Mathematics and Computer Science. JJ Game Class. D. P. Story

A brief introduction to L A TEX

y= sin( x) y= cos( x)

Welcome Back! Without further delay, let s get started! First Things First. If you haven t done it already, download Turbo Lister from ebay.

CS354 gdb Tutorial Written by Chris Feilbach

THE UNIVERSITY OF AKRON Mathematics and Computer Science. JJ Game Class. D. P. Story

Math 395 Homework #1 Due Wednesday, April 12

The mcaption package

Google SketchUp Design Exercise 1

TUGboat, Volume 0 (2001), No. 0 preliminary draft, 19 Jun :06 1

Assignment 0. Nothing here to hand in

Including Graphics in L A TEX Files

NENS 230 Assignment 4: Data Visualization

Why learning L A TEX is worth the effort

Trigonometric Graphs. Inverness College. September 29, 2010

The mathstyle package. Morten Høgholm 2008/08/13 v0.86

The ifplatform package

Excel Basics Rice Digital Media Commons Guide Written for Microsoft Excel 2010 Windows Edition by Eric Miller

Square cells: an array cooking lesson

Exercise sheet 1 To be corrected in tutorials in the week from 23/10/2017 to 27/10/2017

Working with Windows Movie Maker

Mathematical Computing

Function Graphing pdf (6/19/10)

A New Implementation of L A TEX s verbatim and verbatim* Environments.

Fitting data with Matlab

Techniques of Introducing Document-level JavaScript into a PDF file from a L A TEX Source

Points and lines. x x 1 + y 1. y = mx + b

Reading on the Accumulation Buffer: Motion Blur, Anti-Aliasing, and Depth of Field

Version v2.01, 2000/06/29

An Introduction to LATEX

Software Compare and Contrast

Customizing DAZ Studio

The ted package. Manuel Pégourié-Gonnard v1.06 (2008/03/07) 1 Introduction 1. 2 Usage 1. 3 Implementation 3

The qrcode package: Quick Response code generation in L A TEX

Getting Started. 1 by Conner Irwin

Installing and Using Trackside Cameras Revised November 2008

Installing the TX/PX fonts for SWP5/pdfTeX

The wiki2beamer example. October 19, 2012

MTH 122 Calculus II Essex County College Division of Mathematics and Physics 1 Lecture Notes #11 Sakai Web Project Material

eps2pdf v4.0 for Windows

DOWNLOAD PDF GRAPHICS WITH LATEX

Transcription:

The gnuplottex package Lars Kotthoff, Udo Höfel and more contributors December 13, 2015 1 Introduction This package allows you to include gnuplot graphs in your L A TEX documents. The gnuplot code is extracted from the document and written to.gnuplot files. Then, if shell escape is used, the graph files are automatically processed to graphics or L A TEX code files which will then be included in the document. If shell escape isn t used, the user will have to manually convert the files by running gnuplot on the extracted.gnuplot files. Shell escape is available in the web2c TEX compiler, it allows the execution of shell code during the compilation of a TEX document. It s disabled by default, you ll have to edit your configuration files or give the -shell-escape option to latex. The package also allows you to include gnuplot code in a file verbatim, generating and including the plot automatically. 2 Requirements To use gnuplottex, you ll need the graphicx, latexsym, keyval, ifthen, and moreverb packages and, of course, gnuplot. If you want to use tikz-terminal you also have to use the gnuplot-lua-tikz-package from gnuplot. If you want to use the eepic-terminal, you ll need the eepic-, the epic- and (if you re not using dvips or dvipdfm) the eepicemu-package. 3 Usage To load the package, simply write \usepackage{gnuplottex} in your document preamble. Options that can be passed to the package are This document corresponds to gnuplottex v0.9.1, dated 2015/12/13. lars@larsko.org udo.hoefel@ipp.mpg.de 1

gnuplot \gnuplotloadfile [ shell ] Use shell escape to automatically generate the graphs from the gnuplot source files. This is the default. Normally, you don t need to specify this option. [ noshell ] Don t use shell escape, graphs must be generated manually. [ miktex ] We re using miktex. [ siunitx ] Use siunitx to typeset numbers in the graphs. You need to load the siunitx package before gnuplottex for this to work. If the gnuplot terminal does not support TEX, a warning will be given and the functionality not used. [ subfolder ] Put the generated graphs in a gnuplottex subfolder, which will be created automatically. [ cleanup ] Delete the.gnuplot files after conversion. In addition, you can set \gnuplotexe to the path to the gnuplot executable. Normally, you don t need to do this; use this option only if L A TEX doesn t find gnuplot. The following environment can be used to include graphs: Within this environment, you can specify arbitrary gnuplot code, for example plot sin(x). The code necessary to write the plot to a file will be inserted by this package. It adds set terminal terminal and the name of the output file. The terminal can be specified by the user and defaults to latex. It may be set to anything supported by gnuplot. If set to a terminal which produces TEX output, such as latex, tex, epslatex, or pstricks, the file processed by gnuplot will be included with the \include command, else the \includegraphics command is used. The file extension of the intermediate file is in some cases different from the terminal name, this is taken care of for most common terminals in the package code. If graphics inclusion fails for a specific terminal, the intermediate file extension may be the cause. The terminal name can be specified as a value to the key terminal as an argument to the environment, \begin{gnuplot}[terminal= terminal ]... The graph can be scaled by providing an argument to the scale key, similar to the specification of the terminal name. It defaults to 1, i.e. no scaling will be done. Additional options to the terminal can be given as argument to the terminaloptions key, e.g. \begin{gnuplot}[terminal=pdf,terminaloptions=font,10 linewidth 3]... In addition to the environment, you can use the command \gnuplotloadfile to directly include gnuplot source code. It accepts the same options as the environment, e.g. \gnuplotloadfile[terminal=pdf]{example.gnuplot} 2

1 0.5 sin(x) cos(x) tan(x) tanh(x) y-label 0 0.5 1 4 2 0 2 4 x-label Figure 1: This is a simple example using the latex-terminal. 4 Examples latex Here are short examples of each possible terminal. This is a terminal that offers only basic support, as you won t be able to (easily) use colours. For an example see figure 1. An advantage of this terminal is that it only relies on the picture-environment (which should be supported widely). Furthermore you can use the siunitx-option to get correct axis labeling and you can use L A TEX commands. On the other hand, if you have multiple things to plot, it ll be hard to distinguish them, as you can t use colours (and the dash patterns are hard to distinguish). As this is something which should be avoided, especially for scientific work, if possible, you should try another terminal. The source code for figure 1 is: \begin{figure}% \centering% \begin{gnuplot}[terminal=latex, terminaloptions=rotate] set key box top left set key width 4 set sample 1000 set xr [-5:5] set yr [-1:1] set xlabel $x$-label set ylabel $y$-label plot sin(x) w l lc 1 t $\sin(x)$,\ 3

1 0.5 sin(x) cos(x) tan(x) tanh(x) y-label 0 0.5 1 4 2 0 2 4 x-label Figure 2: This is a simple example using the epslatex-terminal. cos(x) w l lc 2 t $\cos(x)$,\ tan(x) w l lc 3 t $\tan(x)$,\ tanh(x) w l lc 4 t $\tanh(x)$ \caption{this is a simple example using the latex-terminal.}% \label{pic:latex}% \end{figure}% This terminal produces high-quality output, you also can use the siunitx- option for axis labeling and the usual L A TEX commands. There are rare examples where one sees flaws, like two lines not completely adhering (see e.g. some parts of the red line in figure 2). You have to use the epstopdf-package to use this terminal with pdftex. If you re using pdftex this or the cairolatex-terminal should be the terminals you use. Your pdf viewer can slow down dramatically, if you use high resolution 3d plots though, but there are seldom real problems. For an example see figure 2. Its code is: epslatex \begin{figure}% \centering% 4

\begin{gnuplot}[terminal=epslatex, terminaloptions=color dashed] set key box top left set key width 2 set key opaque set sample 1000 set xr [-5:5] set yr [-1:1] set xlabel $x$-label set ylabel $y$-label plot sin(x) w l lc 1 lw 3 t $\sin(x)$,\ cos(x) w l lc 2 lw 3 t $\cos(x)$,\ tan(x) w l lc 3 lw 3 t $\tan(x)$,\ tanh(x) w l lc 4 lw 3 t $\tanh(x)$ \caption{this is a simple example using the epslatex-terminal.}% \label{pic:epslatex}% \end{figure}% jpeg This is a terminal that offers (compared with other terminals) poor raster graphics output. If possible switch to another terminal (preferably to the cairolatex-, the epslatex- or the tikz-terminal) For an example see figure 3. There are quite some disadvantages, as you cannot use L A TEX commands, it is hard to get the right font and the right font size, the siunitx option is useless, no vector graphics and there seems to be no support for dashed lines. Its code is: \begin{figure}% \centering% \begin{gnuplot}[terminal=jpeg, terminaloptions=crop] set key box top left set key width -2 set key opaque set sample 1000 set xr [-5:5] set yr [-1:1] set size 0.7,0.7 set xlabel $x$-label set ylabel $y$-label plot sin(x) w l lc 1 lw 3 t $\sin(x)$,\ cos(x) w l lc 2 lw 3 t $\cos(x)$,\ tan(x) w l lc 3 lw 3 t $\tan(x)$,\ tanh(x) w l lc 4 lw 3 t $\tanh(x)$ \caption{this is a simple example using the jpeg-terminal.}% \label{pic:jpeg}% \end{figure}% 5

Figure 3: This is a simple example using the jpeg-terminal. This is a terminal that offers high-quality output. Unlike the epslatex- terminal it will generate directly pdf output. It allows the use of the siunitx option as well as L A TEX commands. If you re using pdftex this or the epslatexterminal should be the terminals you use. cairolatex has the advantage of not needing the epstopdf-package. Your pdf viewer can slow down dramatically, if you use high resolution 3d plots though, but there are seldom real problems. For an example see figure 4. Its code is: cairolatex \begin{figure}% \centering% \begin{gnuplot}[terminal=epslatex, terminaloptions=color dashed] set key box top left set key width 4 set key height 0.25 set key spacing 1.2 set key opaque set sample 1000 set xr [-5:5] set yr [-1:1] set xlabel $x$-label 6

1 0.5 sin(x) cos(x) tan(x) tanh(x) y-label 0 0.5 1 4 2 0 2 4 x-label Figure 4: This is a simple example using the cairolatex-terminal. set ylabel $y$-label plot sin(x) w l lc 1 lw 3 t $\sin(x)$,\ cos(x) w l lc 7 lw 3 t $\cos(x)$,\ tan(x) w l lc 3 lw 3 t $\tan(x)$,\ tanh(x) w l lc 4 lw 3 t $\tanh(x)$ \caption{this is a simple example using the cairolatex-terminal.}% \label{pic:cairolatex}% \end{figure}% eepic This is a terminal that offers better output than the latex-terminal, but it is quite worse compared to epslatex/cairolatex/tikz-terminal. You can use the siunitx option as well as L A TEX commands. It seems one can use either coloured or dashed lines, not both combined. The lines are also pretty ugly and there is no set key opaque-option in gnuplot available. For an example see figure 5. Avoid if possible. There are better terminals available. Its code is: \begin{figure}% \centering% \begin{gnuplot}[terminal=eepic, terminaloptions = color rotate] 7

1 0.5 sin(x) cos(x) tan(x) tanh(x) y-label 0 0.5 1 4 2 0 2 4 x-label Figure 5: This is a simple example using the eepic-terminal. set key box top left #set key width -3 set sample 1000 set xr [-5:5] set yr [-1:1] set xlabel $x$-label set ylabel $y$-label plot sin(x) w l lc 1 lw 3 t $\sin(x)$,\ cos(x) w l lc 2 lw 3 t $\cos(x)$,\ tan(x) w l lc 3 lw 3 t $\tan(x)$,\ tanh(x) w l lc 4 lw 3 t $\tanh(x)$ \caption{this is a simple example using the cairolatex-terminal.}% \label{pic:cairolatex}% \end{figure}% emtex Similar to the latex-terminal (but with emtex specials), except it seems not to draw any borders (at least for pdftex). Only relies on the picture environment, so should be widely supported, the siunitx option is available and you can use L A TEX commands. If you have multiple things to plot, it ll be hard to distinguish them, as you can t use colours (and the dash patterns are hard to distinguish), this is a no-no for scientific work, so avoid if possible. 8

1 0.5 sin(x) cos(x) tan(x) tanh(x) y-label 0 0.5 1 4 2 0 2 4 x-label Figure 6: This is a simple example using the emtex-terminal. The source code for figure 6 is: \begin{figure}% \centering% \begin{gnuplot}[terminal=emtex, terminaloptions=rotate] set key box top left set key width 4 set sample 1000 set xr [-5:5] set yr [-1:1] set xlabel $x$-label set ylabel $y$-label plot sin(x) w l lc 2 t $\sin(x)$,\ cos(x) w l lc 4 t $\cos(x)$,\ tan(x) w l lc 6 t $\tan(x)$,\ tanh(x) w l lc 8 t $\tanh(x)$ \caption{this is a simple example using the emtex-terminal.}% \label{pic:emtex}% \end{figure}% tikz Probably offers the best output terminal at the moment, even though the difference to cairolatex and epslatex isn t that big. The siunitx option is 9

1 0.5 sin(x) cos(x) tan(x) tanh(x) fitted function example values y-label 0 0.5 1 4 2 0 2 4 x-label Figure 7: This is a simple example using the tikz-terminal. The slope of the fitted function (a x + c) is a = 0.178 749 999 989 22, while its offset is c = 0.114 285 714 323 53. available, L A TEX commands can be used and you can easily export constants from within gnuplot (see the example code for an example on how to export them). On the other hand requires this terminal the gnuplot-lua-tikz-package and you cannot use many plots if you use pdftex, as TEXs memory will be exceeded pretty fast. If you use LuaTEX, this is no problem. The source code for figure 7 is: \begin{figure}% \centering% \begin{gnuplot}[terminal=tikz, terminaloptions={color dashed providevars a,c}] set key box top left set key width -0.9 set key height 0.25 set key spacing 1.25 set sample 1000 set grid xtics lt 0 ls 0 set grid ytics lt 0 ls 0 set xr [-5:5] 10

set yr [-1:1] set key opaque set xlabel $x$-label set ylabel $y$-label f(x) = a*x+c fit f(x) "SomeValuesForGnuplot.txt" u ($1*5/7):($2/20) via a,c plot sin(x) w l lc 2 t $\sin(x)$,\ cos(x) w l lc 4 t $\cos(x)$,\ tan(x) w l lc 6 t $\tan(x)$,\ tanh(x) w l lc 3 t $\tanh(x)$,\ f(x) t fitted function lc 4,\ "SomeValuesForGnuplot.txt" u ($1*5/7):($2/20) w points lc 5\ t example values \caption{this is a simple example using the \texttt{tikz}-terminal. The slope of the fitted function ($a*x+c$) is $a=\num{\gpgetvar{a}}$, while its offset is $c=\num{\gpgetvar{c}}$.}% \label{pic:tikz}% \end{figure}% As compiling all pictures everytime can take quite a long time, the tikz-package offers the possibility to externalize the pictures, resulting in a great speedup. An example for LuaTEX is shown below, pictures are not generated if they are up-todate. In the preamble write: \usepackage{tikz} \usetikzlibrary{external} \tikzexternalize[prefix=gnuplottex/] %-- Use the gnuplottex-subfolder. Deactivate %-- the subfolderoption of gnuplottex to use! \tikzset{external/system call={lualatex -shell-escape -halt-on-error -interaction=batchmode -jobname "\image" "\texsource"}} \tikzexternalize In the document, write e. g.: \begin{figure}% \centering% \tikzsetnextfilename{thisisasinus} \begin{tikzpicture}[gnuplot] \begin{gnuplot}[terminal=tikz, terminaloptions=color dashed nopicenvironment] set grid xtics mxtics lt 0 ls 0 set grid ytics mytics lt 0 ls 0 set key box top left plot sin(x) w l t Sinus \end{tikzpicture} \caption{captiontext.}% \label{pic:thisisasinus}% \end{figure}% 11

pstex,pslatex,pstricks The pstex- and pslatex-terminal produces unusable output with pdftex. I wasn t able to get any output using the pstricks-terminal with pdftex (if you manage to get reasonable output via one of these terminals, please send me an email). 5 Acknowledgements In addition to the people mentioned in the changelog, I would like to thank Roy Ratcliffe for the suggestion and basic code for the gnuplot terminal specification and handling. Additional thanks to Michel Voßuhle for the implementation of \gnuplotloadfile. I would also like to thank all the people who sent me bug reports, feature requests and patches Philip Vetter, sdaau, Mika Pflüger, Henri Menke, Michel Voßkuhle, Udo Höfel, Thomas Schmid and Manuel Solano. Gnuplottex wouldn t be what it is today without you. 6 Implementation 6.1 Initialization 1 \newif\ifshellescape 2 \newif\ifmiktex \miktexfalse 3 \newif\ifusesiunitx 4 \newif\ifcleanup 5 \newif\ifusesubfolder 6 7 \newwrite\verbatim@out 8 9 \DeclareOption{shell}{\ShellEscapetrue} 10 \DeclareOption{noshell}{\ShellEscapefalse} 11 \DeclareOption{miktex}{\global\miktextrue} 12 \DeclareOption{siunitx}{\usesiunitxtrue} 13 \DeclareOption{cleanup}{\cleanuptrue} 14 \DeclareOption{subfolder}{\usesubfoldertrue} 15 16 \@ifundefined{gnuplotexe}{\def\gnuplotexe{gnuplot}}{} 17 18 \ExecuteOptions{shell} 19 \ProcessOptions\relax 20 %% test if shell escape really works 21 \ifshellescape 22 \def\tmpfile{w18-test-\the\year\the\month\the\day\the\time.tex} 23 \ifmiktex 24 \immediate\write18{echo t > "\tmpfile"} 25 \else 26 \immediate\write18{touch \tmpfile} 27 \fi 28 \ifmiktex 12

29 \IfFileExists{\tmpfile.}{\ShellEscapetrue}{\ShellEscapefalse} 30 \immediate\write18{del "\tmpfile"} 31 \else 32 \IfFileExists{\tmpfile}{\ShellEscapetrue}{\ShellEscapefalse} 33 \immediate\write18{rm -f \tmpfile} 34 \immediate\write18{rm -f "\jobname.gnuploterrors"} 35 \fi 36 \fi 37 38 \ifusesubfolder 39 \ifmiktex 40 \immediate\write18{mkdir gnuplottex} 41 \immediate\write18{echo test > "gnuplottex/\tmpfile"} 42 \else 43 \immediate\write18{mkdir -p "gnuplottex"} 44 \immediate\write18{touch "gnuplottex/\tmpfile"} 45 \fi 46 \IfFileExists{gnuplottex/\tmpfile}{ 47 \ifmiktex 48 \immediate\write18{del "gnuplottex\@backslashchar\tmpfile"} 49 \else 50 \immediate\write18{rm -f "gnuplottex/\tmpfile"} 51 \fi 52 \def\subfolder{gnuplottex/} 53 }{ 54 \PackageWarningNoLine{gnuplottex} 55 {Creation of subfolder failed.\messagebreak 56 You ll need to create the folder yourself} 57 \def\subfolder{} 58 } 59 \else 60 \def\subfolder{} 61 \fi 62 63 64 \ifshellescape 65 \PackageInfo{gnuplottex} 66 {Automatically converting gnuplot files.} 67 \else 68 \PackageWarningNoLine{gnuplottex} 69 {Shell escape not enabled.\messagebreak 70 You ll need to convert the graphs yourself.} 71 \fi 72 \newcounter{fignum} 6.2.gnuplot write out 73 \def\figname{\jobname-gnuplottex-fig\thefignum} 74 75 \def\usesiunitxingnuplot{\immediate\write\verbatim@out{set format \@backslashchar num{\@per 13

76 77 \def\gnuplotverbatimwrite#1{% 78 \def\beforestream 79 {\message{opening gnuplot stream #1}% 80 \immediate\write\verbatim@out{\string set terminal \gnuplotterminal \gnuplotterminal 81 \immediate\write\verbatim@out{\string set output \subfolder\figname.\gnuplottexextension{\g 82 \ifusesiunitx 83 \ifthenelse{\equal{\extension}{\string tex}}{\usesiunitxingnuplot}{\packagewarningno 84 \else 85 \relax 86 \fi 87 } 88 \@bsphack 89 \immediate\openout \verbatim@out #1 90 \BeforeStream% 91 \let\do\@makeother\dospecials 92 \catcode \^^M\active 93 \def\verbatim@processline{% 94 \immediate\write\verbatim@out 95 {\the\verbatim@line}}% 96 \verbatim@start} 97 \def\endgnuplotverbatimwrite{% 98 \immediate\closeout\verbatim@out 99 \@esphack 100 \catcode \\0 101 \catcode \{1 102 \catcode \}2 103 \catcode \$3 104 \catcode \&4 105 \catcode \^^M5 106 \catcode \#6 107 \catcode \^7 108 \catcode \_8 109 \catcode \ 10 110 \catcode \%14} 6.3 Environment definition 111 \def\gnuplottexextension@latex{\string tex} 112 \def\gnuplottexextension@epslatex{\string tex} 113 \def\gnuplottexextension@cairolatex{\string tex} 114 \def\gnuplottexextension@eepic{\string tex} 115 \def\gnuplottexextension@pstricks{\string tex} 116 \def\gnuplottexextension@pslatex{\string tex} 117 \def\gnuplottexextension@pstex{\string tex} 118 \def\gnuplottexextension@emtex{\string tex} 119 \def\gnuplottexextension@jpeg{\string jpg} 120 \def\gnuplottexextension@tikz{\string tex} 121 \def\gnuplottexextension@lua{\string tex} 122 \def\gnuplottexextension#1{\@ifundefined{gnuplottexextension@#1}{#1}{\csname gnuplottexexten 14

123 \define@key{pic}{scale}[1]{\def\gnuplotscale{#1}} 124 \define@key{pic}{terminal}[latex]{\def\gnuplotterminal{#1}} 125 \define@key{pic}{terminaloptions}{\def\gnuplotterminaloptions{ #1}} 126 \newenvironment{gnuplot}[1][]{\stepcounter{fignum}% 127 \def\gnuplotterminal{latex} 128 \def\gnuplotterminaloptions{} 129 \def\gnuplotscale{1} 130 \setkeys{pic}{#1} 131 \xdef\gnuplotcutfile{\subfolder\figname.gnuplot} 132 \gnuplotverbatimwrite{\gnuplotcutfile}} 133 {\endgnuplotverbatimwrite% 134 \gnuplotgraphicsprocess% 135 \gnuplotgraphicsinclude} 6.4.gnuplot file processing 136 \def\extension{\gnuplottexextension{\gnuplotterminal}} 137 \long\gdef\gnuplotgraphicsprocess{% 138 \ifshellescape 139 \IfFileExists{\subfolder\figname.gnuplot}{% 140 \ifmiktex 141 \immediate\write18{\gnuplotexe\space \subfolder\figname.gnuplot} 142 \else 143 \immediate\write18{\gnuplotexe\space \subfolder\figname.gnuplot\ 144 \fi 145 \IfFileExists{\subfolder\figname.\extension}{% 146 \PackageInfo{gnuplottex}{\subfolder\figname.gnuplot converted} 147 \ifcleanup 148 \ifmiktex 149 \immediate\write18{del "\subfolder\figname.gnuplot"} 150 \else 151 \immediate\write18{rm -f "\subfolder\figname.gnuplot"} 152 \fi 153 \fi 154 } 155 {\PackageWarningNoLine{gnuplottex} 156 {Conversion of \subfolder\figname.gnuplot failed}}}{} 157 \fi} 158 \long\def\gnuploterrors@eatpar#1#2\@nil{\def\gnuploterrors@{#2}} 159 \AtEndDocument{% 160 \ifmiktex 161 \else 162 \CatchFileDef\gnuploterrors@{\jobname.gnuploterrors}{\endlinechar= ^^J \catcode \ =12 }% 163 \expandafter\gnuploterrors@eatpar\gnuploterrors@\@nil 164 \ifx\gnuploterrors@\@empty\else 165 \PackageWarningNoLine{gnuplottex}{Gnuplot execution produced errors:^^j% 166 \detokenize\expandafter{\gnuploterrors@}}% 167 \fi 168 \fi 169 } 15

6.5 Graph inclusion 170 \long\gdef\gnuplotgraphicsinclude{% 171 \IfFileExists{\subfolder\figname.\extension}{% 172 \ifthenelse{\equal{\extension}{\string tex}} 173 {\scalebox{\gnuplotscale}{\input{\subfolder\figname.\extension}}} 174 {\includegraphics[scale=\gnuplotscale]{\subfolder\figname.\extension}} 175 } 176 {\PackageWarningNoLine{gnuplottex} 177 {Please convert \subfolder\figname.gnuplot manually}} 178 } 6.6.gnuplot file processing 179 \newcommand{\gnuplotloadfilewrite}[2]{% 180 \immediate\openout \verbatim@out #1% 181 \message{opening gnuplot stream #1}% 182 \immediate\write\verbatim@out{\string set terminal \gnuplotterminal \gnuplotterminaloption 183 \immediate\write\verbatim@out{\string set output \subfolder\figname.\gnuplottexextension{ 184 \ifusesiunitx 185 \ifthenelse{\equal{\extension}{\string tex}}{\usesiunitxingnuplot}{\packagewarningnoline 186 \else 187 \relax 188 \fi 189 \ifusesiunitx 190 {\escapechar=-1\edef\percentforgnuplot{\string\%} 191 \escapechar=-1\edef\backslashforgnuplot{\string\\} 192 \immediate\write\verbatim@out{set format \backslashforgnuplot num{\percentforgnuplot 193 \else 194 \relax 195 \fi 196 \immediate\write\verbatim@out{\string load #2 }% 197 \immediate\closeout\verbatim@out% 198 } 199 200 \newcommand{\gnuplotloadfile}[2][]{ 201 \stepcounter{fignum}% 202 \def\gnuplotterminal{latex} 203 \def\gnuplotterminaloptions{} 204 \def\gnuplotscale{1} 205 \setkeys{pic}{#1} 206 \xdef\gnuplotcutfile{\subfolder\figname.gnuplot} 207 \gnuplotloadfilewrite{\gnuplotcutfile}{#2} 208 \gnuplotgraphicsprocess% 209 \gnuplotgraphicsinclude 210 } 16