From 239dea3abc650575370879a8bdc6f69f4861aceb Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sat, 6 Oct 2007 23:20:38 +0000 Subject: gnuplottex update (6oct07) git-svn-id: svn://tug.org/texlive/trunk@5128 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/gnuplottex/example.tex | 4 +- .../texmf-dist/doc/latex/gnuplottex/gnuplottex.pdf | Bin 90964 -> 94622 bytes .../source/latex/gnuplottex/gnuplottex.dtx | 82 +++++++++++++++------ .../texmf-dist/tex/latex/gnuplottex/gnuplottex.sty | 33 ++++++--- 4 files changed, 85 insertions(+), 34 deletions(-) (limited to 'Master') diff --git a/Master/texmf-dist/doc/latex/gnuplottex/example.tex b/Master/texmf-dist/doc/latex/gnuplottex/example.tex index 951445c6186..71c0d4349f5 100644 --- a/Master/texmf-dist/doc/latex/gnuplottex/example.tex +++ b/Master/texmf-dist/doc/latex/gnuplottex/example.tex @@ -4,11 +4,11 @@ \begin{document} -\begin{gnuplot}[scale=.8] +\begin{gnuplot}[terminal=pdf] plot sin(x), cos(x) \end{gnuplot} -\begin{gnuplot} +\begin{gnuplot}[scale=0.8] set grid set title 'gnuplottex test $e^x$' set ylabel '$y$' diff --git a/Master/texmf-dist/doc/latex/gnuplottex/gnuplottex.pdf b/Master/texmf-dist/doc/latex/gnuplottex/gnuplottex.pdf index bd098089a0a..149661d8670 100644 Binary files a/Master/texmf-dist/doc/latex/gnuplottex/gnuplottex.pdf and b/Master/texmf-dist/doc/latex/gnuplottex/gnuplottex.pdf differ diff --git a/Master/texmf-dist/source/latex/gnuplottex/gnuplottex.dtx b/Master/texmf-dist/source/latex/gnuplottex/gnuplottex.dtx index ded27ac4fb6..1816c309d36 100644 --- a/Master/texmf-dist/source/latex/gnuplottex/gnuplottex.dtx +++ b/Master/texmf-dist/source/latex/gnuplottex/gnuplottex.dtx @@ -42,8 +42,8 @@ % \NeedsTeXFormat{LaTeX2e}[1999/12/01] % \ProvidesPackage{gnuplottex} %<*package> - [2007/08/21 v0.3 gnuplot graphs in LaTeX] -\RequirePackage{latexsym,graphicx,moreverb,keyval} + [2007/10/06 v0.4.1 gnuplot graphs in LaTeX] +\RequirePackage{latexsym,graphicx,moreverb,keyval,ifthen} % % %<*driver> @@ -60,7 +60,7 @@ % % \fi % -% \CheckSum{180} +% \CheckSum{233} % % \CharacterTable % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z @@ -82,6 +82,8 @@ % \changes{v0.1}{2006/04/02}{Initial version.} % \changes{v0.2}{2006/10/28}{Changed gnuplot output to LaTeX, simplified code.} % \changes{v0.3}{2007/08/21}{Improved MikTeX compatibility.} +% \changes{v0.4}{2007/09/28}{Added feature to specify gnuplot terminal.} +% \changes{v0.4.1}{2007/10/06}{Improved gnuplot terminal handling.} % % \GetFileInfo{gnuplottex.dtx} % @@ -98,11 +100,11 @@ % This package allows you to include gnuplot graphs in your \LaTeX{} documents. % % The gnuplot code is extracted from the document and written to -% \texttt{.gnuplot} -% files. Then, if shell escape is used, the graph files are automatically -% processed and converted to LaTeX files, which will then be included. If -% shell escape isn't used, the user will have to manually convert the -% files by running gnuplot on the extracted .gnuplot files. +% \texttt{.gnuplot} files. Then, if shell escape is used, the graph files are +% automatically processed to graphics or \LaTeX{} 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 \texttt{.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 @@ -112,7 +114,8 @@ % \section{Requirements} % % To use gnuplottex, you'll need the \texttt{graphicx}, \texttt{latexsym}, -% \texttt{keyval} and \texttt{moreverb} packages and, of course, gnuplot. +% \texttt{keyval}, \texttt{ifthen}, and \texttt{moreverb} packages and, of +% course, gnuplot. % % \section{Usage} % @@ -133,13 +136,31 @@ % Within this environment, you can specify arbitrary gnuplot code, for example\\ % \texttt{plot sin(x)}.\\ % The code necessary to write the plot to a file will be inserted by this -% package. It adds 'set terminal latex' and the name of the output file. -% Therefore, you cannot specify a terminal or output file in the instructions on -% this environment because it'll break. -% -% You may specify a scaling factor for the graphs by adding the parameter after -% the beginning of the environment, like so: -% \verb=\begin{gnuplottex}=[scale=\meta{scale}] +% package. It adds 'set terminal \meta{terminal}' and the name of the output file. +% The terminal can be specified by the user and defaults to \texttt{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 \verb=\include= command, else the +% \verb=\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 \texttt{terminal} as an argument to the environment, +% \verb=\begin{gnuplottex}=[scale=\meta{terminal}]\\ +% \ldots\\ +% \verb=\end{gnuplottex}= +% +% The graph can be scaled by providing an argument to the \texttt{scale} key, +% similar to the specification of the terminal name. It defaults to 1, i.e.\ no +% scaling will be done. +% +% \section{Acknowledgements} +% +% Thanks to Roy Ratcliffe for the suggestion and basic code for the gnuplot +% terminal specification and handling. % % \StopEventually{} % @@ -192,8 +213,8 @@ \def\gnuplotverbatimwrite#1{% \def\BeforeStream {\message{Opening gnuplot stream #1}% - \immediate\write\verbatim@out{\string set terminal latex} - \immediate\write\verbatim@out{\string set output '\figname.tex'} + \immediate\write\verbatim@out{\string set terminal \gnuplotterminal} + \immediate\write\verbatim@out{\string set output '\figname.\gnuplottexextension{\gnuplotterminal}'} } \@bsphack \immediate\openout \verbatim@out #1 @@ -222,13 +243,25 @@ % % \subsection{Environment definition} % \begin{macrocode} -\define@key{pic}{scale}{\def\gnuplotscale{#1}} +\def\gnuplottexextension@latex{\string tex} +\def\gnuplottexextension@epslatex{\string tex} +\def\gnuplottexextension@eepic{\string tex} +\def\gnuplottexextension@pstricks{\string tex} +\def\gnuplottexextension@pslatex{\string tex} +\def\gnuplottexextension@pstex{\string tex} +\def\gnuplottexextension@emtex{\string tex} +\def\gnuplottexextension@jpeg{\string jpg} +\def\gnuplottexextension#1{\@ifundefined{gnuplottexextension@#1}{#1}{\csname gnuplottexextension@#1\endcsname}} +\define@key{pic}{scale}[1]{\def\gnuplotscale{#1}} +\define@key{pic}{terminal}[latex]{\def\gnuplotterminal{#1}} \newenvironment{gnuplot}[1][]{\stepcounter{fignum}% + \def\gnuplotterminal{latex} \def\gnuplotscale{1} \setkeys{pic}{#1} \xdef\gnuplotCutFile{\figname.gnuplot} \gnuplotverbatimwrite{\gnuplotCutFile}} {\endgnuplotverbatimwrite% + \gnuplotgraphicsprocess% \gnuplotgraphicsinclude} % \end{macrocode} % @@ -238,7 +271,7 @@ \ifShellEscape \IfFileExists{\figname.gnuplot}{% \immediate\write18{gnuplot \figname.gnuplot} - \IfFileExists{\figname.tex}{% + \IfFileExists{\figname.\gnuplottexextension{\gnuplotterminal}}{% \PackageInfo{gnuplottex} {\figname.gnuplot converted}} {\PackageWarningNoLine{gnuplottex} @@ -248,9 +281,12 @@ % % \subsection{Graph inclusion} % \begin{macrocode} -\long\gdef\gnuplotgraphicsinclude{\gnuplotgraphicsprocess% - \IfFileExists{\figname.tex}{% - \scalebox{\gnuplotscale}{\input{\figname}}} +\long\gdef\gnuplotgraphicsinclude{% + \IfFileExists{\figname.\gnuplottexextension{\gnuplotterminal}}{% + \ifthenelse{\equal{\gnuplottexextension{\gnuplotterminal}}{\string tex}} + {\scalebox{\gnuplotscale}{\input{\figname.\gnuplottexextension{\gnuplotterminal}}}} + {\includegraphics[scale=\gnuplotscale]{\figname.\gnuplottexextension{\gnuplotterminal}}} + } {\PackageWarningNoLine{gnuplottex} {Please convert \figname.gnuplot manually}} } diff --git a/Master/texmf-dist/tex/latex/gnuplottex/gnuplottex.sty b/Master/texmf-dist/tex/latex/gnuplottex/gnuplottex.sty index 05a3044a666..bafdb9e617e 100644 --- a/Master/texmf-dist/tex/latex/gnuplottex/gnuplottex.sty +++ b/Master/texmf-dist/tex/latex/gnuplottex/gnuplottex.sty @@ -41,8 +41,8 @@ %% \NeedsTeXFormat{LaTeX2e}[1999/12/01] \ProvidesPackage{gnuplottex} - [2007/08/21 v0.3 gnuplot graphs in LaTeX] -\RequirePackage{latexsym,graphicx,moreverb,keyval} + [2007/10/06 v0.4.1 gnuplot graphs in LaTeX] +\RequirePackage{latexsym,graphicx,moreverb,keyval,ifthen} \newif\ifShellEscape \newif\ifmiktex \miktexfalse @@ -84,8 +84,8 @@ \def\gnuplotverbatimwrite#1{% \def\BeforeStream {\message{Opening gnuplot stream #1}% - \immediate\write\verbatim@out{\string set terminal latex} -\immediate\write\verbatim@out{\string set output '\figname.tex'} + \immediate\write\verbatim@out{\string set terminal \gnuplotterminal} +\immediate\write\verbatim@out{\string set output '\figname.\gnuplottexextension{\gnuplotterminal}'} } \@bsphack \immediate\openout \verbatim@out #1 @@ -110,27 +110,42 @@ \catcode`\_8 \catcode`\ 10 \catcode`\%14} -\define@key{pic}{scale}{\def\gnuplotscale{#1}} +\def\gnuplottexextension@latex{\string tex} +\def\gnuplottexextension@epslatex{\string tex} +\def\gnuplottexextension@eepic{\string tex} +\def\gnuplottexextension@pstricks{\string tex} +\def\gnuplottexextension@pslatex{\string tex} +\def\gnuplottexextension@pstex{\string tex} +\def\gnuplottexextension@emtex{\string tex} +\def\gnuplottexextension@jpeg{\string jpg} +\def\gnuplottexextension#1{\@ifundefined{gnuplottexextension@#1}{#1}{\csname gnuplottexextension@#1\endcsname}} +\define@key{pic}{scale}[1]{\def\gnuplotscale{#1}} +\define@key{pic}{terminal}[latex]{\def\gnuplotterminal{#1}} \newenvironment{gnuplot}[1][]{\stepcounter{fignum}% +\def\gnuplotterminal{latex} \def\gnuplotscale{1} \setkeys{pic}{#1} \xdef\gnuplotCutFile{\figname.gnuplot} \gnuplotverbatimwrite{\gnuplotCutFile}} {\endgnuplotverbatimwrite% + \gnuplotgraphicsprocess% \gnuplotgraphicsinclude} \long\gdef\gnuplotgraphicsprocess{% \ifShellEscape \IfFileExists{\figname.gnuplot}{% \immediate\write18{gnuplot \figname.gnuplot} -\IfFileExists{\figname.tex}{% +\IfFileExists{\figname.\gnuplottexextension{\gnuplotterminal}}{% \PackageInfo{gnuplottex} {\figname.gnuplot converted}} {\PackageWarningNoLine{gnuplottex} {Conversion of \figname.gnuplot failed.}}}{} \fi} -\long\gdef\gnuplotgraphicsinclude{\gnuplotgraphicsprocess% -\IfFileExists{\figname.tex}{% -\scalebox{\gnuplotscale}{\input{\figname}}} +\long\gdef\gnuplotgraphicsinclude{% +\IfFileExists{\figname.\gnuplottexextension{\gnuplotterminal}}{% +\ifthenelse{\equal{\gnuplottexextension{\gnuplotterminal}}{\string tex}} +{\scalebox{\gnuplotscale}{\input{\figname.\gnuplottexextension{\gnuplotterminal}}}} +{\includegraphics[scale=\gnuplotscale]{\figname.\gnuplottexextension{\gnuplotterminal}}} +} {\PackageWarningNoLine{gnuplottex} {Please convert \figname.gnuplot manually}} } -- cgit v1.2.3