summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/gnuplottex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2013-07-24 21:47:34 +0000
committerKarl Berry <karl@freefriends.org>2013-07-24 21:47:34 +0000
commit2ca350121961af1d06876475b5c661ebc41993e6 (patch)
treede21d08197678f3e3165045239281a4982f6e4e9 /Master/texmf-dist/tex/latex/gnuplottex
parent5e14116e06fecff88428f6def065d5b502234248 (diff)
gnuplottex (24jul13)
git-svn-id: svn://tug.org/texlive/trunk@31279 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/gnuplottex')
-rw-r--r--Master/texmf-dist/tex/latex/gnuplottex/gnuplottex.sty75
1 files changed, 55 insertions, 20 deletions
diff --git a/Master/texmf-dist/tex/latex/gnuplottex/gnuplottex.sty b/Master/texmf-dist/tex/latex/gnuplottex/gnuplottex.sty
index 290c26d7465..4f1d47f9a9d 100644
--- a/Master/texmf-dist/tex/latex/gnuplottex/gnuplottex.sty
+++ b/Master/texmf-dist/tex/latex/gnuplottex/gnuplottex.sty
@@ -6,7 +6,7 @@
%%
%% gnuplottex.dtx (with options: `package')
%%
-%% Copyright (c) 2006-13, Lars Kotthoff <lars@larsko.org>
+%% Copyright (c) 2006-13, Lars Kotthoff <lars@larsko.org> and contributors
%%
%% Large portions copied from pdftex,
%% Copyright (c) 2001-3, Radhakrishnan CV <cvr@river-valley.com>
@@ -41,11 +41,13 @@
%%
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{gnuplottex}
- [2013/06/28 v0.6 gnuplot graphs in LaTeX]
+ [2013/07/23 v0.7 gnuplot graphs in LaTeX]
\RequirePackage{latexsym,graphicx,moreverb,keyval,ifthen}
\newif\ifShellEscape
\newif\ifmiktex \miktexfalse
\newif\ifusesiunitx
+\newif\ifcleanup
+\newif\ifusesubfolder
\newwrite\verbatim@out
@@ -53,14 +55,15 @@
\DeclareOption{noshell}{\ShellEscapefalse}
\DeclareOption{miktex}{\global\miktextrue}
\DeclareOption{siunitx}{\usesiunitxtrue}
+\DeclareOption{cleanup}{\cleanuptrue}
+\DeclareOption{subfolder}{\usesubfoldertrue}
\ExecuteOptions{shell}
\ProcessOptions\relax
%% test if shell escape really works
\ifShellEscape
-\def\tmpfile{/tmp/w18-test-\the\year\the\month\the\day\the\time.tex}
-\ifmiktex
\def\tmpfile{w18-test-\the\year\the\month\the\day\the\time.tex}
+\ifmiktex
\immediate\write18{echo t > "\tmpfile"}
\else
\immediate\write18{touch \tmpfile}
@@ -74,6 +77,32 @@
\fi
\fi
+\ifusesubfolder
+ \ifmiktex
+ \immediate\write18{mkdir gnuplottex}
+ \immediate\write18{echo test > "gnuplottex/\tmpfile"}
+ \else
+ \immediate\write18{mkdir -p "gnuplottex"}
+ \immediate\write18{touch "gnuplottex/\tmpfile"}
+ \fi
+ \IfFileExists{gnuplottex/\tmpfile}{
+ \ifmiktex
+ \immediate\write18{del "gnuplottex\@backslashchar\tmpfile"}
+ \def\subfolder{gnuplottex\@backslashchar}
+ \else
+ \immediate\write18{rm -f "gnuplottex/\tmpfile"}
+ \def\subfolder{gnuplottex/}
+ \fi
+ }{
+ \PackageWarningNoLine{gnuplottex}
+ {Creation of subfolder failed.\MessageBreak
+ You'll need to create the folder yourself}
+ \def\subfolder{}
+ }
+\else
+ \def\subfolder{}
+\fi
+
\ifShellEscape
\PackageInfo{gnuplottex}
{Automatically converting gnuplot files.}
@@ -85,15 +114,13 @@
\newcounter{fignum}
\def\figname{\jobname-gnuplottex-fig\thefignum}
-\def\usesiunitxingnuplot{{\escapechar=-1\edef\percentforgnuplot{\string\%}
- \escapechar=-1\edef\backslashforgnuplot{\string\\}
- \immediate\write\verbatim@out{set format '\backslashforgnuplot num{\percentforgnuplot g}'}}}
+\def\usesiunitxingnuplot{\immediate\write\verbatim@out{set format '\@backslashchar num{\@percentchar g}'}}
\def\gnuplotverbatimwrite#1{%
\def\BeforeStream
{\message{Opening gnuplot stream #1}%
\immediate\write\verbatim@out{\string set terminal \gnuplotterminal \gnuplotterminaloptions}
-\immediate\write\verbatim@out{\string set output '\figname.\gnuplottexextension{\gnuplotterminal}'}
+\immediate\write\verbatim@out{\string set output '\subfolder\figname.\gnuplottexextension{\gnuplotterminal}'}
\ifusesiunitx
\ifthenelse{\equal{\extension}{\string tex}}{\usesiunitxingnuplot}{\PackageWarningNoLine{gnuplottex}{Axis numbers not written in \noexpand\num{}. Use a terminal that allows TeX output to enable this feature.}}
\else
@@ -142,7 +169,7 @@
\def\gnuplotterminaloptions{}
\def\gnuplotscale{1}
\setkeys{pic}{#1}
- \xdef\gnuplotCutFile{\figname.gnuplot}
+ \xdef\gnuplotCutFile{\subfolder\figname.gnuplot}
\gnuplotverbatimwrite{\gnuplotCutFile}}
{\endgnuplotverbatimwrite%
\gnuplotgraphicsprocess%
@@ -150,27 +177,35 @@
\def\extension{\gnuplottexextension{\gnuplotterminal}}
\long\gdef\gnuplotgraphicsprocess{%
\ifShellEscape
-\IfFileExists{\figname.gnuplot}{%
-\immediate\write18{gnuplot \figname.gnuplot}
-\IfFileExists{\figname.\extension}{%
-\PackageInfo{gnuplottex}{\figname.gnuplot converted}}
+\IfFileExists{\subfolder\figname.gnuplot}{%
+\immediate\write18{gnuplot \subfolder\figname.gnuplot}
+\IfFileExists{\subfolder\figname.\extension}{%
+\PackageInfo{gnuplottex}{\subfolder\figname.gnuplot converted}
+ \ifcleanup
+ \ifmiktex
+ \immediate\write18{del "\subfolder\figname.gnuplot"}
+ \else
+ \immediate\write18{rm -f "\subfolder\figname.gnuplot"}
+ \fi
+ \fi
+ }
{\PackageWarningNoLine{gnuplottex}
-{Conversion of \figname.gnuplot failed}}}{}
+{Conversion of \subfolder\figname.gnuplot failed}}}{}
\fi}
\long\gdef\gnuplotgraphicsinclude{%
-\IfFileExists{\figname.\extension}{%
+\IfFileExists{\subfolder\figname.\extension}{%
\ifthenelse{\equal{\extension}{\string tex}}
-{\scalebox{\gnuplotscale}{\input{\figname.\extension}}}
-{\includegraphics[scale=\gnuplotscale]{\figname.\extension}}
+{\scalebox{\gnuplotscale}{\input{\subfolder\figname.\extension}}}
+{\includegraphics[scale=\gnuplotscale]{\subfolder\figname.\extension}}
}
{\PackageWarningNoLine{gnuplottex}
-{Please convert \figname.gnuplot manually}}
+{Please convert \subfolder\figname.gnuplot manually}}
}
\newcommand{\gnuplotloadfilewrite}[2]{%
\immediate\openout \verbatim@out #1%
\message{Opening gnuplot stream #1}%
\immediate\write\verbatim@out{\string set terminal \gnuplotterminal \gnuplotterminaloptions}%
- \immediate\write\verbatim@out{\string set output '\figname.\gnuplottexextension{\gnuplotterminal}'}%
+ \immediate\write\verbatim@out{\string set output '\subfolder\figname.\gnuplottexextension{\gnuplotterminal}'}%
\ifusesiunitx
\ifthenelse{\equal{\extension}{\string tex}}{\usesiunitxingnuplot}{\PackageWarningNoLine{gnuplottex}{Axis numbers not written in \noexpand\num{}. Use a terminal that allows TeX output to enable this feature.}}
\else
@@ -193,7 +228,7 @@
\def\gnuplotterminaloptions{}
\def\gnuplotscale{1}
\setkeys{pic}{#1}
- \xdef\gnuplotCutFile{\figname.gnuplot}
+ \xdef\gnuplotCutFile{\subfolder\figname.gnuplot}
\gnuplotloadfilewrite{\gnuplotCutFile}{#2}
\gnuplotgraphicsprocess%
\gnuplotgraphicsinclude