| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% Copyright (c) 2006-2015, Lars Kotthoff <[email protected]> and contributors |
| 4 |
% |
| 5 |
% Large portions copied from pdftex, |
| 6 |
% Copyright (c) 2001-3, Radhakrishnan CV <[email protected]> |
| 7 |
% Rajagopal CV <[email protected]> |
| 8 |
% http://www.river-valley.com |
| 9 |
% |
| 10 |
% River Valley Technologies, Floor III, SJP Buildings, Cotton Hills |
| 11 |
% Trivandrum, India 695014 |
| 12 |
% |
| 13 |
% Tel: +91 471 233 7501 |
| 14 |
% |
| 15 |
% Antoine Chambert-Loir |
| 16 |
% <[email protected]> |
| 17 |
% http://www.math.polytechnique.fr/~chambert |
| 18 |
% |
| 19 |
% Ecole polytechnique, Palaiseau Cedex, France |
| 20 |
% |
| 21 |
% This program is free software; you can redistribute it and/or |
| 22 |
% modify it under the terms of the GNU General Public License |
| 23 |
% as published by the Free Software Foundation; either version 2 |
| 24 |
% of the License, or (at your option) any later version. |
| 25 |
% |
| 26 |
% This program is distributed in the hope that it will be useful, |
| 27 |
% but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 28 |
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 29 |
% GNU General Public License for more details. |
| 30 |
% |
| 31 |
% You should have received a copy of the GNU General Public License |
| 32 |
% along with this program (gpl.txt); if not, write to the Free |
| 33 |
% Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
| 34 |
% MA 02111-1307, USA. |
| 35 |
% |
| 36 |
% \fi |
| 37 |
% |
| 38 |
% \iffalse |
| 39 |
%<*driver> |
| 40 |
\ProvidesFile{gnuplottex.dtx} |
| 41 |
%</driver> |
| 42 |
%<package> \NeedsTeXFormat{LaTeX2e}[1999/12/01] |
| 43 |
%<package> \ProvidesPackage{gnuplottex} |
| 44 |
%<*package> |
| 45 |
[2020/03/19 v0.9.5 gnuplot graphs in LaTeX] |
| 46 |
\RequirePackage{graphicx,moreverb,keyval,ifthen,catchfile} |
| 47 |
%</package> |
| 48 |
% |
| 49 |
%<*driver> |
| 50 |
\documentclass{ltxdoc} |
| 51 |
% \iffalse |
| 52 |
%<*example> |
| 53 |
\usepackage{xcolor,epstopdf,siunitx,eepic,epic,eepicemu,gnuplot-lua-tikz} |
| 54 |
% \fi |
| 55 |
% \iffalse |
| 56 |
%</example> |
| 57 |
% \fi |
| 58 |
\usepackage[siunitx]{gnuplottex} |
| 59 |
\EnableCrossrefs |
| 60 |
\CodelineIndex |
| 61 |
\RecordChanges |
| 62 |
\begin{document} |
| 63 |
\DocInput{gnuplottex.dtx} |
| 64 |
\PrintChanges |
| 65 |
\PrintIndex |
| 66 |
\end{document} |
| 67 |
%</driver> |
| 68 |
% \fi |
| 69 |
% |
| 70 |
% \CheckSum{465} |
| 71 |
% |
| 72 |
% \CharacterTable |
| 73 |
% {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 |
| 74 |
% Lower-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 |
| 75 |
% Digits \0\1\2\3\4\5\6\7\8\9 |
| 76 |
% Exclamation \! Double quote \" Hash (number) \# |
| 77 |
% Dollar \$ Percent \% Ampersand \& |
| 78 |
% Acute accent \' Left paren \( Right paren \) |
| 79 |
% Asterisk \* Plus \+ Comma \, |
| 80 |
% Minus \- Point \. Solidus \/ |
| 81 |
% Colon \: Semicolon \; Less than \< |
| 82 |
% Equals \= Greater than \> Question mark \? |
| 83 |
% Commercial at \@ Left bracket \[ Backslash \\ |
| 84 |
% Right bracket \] Circumflex \^ Underscore \_ |
| 85 |
% Grave accent \` Left brace \{ Vertical bar \| |
| 86 |
% Right brace \} Tilde \~} |
| 87 |
% |
| 88 |
% |
| 89 |
% \changes{v0.1}{2006/04/02}{Initial version.} |
| 90 |
% \changes{v0.2}{2006/10/28}{Changed gnuplot output to LaTeX, simplified code.} |
| 91 |
% \changes{v0.3}{2007/08/21}{Improved MikTeX compatibility.} |
| 92 |
% \changes{v0.4}{2007/09/28}{Added feature to specify gnuplot terminal.} |
| 93 |
% \changes{v0.4.1}{2007/10/06}{Improved gnuplot terminal handling.} |
| 94 |
% \changes{v0.4.2}{2007/10/13}{Added terminaloptions option.} |
| 95 |
% \changes{v0.4.3}{2011/04/16}{Fixed terminaloptions example (Philip Vetter).} |
| 96 |
% \changes{v0.4.4}{2011/09/11}{Fixed "Undefined control sequence" error (sdaau).} |
| 97 |
% \changes{v0.4.5}{2012/10/02}{Add support for cairolatex terminal (Mika Pfl\"uger).} |
| 98 |
% \changes{v0.4.6}{2013/04/14}{Fix bug with temporary file creation in LuaTeX (Henri Menke).} |
| 99 |
% \changes{v0.5}{2013/06/03}{Provide command to include gnuplot code in file verbatim (Michel Vo\ss{}kuhle).} |
| 100 |
% \changes{v0.6}{2013/06/28}{Support for \texttt{siunitx} package and tikz terminal (Udo H\"ofel).} |
| 101 |
% \changes{v0.7}{2013/07/23}{Add cleanup and subfolder option (Udo H\"ofel).} |
| 102 |
% \changes{v0.7.1}{2013/09/08}{Fix bug with subfolder option with MikTeX (Thomas Schmid).} |
| 103 |
% \changes{v0.7.2}{2013/11/16}{Allow to specify path to gnuplot (Manuel Solano).} |
| 104 |
% \changes{v0.8}{2013/11/24}{Extended Documentation.} |
| 105 |
% \changes{v0.8.1}{2013/12/29}{Extended Documentation.} |
| 106 |
% \changes{v0.9}{2015/12/08}{Show any errors during conversion on Unix (Enrico Gregorio, suggested by Udo H\"ofel).} |
| 107 |
% \changes{v0.9.1}{2015/12/13}{Fix bug in error gathering introduced in 0.9.} |
| 108 |
% \changes{v0.9.2}{2016/08/21}{Misc bugfixes (thanks fostermaier, Enrico Gregorio, Jan-Benedict Glaw).} |
| 109 |
% \changes{v0.9.3}{2019/09/22}{Whitespace fixes (thanks Johannes Hielscher).} |
| 110 |
% \changes{v0.9.4}{2019/12/22}{Whitespace fixes (thanks Johannes Hielscher).} |
| 111 |
% \changes{v0.9.5}{2020/03/19}{Make subfolder creation test conditional on shell escape being enabled (thanks Alex Serenko).} |
| 112 |
% |
| 113 |
% \GetFileInfo{gnuplottex.dtx} |
| 114 |
% |
| 115 |
% \DoNotIndex{\the,\year,\month,\day,\time} |
| 116 |
% |
| 117 |
% \title{The \textsf{gnuplottex} package\thanks{This document |
| 118 |
% corresponds to \textsf{gnuplottex}~\fileversion, dated \filedate.}} |
| 119 |
% \author{Lars Kotthoff\hspace{0.05em}\thanks{\texttt{[email protected]}}, Udo H\"ofel\thanks{\texttt{[email protected]}} and more contributors } |
| 120 |
% |
| 121 |
% \maketitle |
| 122 |
% |
| 123 |
% \section{Introduction} |
| 124 |
% |
| 125 |
% This package allows you to include gnuplot graphs in your \LaTeX{} documents. |
| 126 |
% |
| 127 |
% The gnuplot code is extracted from the document and written to |
| 128 |
% \texttt{.gnuplot} files. Then, if shell escape is used, the graph files are |
| 129 |
% automatically processed to graphics or \LaTeX{} code files which will then be |
| 130 |
% included in the document. |
| 131 |
% If shell escape isn't used, the user will have to manually convert |
| 132 |
% the files by running gnuplot on the extracted \texttt{.gnuplot} files. |
| 133 |
% |
| 134 |
% Shell escape is available in the web2c \TeX{} compiler, it allows the execution |
| 135 |
% of shell code during the compilation of a \TeX{} document. It's disabled by |
| 136 |
% default, you'll have to edit your configuration files or give the |
| 137 |
% \texttt{-shell-escape} option to \texttt{latex}. |
| 138 |
% |
| 139 |
% The package also allows you to include gnuplot code in a file verbatim, |
| 140 |
% generating and including the plot automatically. |
| 141 |
% |
| 142 |
% If you find a bug, please open an issue at |
| 143 |
% \url{https://github.com/larskotthoff/gnuplottex/issues}. |
| 144 |
% |
| 145 |
% \section{Requirements} |
| 146 |
% |
| 147 |
% To use gnuplottex, you'll need the \texttt{graphicx}, \texttt{latexsym}, |
| 148 |
% \texttt{keyval}, \texttt{ifthen}, and \texttt{moreverb} packages and, of |
| 149 |
% course, gnuplot. |
| 150 |
% If you want to use tikz-terminal you also have to use the \texttt{gnuplot-lua-tikz}-package from gnuplot. |
| 151 |
% If you want to use the \texttt{eepic}-terminal, you'll need the \texttt{eepic}-, the \texttt{epic}- and (if you're not using dvips or dvipdfm) the \texttt{eepicemu}-package. |
| 152 |
% If you use beamer, be aware that you have to call the frame with \texttt{\textbackslash begin\{frame\}[fragile]}. |
| 153 |
% |
| 154 |
% \section{Usage} |
| 155 |
% |
| 156 |
% To load the package, simply write \verb=\usepackage{gnuplottex}= in your document |
| 157 |
% preamble. Options that can be passed to the package are |
| 158 |
% \begin{description} |
| 159 |
% \item[\oarg{shell}] Use shell escape to automatically generate the graphs |
| 160 |
% from the gnuplot source files. This is the default. Normally, you don't |
| 161 |
% need to specify this option. |
| 162 |
% \item[\oarg{noshell}] Don't use shell escape, graphs must be generated |
| 163 |
% manually. |
| 164 |
% \item[\oarg{miktex}] We're using mikTeX. |
| 165 |
% \item[\oarg{siunitx}] Use \texttt{siunitx} to typeset numbers in the |
| 166 |
% graphs. You need to load the \texttt{siunitx} package before |
| 167 |
% \texttt{gnuplottex} for this to work. If the gnuplot terminal does not |
| 168 |
% support \TeX, a warning will be given and the functionality not used. |
| 169 |
% \item[\oarg{subfolder}] Put the generated graphs in a "gnuplottex" |
| 170 |
% subfolder, which will be created automatically. |
| 171 |
% \item[\oarg{cleanup}] Delete the \texttt{.gnuplot} files after conversion. |
| 172 |
% \end{description} |
| 173 |
% |
| 174 |
% In addition, you can set \verb=\gnuplotexe= to the path to the gnuplot |
| 175 |
% executable. Normally, you don't need to do this; use this option only if |
| 176 |
% \LaTeX{} doesn't find gnuplot. For example:\\ |
| 177 |
% \verb=\def\gnuplotexe{/opt/local/bin/gnuplot}= |
| 178 |
% |
| 179 |
% The following environment can be used to include graphs: |
| 180 |
% |
| 181 |
% \DescribeEnv{gnuplot} |
| 182 |
% Within this environment, you can specify arbitrary gnuplot code, for example\\ |
| 183 |
% \texttt{plot sin(x)}.\\ |
| 184 |
% The code necessary to write the plot to a file will be inserted by this |
| 185 |
% package. It adds 'set terminal \meta{terminal}' and the name of the output file. |
| 186 |
% The terminal can be specified by the user and defaults to \texttt{latex}. It may |
| 187 |
% be set to anything supported by gnuplot. If set to a terminal which produces |
| 188 |
% \TeX{} output, such as latex, tex, epslatex, or pstricks, the file processed |
| 189 |
% by gnuplot will be included with the \verb=\include= command, else the |
| 190 |
% \verb=\includegraphics= command is used. The file extension of the |
| 191 |
% intermediate file is in some cases different from the terminal name, this is |
| 192 |
% taken care of for most common terminals in the package code. If graphics |
| 193 |
% inclusion fails for a specific terminal, the intermediate file extension may |
| 194 |
% be the cause. |
| 195 |
% |
| 196 |
% The terminal name can be specified as |
| 197 |
% a value to the key \texttt{terminal} as an argument to the environment,\\ |
| 198 |
% \verb=\begin{gnuplot}=[terminal=\meta{terminal}]\\ |
| 199 |
% \ldots\\ |
| 200 |
% \verb=\end{gnuplot}= |
| 201 |
% |
| 202 |
% The graph can be scaled by providing an argument to the \texttt{scale} key, |
| 203 |
% similar to the specification of the terminal name. It defaults to 1, i.e.\ no |
| 204 |
% scaling will be done. Additional options to the terminal can be given as |
| 205 |
% argument to the \texttt{terminaloptions} key, e.g.\\ |
| 206 |
% \verb=\begin{gnuplot}=[terminal=pdf,terminaloptions={font ",10" linewidth 3}]\\ |
| 207 |
% \ldots\\ |
| 208 |
% \verb=\end{gnuplot}= |
| 209 |
% |
| 210 |
% \DescribeMacro{\gnuplotloadfile} |
| 211 |
% In addition to the environment, you can use the command |
| 212 |
% \verb=\gnuplotloadfile= to directly include gnuplot source code. It accepts |
| 213 |
% the same options as the environment, e.g.\\ |
| 214 |
% \verb+\gnuplotloadfile[terminal=pdf]{example.gnuplot}+ |
| 215 |
% |
| 216 |
%\section{Examples} |
| 217 |
% Here are short examples of each possible terminal. |
| 218 |
% |
| 219 |
% \DescribeMacro{latex} |
| 220 |
% This is a terminal that offers only basic support, as you won't be able to (easily) use colours. For an example see figure~\ref{pic:latex}. |
| 221 |
% |
| 222 |
% An advantage of this terminal is that it only relies on the picture-environment (which should be supported widely). |
| 223 |
% Furthermore you can use the \texttt{siunitx}-option to get correct axis labeling and you can use \LaTeX{} commands. |
| 224 |
% |
| 225 |
% 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). |
| 226 |
% As this is something which should be avoided, especially for scientific work, if possible, you should try another terminal. |
| 227 |
% \iffalse |
| 228 |
%<*example> |
| 229 |
% \fi |
| 230 |
\begin{figure}% |
| 231 |
\centering% |
| 232 |
\begin{gnuplot}[terminal=latex, terminaloptions=rotate] |
| 233 |
set key box top left |
| 234 |
set key width 4 |
| 235 |
set sample 1000 |
| 236 |
set xr [-5:5] |
| 237 |
set yr [-1:1] |
| 238 |
set xlabel '$x$-label' |
| 239 |
set ylabel '$y$-label' |
| 240 |
plot sin(x) w l lc 1 t '$\sin(x)$',\ |
| 241 |
cos(x) w l lc 2 t '$\cos(x)$',\ |
| 242 |
tan(x) w l lc 3 t '$\tan(x)$',\ |
| 243 |
tanh(x) w l lc 4 t '$\tanh(x)$' |
| 244 |
\end{gnuplot} |
| 245 |
\caption{This is a simple example using the \texttt{latex}-terminal.}% |
| 246 |
\label{pic:latex}% |
| 247 |
\end{figure}% |
| 248 |
% \iffalse |
| 249 |
%</example> |
| 250 |
% \fi |
| 251 |
%The source code for figure~\ref{pic:latex} is:\\ |
| 252 |
%\verb+\begin{figure}%+\\ |
| 253 |
%\verb+ \centering%+\\ |
| 254 |
%\verb+ \begin{gnuplot}[terminal=latex, terminaloptions=rotate]+\\ |
| 255 |
%\verb+ set key box top left+\\ |
| 256 |
%\verb+ set key width 4+\\ |
| 257 |
%\verb+ set sample 1000+\\ |
| 258 |
%\verb+ set xr [-5:5]+\\ |
| 259 |
%\verb+ set yr [-1:1]+\\ |
| 260 |
%\verb+ set xlabel '$x$-label'+\\ |
| 261 |
%\verb+ set ylabel '$y$-label'+\\ |
| 262 |
%\verb+ plot sin(x) w l lc 1 t '$\sin(x)$',\+\\ |
| 263 |
%\verb+ cos(x) w l lc 2 t '$\cos(x)$',\+\\ |
| 264 |
%\verb+ tan(x) w l lc 3 t '$\tan(x)$',\+\\ |
| 265 |
%\verb+ tanh(x) w l lc 4 t '$\tanh(x)$'+\\ |
| 266 |
%\verb+ \end{gnuplot}+\\ |
| 267 |
%\verb+ \caption{This is a simple example using the latex-terminal.}%+\\ |
| 268 |
%\verb+ \label{pic:latex}%+\\ |
| 269 |
%\verb+\end{figure}%+\\ |
| 270 |
% |
| 271 |
% \DescribeMacro{epslatex} |
| 272 |
% This terminal produces high-quality output, you also can use the \texttt{siunitx}-option for axis labeling and the usual \LaTeX{} commands. |
| 273 |
% |
| 274 |
% 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~\ref{pic:epslatex}). |
| 275 |
% You have to use the \texttt{epstopdf}-package to use this terminal with pdf\TeX. |
| 276 |
% |
| 277 |
% If you're using pdf\TeX{} this or the \texttt{cairolatex}-terminal should be the terminals you use. |
| 278 |
% Your pdf viewer can slow down dramatically, if you use high resolution 3d plots though, but there are seldom real problems. |
| 279 |
% For an example see figure~\ref{pic:epslatex}. |
| 280 |
% |
| 281 |
% \iffalse |
| 282 |
%<*example> |
| 283 |
% \fi |
| 284 |
\begin{figure}% |
| 285 |
\centering% |
| 286 |
\begin{gnuplot}[terminal=epslatex, terminaloptions=color dashed] |
| 287 |
set key box top left |
| 288 |
set key width 2 |
| 289 |
set key opaque |
| 290 |
set sample 1000 |
| 291 |
set xr [-5:5] |
| 292 |
set yr [-1:1] |
| 293 |
set xlabel '$x$-label' |
| 294 |
set ylabel '$y$-label' |
| 295 |
plot sin(x) w l lc 1 lw 3 t '$\sin(x)$',\ |
| 296 |
cos(x) w l lc 7 lw 3 t '$\cos(x)$',\ |
| 297 |
tan(x) w l lc 3 lw 3 t '$\tan(x)$',\ |
| 298 |
tanh(x) w l lc 4 lw 3 t '$\tanh(x)$' |
| 299 |
\end{gnuplot} |
| 300 |
\caption{This is a simple example using the \texttt{epslatex}-terminal.}% |
| 301 |
\label{pic:epslatex}% |
| 302 |
\end{figure}% |
| 303 |
% \iffalse |
| 304 |
%</example> |
| 305 |
% \fi |
| 306 |
% |
| 307 |
%Its code is:\\ |
| 308 |
%~\\ |
| 309 |
%\verb+\begin{figure}%+\\ |
| 310 |
%\verb+ \centering%+\\ |
| 311 |
%\verb+ \begin{gnuplot}[terminal=epslatex, terminaloptions=color dashed]+\\ |
| 312 |
%\verb+ set key box top left+\\ |
| 313 |
%\verb+ set key width 2+\\ |
| 314 |
%\verb+ set key opaque+\\ |
| 315 |
%\verb+ set sample 1000+\\ |
| 316 |
%\verb+ set xr [-5:5]+\\ |
| 317 |
%\verb+ set yr [-1:1]+\\ |
| 318 |
%\verb+ set xlabel '$x$-label'+\\ |
| 319 |
%\verb+ set ylabel '$y$-label'+\\ |
| 320 |
%\verb+ plot sin(x) w l lc 1 lw 3 t '$\sin(x)$',\+\\ |
| 321 |
%\verb+ cos(x) w l lc 2 lw 3 t '$\cos(x)$',\+\\ |
| 322 |
%\verb+ tan(x) w l lc 3 lw 3 t '$\tan(x)$',\+\\ |
| 323 |
%\verb+ tanh(x) w l lc 4 lw 3 t '$\tanh(x)$'+\\ |
| 324 |
%\verb+ \end{gnuplot}+\\ |
| 325 |
%\verb+ \caption{This is a simple example using the epslatex-terminal.}%+\\ |
| 326 |
%\verb+ \label{pic:epslatex}%+\\ |
| 327 |
%\verb+\end{figure}%+\\ |
| 328 |
% |
| 329 |
% \DescribeMacro{jpeg} |
| 330 |
% This is a terminal that offers (compared with other terminals) poor raster graphics output. |
| 331 |
% If possible switch to another terminal (preferably to the \texttt{cairolatex}-, the \texttt{epslatex}- or the \texttt{tikz}-terminal) |
| 332 |
% For an example see figure~\ref{pic:jpeg}. |
| 333 |
% |
| 334 |
% There are quite some disadvantages, as you cannot use \LaTeX{} commands, it is hard to get the right font and the right font size, the \texttt{siunitx} option is useless, no vector graphics and there seems to be no support for dashed lines. |
| 335 |
% |
| 336 |
% \iffalse |
| 337 |
%<*example> |
| 338 |
% \fi |
| 339 |
\begin{figure}% |
| 340 |
\centering% |
| 341 |
\begin{gnuplot}[terminal=jpeg, terminaloptions=crop] |
| 342 |
set key box top left |
| 343 |
set key width -2 |
| 344 |
set key opaque |
| 345 |
set sample 1000 |
| 346 |
set xr [-5:5] |
| 347 |
set yr [-1:1] |
| 348 |
set size 0.7,0.7 |
| 349 |
set xlabel '$x$-label' |
| 350 |
set ylabel '$y$-label' |
| 351 |
plot sin(x) w l lc 1 lw 2 t '$\sin(x)$',\ |
| 352 |
cos(x) w l lc 7 lw 2 t '$\cos(x)$',\ |
| 353 |
tan(x) w l lc 3 lw 2 t '$\tan(x)$',\ |
| 354 |
tanh(x) w l ls 8 lc 4 lw 2 t '$\tanh(x)$' |
| 355 |
\end{gnuplot} |
| 356 |
\caption{This is a simple example using the \texttt{jpeg}-terminal.}% |
| 357 |
\label{pic:jpeg}% |
| 358 |
\end{figure}% |
| 359 |
% \iffalse |
| 360 |
%</example> |
| 361 |
% \fi |
| 362 |
% |
| 363 |
%Its code is:\\ |
| 364 |
%~\\ |
| 365 |
%\verb+\begin{figure}%+\\ |
| 366 |
%\verb+ \centering%+\\ |
| 367 |
%\verb+ \begin{gnuplot}[terminal=jpeg, terminaloptions=crop]+\\ |
| 368 |
%\verb+ set key box top left+\\ |
| 369 |
%\verb+ set key width -2+\\ |
| 370 |
%\verb+ set key opaque+\\ |
| 371 |
%\verb+ set sample 1000+\\ |
| 372 |
%\verb+ set xr [-5:5]+\\ |
| 373 |
%\verb+ set yr [-1:1]+\\ |
| 374 |
%\verb+ set size 0.7,0.7+\\ |
| 375 |
%\verb+ set xlabel '$x$-label'+\\ |
| 376 |
%\verb+ set ylabel '$y$-label'+\\ |
| 377 |
%\verb+ plot sin(x) w l lc 1 lw 3 t '$\sin(x)$',\+\\ |
| 378 |
%\verb+ cos(x) w l lc 2 lw 3 t '$\cos(x)$',\+\\ |
| 379 |
%\verb+ tan(x) w l lc 3 lw 3 t '$\tan(x)$',\+\\ |
| 380 |
%\verb+ tanh(x) w l lc 4 lw 3 t '$\tanh(x)$'+\\ |
| 381 |
%\verb+ \end{gnuplot}+\\ |
| 382 |
%\verb+ \caption{This is a simple example using the jpeg-terminal.}%+\\ |
| 383 |
%\verb+ \label{pic:jpeg}%+\\ |
| 384 |
%\verb+\end{figure}%+\\ |
| 385 |
% |
| 386 |
% \DescribeMacro{cairolatex} |
| 387 |
% This is a terminal that offers high-quality output. |
| 388 |
% Unlike the \texttt{epslatex}-terminal it will generate \emph{directly} pdf output. |
| 389 |
% It allows the use of the \texttt{siunitx} option as well as \LaTeX{} commands. |
| 390 |
% If you're using pdf\TeX{} this or the \texttt{epslatex}-terminal should be the terminals you use. |
| 391 |
% \texttt{cairolatex} has the advantage of not needing the \texttt{epstopdf}-package. |
| 392 |
% Your pdf viewer can slow down dramatically, if you use high resolution 3d plots though, but there are seldom real problems. |
| 393 |
% For an example see figure~\ref{pic:cairolatex}. |
| 394 |
% |
| 395 |
% \iffalse |
| 396 |
%<*example> |
| 397 |
% \fi |
| 398 |
\begin{figure}% |
| 399 |
\centering% |
| 400 |
\begin{gnuplot}[terminal=cairolatex, terminaloptions=color dashed] |
| 401 |
set key box top left |
| 402 |
set key width 4 |
| 403 |
set key height 0.25 |
| 404 |
set key spacing 1.2 |
| 405 |
set key opaque |
| 406 |
set sample 1000 |
| 407 |
set xr [-5:5] |
| 408 |
set yr [-1:1] |
| 409 |
set xlabel '$x$-label' |
| 410 |
set ylabel '$y$-label' |
| 411 |
plot sin(x) w l lc 1 lw 3 t '$\sin(x)$',\ |
| 412 |
cos(x) w l lc 7 lw 3 t '$\cos(x)$',\ |
| 413 |
tan(x) w l lc 3 lw 3 t '$\tan(x)$',\ |
| 414 |
tanh(x) w l lc 4 lw 3 t '$\tanh(x)$' |
| 415 |
\end{gnuplot} |
| 416 |
\caption{This is a simple example using the \texttt{cairolatex}-terminal.}% |
| 417 |
\label{pic:cairolatex}% |
| 418 |
\end{figure}% |
| 419 |
% \iffalse |
| 420 |
%</example> |
| 421 |
% \fi |
| 422 |
% |
| 423 |
%Its code is:\\ |
| 424 |
%~\\ |
| 425 |
%\verb+\begin{figure}%+\\ |
| 426 |
%\verb+ \centering%+\\ |
| 427 |
%\verb+ \begin{gnuplot}[terminal=epslatex, terminaloptions=color dashed]+\\ |
| 428 |
%\verb+ set key box top left+\\ |
| 429 |
%\verb+ set key width 4+\\ |
| 430 |
%\verb+ set key height 0.25+\\ |
| 431 |
%\verb+ set key spacing 1.2+\\ |
| 432 |
%\verb+ set key opaque+\\ |
| 433 |
%\verb+ set sample 1000+\\ |
| 434 |
%\verb+ set xr [-5:5]+\\ |
| 435 |
%\verb+ set yr [-1:1]+\\ |
| 436 |
%\verb+ set xlabel '$x$-label'+\\ |
| 437 |
%\verb+ set ylabel '$y$-label'+\\ |
| 438 |
%\verb+ plot sin(x) w l lc 1 lw 3 t '$\sin(x)$',\+\\ |
| 439 |
%\verb+ cos(x) w l lc 7 lw 3 t '$\cos(x)$',\+\\ |
| 440 |
%\verb+ tan(x) w l lc 3 lw 3 t '$\tan(x)$',\+\\ |
| 441 |
%\verb+ tanh(x) w l lc 4 lw 3 t '$\tanh(x)$'+\\ |
| 442 |
%\verb+ \end{gnuplot}+\\ |
| 443 |
%\verb+ \caption{This is a simple example using the cairolatex-terminal.}%+\\ |
| 444 |
%\verb+ \label{pic:cairolatex}%+\\ |
| 445 |
%\verb+\end{figure}%+\\ |
| 446 |
% |
| 447 |
% \DescribeMacro{eepic} |
| 448 |
% This is a terminal that offers better output than the \texttt{latex}-terminal, but it is quite worse compared to \texttt{epslatex/cairolatex/tikz}-terminal. |
| 449 |
% You can use the \texttt{siunitx} option as well as \LaTeX{} commands. |
| 450 |
% |
| 451 |
% It seems one can use either coloured or dashed lines, not both combined. |
| 452 |
% The lines are also pretty ugly and there is no \verb+set key opaque+-option in \texttt{gnuplot} available. |
| 453 |
% |
| 454 |
% For an example see figure~\ref{pic:eepic}. |
| 455 |
% Avoid if possible. |
| 456 |
% There are better terminals available. |
| 457 |
% |
| 458 |
% \iffalse |
| 459 |
%<*example> |
| 460 |
% \fi |
| 461 |
\begin{figure}% |
| 462 |
\centering% |
| 463 |
\begin{gnuplot}[terminal=eepic, terminaloptions = color rotate] |
| 464 |
set key box top left |
| 465 |
set key width -3 |
| 466 |
set sample 1000 |
| 467 |
set xr [-5:5] |
| 468 |
set yr [-1:1] |
| 469 |
set xlabel '$x$-label' |
| 470 |
set ylabel '$y$-label' |
| 471 |
plot sin(x) w l lc 1 lw 3 t '$\sin(x)$',\ |
| 472 |
cos(x) w l lc 2 lw 3 t '$\cos(x)$',\ |
| 473 |
tan(x) w l lc 3 lw 3 t '$\tan(x)$',\ |
| 474 |
tanh(x) w l lc 4 lw 3 t '$\tanh(x)$' |
| 475 |
\end{gnuplot} |
| 476 |
\caption{This is a simple example using the \texttt{eepic}-terminal.}% |
| 477 |
\label{pic:eepic}% |
| 478 |
\end{figure}% |
| 479 |
% \iffalse |
| 480 |
%</example> |
| 481 |
% \fi |
| 482 |
%Its code is:\\ |
| 483 |
%~\\ |
| 484 |
%\verb+\begin{figure}%+\\ |
| 485 |
%\verb+ \centering%+\\ |
| 486 |
%\verb+ \begin{gnuplot}[terminal=eepic, terminaloptions = color rotate]+\\ |
| 487 |
%\verb+ set key box top left+\\ |
| 488 |
%\verb+ #set key width -3+\\ |
| 489 |
%\verb+ set sample 1000+\\ |
| 490 |
%\verb+ set xr [-5:5]+\\ |
| 491 |
%\verb+ set yr [-1:1]+\\ |
| 492 |
%\verb+ set xlabel '$x$-label'+\\ |
| 493 |
%\verb+ set ylabel '$y$-label'+\\ |
| 494 |
%\verb+ plot sin(x) w l lc 1 lw 3 t '$\sin(x)$',\+\\ |
| 495 |
%\verb+ cos(x) w l lc 2 lw 3 t '$\cos(x)$',\+\\ |
| 496 |
%\verb+ tan(x) w l lc 3 lw 3 t '$\tan(x)$',\+\\ |
| 497 |
%\verb+ tanh(x) w l lc 4 lw 3 t '$\tanh(x)$'+\\ |
| 498 |
%\verb+ \end{gnuplot}+\\ |
| 499 |
%\verb+ \caption{This is a simple example using the cairolatex-terminal.}%+\\ |
| 500 |
%\verb+ \label{pic:cairolatex}%+\\ |
| 501 |
%\verb+\end{figure}%+\\ |
| 502 |
% |
| 503 |
% \DescribeMacro{emtex} |
| 504 |
% Similar to the \texttt{latex}-terminal (but with emtex specials), except it seems not to draw any borders (at least for pdf\TeX). |
| 505 |
% Only relies on the picture environment, so should be widely supported, the \texttt{siunitx} option is available and you can use \LaTeX{} commands. |
| 506 |
% |
| 507 |
% 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. |
| 508 |
% |
| 509 |
% \iffalse |
| 510 |
%<*example> |
| 511 |
% \fi |
| 512 |
\begin{figure}% |
| 513 |
\centering% |
| 514 |
\begin{gnuplot}[terminal=emtex, terminaloptions=rotate] |
| 515 |
set key box top left |
| 516 |
set key width 4 |
| 517 |
set sample 1000 |
| 518 |
set xr [-5:5] |
| 519 |
set yr [-1:1] |
| 520 |
set xlabel '$x$-label' |
| 521 |
set ylabel '$y$-label' |
| 522 |
plot sin(x) w l lc 2 t '$\sin(x)$',\ |
| 523 |
cos(x) w l lc 4 t '$\cos(x)$',\ |
| 524 |
tan(x) w l lc 6 t '$\tan(x)$',\ |
| 525 |
tanh(x) w l lc 8 t '$\tanh(x)$' |
| 526 |
\end{gnuplot} |
| 527 |
\caption{This is a simple example using the \texttt{emtex}-terminal.}% |
| 528 |
\label{pic:emtex}% |
| 529 |
\end{figure}% |
| 530 |
% \iffalse |
| 531 |
%</example> |
| 532 |
% \fi |
| 533 |
%The source code for figure~\ref{pic:emtex} is:\\ |
| 534 |
%~\\ |
| 535 |
%\verb+\begin{figure}%+\\ |
| 536 |
%\verb+ \centering%+\\ |
| 537 |
%\verb+ \begin{gnuplot}[terminal=emtex, terminaloptions=rotate]+\\ |
| 538 |
%\verb+ set key box top left+\\ |
| 539 |
%\verb+ set key width 4+\\ |
| 540 |
%\verb+ set sample 1000+\\ |
| 541 |
%\verb+ set xr [-5:5]+\\ |
| 542 |
%\verb+ set yr [-1:1]+\\ |
| 543 |
%\verb+ set xlabel '$x$-label'+\\ |
| 544 |
%\verb+ set ylabel '$y$-label'+\\ |
| 545 |
%\verb+ plot sin(x) w l lc 2 t '$\sin(x)$',\+\\ |
| 546 |
%\verb+ cos(x) w l lc 4 t '$\cos(x)$',\+\\ |
| 547 |
%\verb+ tan(x) w l lc 6 t '$\tan(x)$',\+\\ |
| 548 |
%\verb+ tanh(x) w l lc 8 t '$\tanh(x)$'+\\ |
| 549 |
%\verb+ \end{gnuplot}+\\ |
| 550 |
%\verb+ \caption{This is a simple example using the emtex-terminal.}%+\\ |
| 551 |
%\verb+ \label{pic:emtex}%+\\ |
| 552 |
%\verb+\end{figure}%+\\ |
| 553 |
% |
| 554 |
% \DescribeMacro{tikz} |
| 555 |
% Probably offers the best output terminal at the moment, even though the difference to \texttt{cairolatex} and \texttt{epslatex} isn't that big. |
| 556 |
% The \texttt{siunitx} option is available, \LaTeX{} 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). |
| 557 |
% |
| 558 |
%On the other hand requires this terminal the \texttt{gnuplot-lua-tikz}-package and you cannot use many plots if you use pdf\TeX, as \TeX s memory will be exceeded pretty fast. |
| 559 |
% If you use Lua\TeX, this is no problem. |
| 560 |
% |
| 561 |
% \iffalse |
| 562 |
%<*example> |
| 563 |
% \fi |
| 564 |
\begin{figure}% |
| 565 |
\centering% |
| 566 |
\begin{gnuplot}[terminal=tikz, terminaloptions={color providevars a,c}] |
| 567 |
set key box top left |
| 568 |
set key width -0.9 |
| 569 |
set key height 0.25 |
| 570 |
set key spacing 1.25 |
| 571 |
set size 1,0.9 |
| 572 |
set sample 1000 |
| 573 |
set grid xtics lt 0 ls 0 |
| 574 |
set grid ytics lt 0 ls 0 |
| 575 |
set xr [-5:5] |
| 576 |
set yr [-1:1] |
| 577 |
set key opaque |
| 578 |
f(x) = a*x+c |
| 579 |
fit f(x) "SomeValuesForGnuplot.txt" u ($1*5/7):($2/20) via a,c |
| 580 |
set xlabel '$x$-label' |
| 581 |
set ylabel '$y$-label' |
| 582 |
plot sin(x) w l lc -1 t '$\sin(x)$',\ |
| 583 |
cos(x) w l lc 1 t '$\cos(x)$',\ |
| 584 |
tan(x) w l lc 7 t '$\tan(x)$',\ |
| 585 |
tanh(x) w l lc 3 t '$\tanh(x)$',\ |
| 586 |
f(x) t 'fitted function' lc 4,\ |
| 587 |
"SomeValuesForGnuplot.txt" u ($1*5/7):($2/20) w points lc 5 t 'example values' |
| 588 |
\end{gnuplot} |
| 589 |
\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}}$.}% |
| 590 |
\label{pic:tikz}% |
| 591 |
\end{figure}% |
| 592 |
% \iffalse |
| 593 |
%</example> |
| 594 |
% \fi |
| 595 |
% |
| 596 |
% The source code for figure~\ref{pic:tikz} is:\\ |
| 597 |
%~\\ |
| 598 |
%\verb+\begin{figure}%+\\ |
| 599 |
%\verb+ \centering%+\\ |
| 600 |
%\verb+ \begin{gnuplot}[terminal=tikz, terminaloptions={color providevars a,c}]+\\ |
| 601 |
%\verb+ set key box top left+\\ |
| 602 |
%\verb+ set key width -0.9+\\ |
| 603 |
%\verb+ set key height 0.25+\\ |
| 604 |
%\verb+ set key spacing 1.25+\\ |
| 605 |
%\verb+ set sample 1000+\\ |
| 606 |
%\verb+ set grid xtics lt 0 ls 0+\\ |
| 607 |
%\verb+ set grid ytics lt 0 ls 0+\\ |
| 608 |
%\verb+ set xr [-5:5]+\\ |
| 609 |
%\verb+ set yr [-1:1]+\\ |
| 610 |
%\verb+ set key opaque+\\ |
| 611 |
%\verb+ set xlabel '$x$-label'+\\ |
| 612 |
%\verb+ set ylabel '$y$-label'+\\ |
| 613 |
%\verb- f(x) = a*x+c-\\ |
| 614 |
%\verb+ fit f(x) "SomeValuesForGnuplot.txt" u ($1*5/7):($2/20) via a,c+\\ |
| 615 |
%\verb+ plot sin(x) w l lc 2 t '$\sin(x)$',\+\\ |
| 616 |
%\verb+ cos(x) w l lc 4 t '$\cos(x)$',\+\\ |
| 617 |
%\verb+ tan(x) w l lc 6 t '$\tan(x)$',\+\\ |
| 618 |
%\verb+ tanh(x) w l lc 3 t '$\tanh(x)$',\+\\ |
| 619 |
%\verb+ f(x) t 'fitted function' lc 4,\+\\ |
| 620 |
%\verb+ "SomeValuesForGnuplot.txt" u ($1*5/7):($2/20) w points lc 5\+\\ |
| 621 |
%\verb+ t 'example values'+\\ |
| 622 |
%\verb+ \end{gnuplot}+\\ |
| 623 |
%\verb+ \caption{This is a simple example using the \texttt{tikz}-terminal.+\\ |
| 624 |
%\verb- The slope of the fitted function ($a*x+c$) is $a=\num{\gpgetvar{a}}$,-\\ |
| 625 |
%\verb- while its offset is $c=\num{\gpgetvar{c}}$.}%-\\ |
| 626 |
%\verb+ \label{pic:tikz}%+\\ |
| 627 |
%\verb+\end{figure}%+\\ |
| 628 |
% As compiling all pictures everytime can take quite a long time, the \texttt{tikz}-package offers the possibility to externalize the pictures, resulting in a great speedup. |
| 629 |
% An example for Lua\TeX{} is shown below, pictures are not generated if they are up-to-date. |
| 630 |
% In the preamble write:\\ |
| 631 |
% \verb+\usepackage{tikz} +\\ |
| 632 |
% \verb+\usetikzlibrary{external}+\\ |
| 633 |
% \verb+\tikzexternalize[prefix=gnuplottex/] %-- Use the gnuplottex-subfolder. Deactivate+\\ |
| 634 |
%\verb+ %-- the subfolderoption of gnuplottex to use!+\\ |
| 635 |
% \verb+\tikzset{external/system call={lualatex -shell-escape -halt-on-error+\\ |
| 636 |
% \verb+-interaction=batchmode -jobname "\image" "\texsource"}}+\\ |
| 637 |
% \verb+\tikzexternalize+\\ |
| 638 |
% In the document, write e.\,g.:\\ |
| 639 |
% \verb+\begin{figure}%+\\ |
| 640 |
% \verb+ \centering%+\\ |
| 641 |
% \verb+ \tikzsetnextfilename{ThisIsASinus}+\\ |
| 642 |
% \verb+ \begin{tikzpicture}[gnuplot]+\\ |
| 643 |
% \verb+ \begin{gnuplot}[terminal=tikz, terminaloptions=color nopicenvironment]+\\ |
| 644 |
%\verb+ set grid xtics mxtics lt 0 ls 0+\\ |
| 645 |
%\verb+ set grid ytics mytics lt 0 ls 0+\\ |
| 646 |
%\verb+ set key box top left+\\ |
| 647 |
%\verb+ plot sin(x) w l t 'Sinus'+\\ |
| 648 |
% \verb+ \end{gnuplot}+\\ |
| 649 |
% \verb+ \end{tikzpicture}+\\ |
| 650 |
% \verb+ \caption{Captiontext.}%+\\ |
| 651 |
% \verb+ \label{pic:ThisIsASinus}%+\\ |
| 652 |
%\verb+\end{figure}%+\\ |
| 653 |
% |
| 654 |
% \DescribeMacro{pstex,pslatex,pstricks} |
| 655 |
% The \texttt{pstex}- and \texttt{pslatex}-terminal produces unusable output with pdf\TeX. |
| 656 |
% I wasn't able to get any output using the \texttt{pstricks}-terminal with pdf\TeX{} (if you manage to get reasonable output via one of these terminals, please send me an email). |
| 657 |
% |
| 658 |
% \section{Acknowledgements} |
| 659 |
% |
| 660 |
% In addition to the people mentioned in the changelog, I would like to thank |
| 661 |
% Roy Ratcliffe for the suggestion and basic code for the gnuplot terminal |
| 662 |
% specification and handling. Additional thanks to Michel Vo\ss{}uhle for the |
| 663 |
% implementation of \verb=\gnuplotloadfile=. I would also like to thank all the |
| 664 |
% people who sent me bug reports, feature requests and patches -- Philip Vetter, |
| 665 |
% sdaau, Mika Pfl\"uger, Henri Menke, Michel Vo\ss{}kuhle, Udo H\"ofel, Thomas |
| 666 |
% Schmid and Manuel Solano. Gnuplottex wouldn't be what it is today without you. |
| 667 |
% |
| 668 |
% \StopEventually{} |
| 669 |
% |
| 670 |
% \section{Implementation} |
| 671 |
% |
| 672 |
% \subsection{Initialization} |
| 673 |
% \begin{macrocode} |
| 674 |
\newif\ifShellEscape |
| 675 |
\newif\ifmiktex \miktexfalse |
| 676 |
\newif\ifusesiunitx |
| 677 |
\newif\ifcleanup |
| 678 |
\newif\ifusesubfolder |
| 679 |
|
| 680 |
\newwrite\verbatim@out |
| 681 |
|
| 682 |
\DeclareOption{shell}{\ShellEscapetrue} |
| 683 |
\DeclareOption{noshell}{\ShellEscapefalse} |
| 684 |
\DeclareOption{miktex}{\global\miktextrue} |
| 685 |
\DeclareOption{siunitx}{\usesiunitxtrue} |
| 686 |
\DeclareOption{cleanup}{\cleanuptrue} |
| 687 |
\DeclareOption{subfolder}{\usesubfoldertrue} |
| 688 |
|
| 689 |
\@ifundefined{gnuplotexe}{\def\gnuplotexe{gnuplot}}{} |
| 690 |
|
| 691 |
\ExecuteOptions{shell} |
| 692 |
\ProcessOptions\relax |
| 693 |
%% test if shell escape really works |
| 694 |
\ifShellEscape |
| 695 |
\def\tmpfile{w18-test-\the\year\the\month\the\day\the\time.tex} |
| 696 |
\ifmiktex |
| 697 |
\immediate\write18{echo t > "\tmpfile"} |
| 698 |
\else |
| 699 |
\immediate\write18{touch \tmpfile} |
| 700 |
\fi |
| 701 |
\ifmiktex |
| 702 |
\IfFileExists{\tmpfile}{\ShellEscapetrue}{\ShellEscapefalse} |
| 703 |
\immediate\write18{del "\tmpfile"} |
| 704 |
\else |
| 705 |
\IfFileExists{\tmpfile}{\ShellEscapetrue}{\ShellEscapefalse} |
| 706 |
\immediate\write18{rm -f \tmpfile} |
| 707 |
\immediate\write18{rm -f "\jobname.gnuploterrors"} |
| 708 |
\fi |
| 709 |
\fi |
| 710 |
|
| 711 |
\ifusesubfolder |
| 712 |
\def\subfolder{gnuplottex} |
| 713 |
\ifShellEscape |
| 714 |
\ifmiktex |
| 715 |
\immediate\write18{mkdir \subfolder} |
| 716 |
\immediate\write18{echo test > "\subfolder/\tmpfile"} |
| 717 |
\else |
| 718 |
\immediate\write18{mkdir -p "\subfolder"} |
| 719 |
\immediate\write18{touch "\subfolder/\tmpfile"} |
| 720 |
\fi |
| 721 |
\IfFileExists{gnuplottex/\tmpfile}{ |
| 722 |
\ifmiktex |
| 723 |
\immediate\write18{del "\subfolder\@backslashchar\tmpfile"} |
| 724 |
\else |
| 725 |
\immediate\write18{rm -f "\subfolder/\tmpfile"} |
| 726 |
\fi |
| 727 |
}{ |
| 728 |
\PackageWarningNoLine{gnuplottex} |
| 729 |
{Creation of subfolder failed.\MessageBreak |
| 730 |
You'll need to create the folder yourself} |
| 731 |
\def\subfolder{} |
| 732 |
} |
| 733 |
\fi |
| 734 |
\else |
| 735 |
\def\subfolder{.} |
| 736 |
\fi |
| 737 |
|
| 738 |
|
| 739 |
\ifShellEscape |
| 740 |
\PackageInfo{gnuplottex} |
| 741 |
{Automatically converting gnuplot files} |
| 742 |
\else |
| 743 |
\PackageWarningNoLine{gnuplottex} |
| 744 |
{Shell escape not enabled.\MessageBreak |
| 745 |
You'll need to convert the graphs yourself} |
| 746 |
\fi |
| 747 |
\newcounter{fignum} |
| 748 |
% \end{macrocode} |
| 749 |
% |
| 750 |
% \subsection{\texttt{.gnuplot} write out} |
| 751 |
% \begin{macrocode} |
| 752 |
\def\figname{\jobname-gnuplottex-fig\thefignum} |
| 753 |
|
| 754 |
\def\usesiunitxingnuplot{\immediate\write\verbatim@out{set format '\@backslashchar num{\@percentchar g}'}} |
| 755 |
|
| 756 |
\def\gnuplotverbatimwrite#1{% |
| 757 |
\def\BeforeStream |
| 758 |
{\message{Opening gnuplot stream #1}% |
| 759 |
\immediate\write\verbatim@out{\string set terminal \gnuplotterminal \gnuplotterminaloptions}% |
| 760 |
\immediate\write\verbatim@out{\string set output '\subfolder/\figname.\gnuplottexextension{\gnuplotterminal}'}% |
| 761 |
\ifusesiunitx |
| 762 |
\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.}} |
| 763 |
\else |
| 764 |
\relax |
| 765 |
\fi |
| 766 |
}% |
| 767 |
\@bsphack% |
| 768 |
\immediate\openout \verbatim@out #1% |
| 769 |
\BeforeStream% |
| 770 |
\let\do\@makeother\dospecials% |
| 771 |
\catcode`\^^M\active |
| 772 |
\def\verbatim@processline{% |
| 773 |
\immediate\write\verbatim@out |
| 774 |
{\the\verbatim@line}}% |
| 775 |
\verbatim@start} |
| 776 |
\def\endgnuplotverbatimwrite{% |
| 777 |
\immediate\closeout\verbatim@out |
| 778 |
\@esphack |
| 779 |
\catcode`\\0 |
| 780 |
\catcode`\{1 |
| 781 |
\catcode`\}2 |
| 782 |
\catcode`\$3 |
| 783 |
\catcode`\&4 |
| 784 |
\catcode`\^^M5 |
| 785 |
\catcode`\#6 |
| 786 |
\catcode`\^7 |
| 787 |
\catcode`\_8 |
| 788 |
\catcode`\ 10 |
| 789 |
\catcode`\%14} |
| 790 |
% \end{macrocode} |
| 791 |
% |
| 792 |
% \subsection{Environment definition} |
| 793 |
% \begin{macrocode} |
| 794 |
\def\gnuplottexextension@latex{\string tex} |
| 795 |
\def\gnuplottexextension@epslatex{\string tex} |
| 796 |
\def\gnuplottexextension@cairolatex{\string tex} |
| 797 |
\def\gnuplottexextension@eepic{\string tex} |
| 798 |
\def\gnuplottexextension@pstricks{\string tex} |
| 799 |
\def\gnuplottexextension@pslatex{\string tex} |
| 800 |
\def\gnuplottexextension@pstex{\string tex} |
| 801 |
\def\gnuplottexextension@emtex{\string tex} |
| 802 |
\def\gnuplottexextension@jpeg{\string jpg} |
| 803 |
\def\gnuplottexextension@tikz{\string tex} |
| 804 |
\def\gnuplottexextension@lua{\string tex} |
| 805 |
\def\gnuplottexextension#1{\@ifundefined{gnuplottexextension@#1}{#1}{\csname gnuplottexextension@#1\endcsname}} |
| 806 |
\define@key{pic}{scale}[1]{\def\gnuplotscale{#1}} |
| 807 |
\define@key{pic}{terminal}[latex]{\def\gnuplotterminal{#1}} |
| 808 |
\define@key{pic}{terminaloptions}{\def\gnuplotterminaloptions{ #1}} |
| 809 |
\newenvironment{gnuplot}[1][]{\stepcounter{fignum}% |
| 810 |
\def\gnuplotterminal{latex}%% |
| 811 |
\def\gnuplotterminaloptions{}%% |
| 812 |
\def\gnuplotscale{1}%% |
| 813 |
\setkeys{pic}{#1}%% |
| 814 |
\xdef\gnuplotCutFile{\subfolder/\figname.gnuplot}%% |
| 815 |
\gnuplotverbatimwrite{\gnuplotCutFile}} |
| 816 |
{\endgnuplotverbatimwrite% |
| 817 |
\gnuplotgraphicsprocess% |
| 818 |
\gnuplotgraphicsinclude} |
| 819 |
% \end{macrocode} |
| 820 |
% |
| 821 |
% \subsection{\texttt{.gnuplot} file processing} |
| 822 |
% \begin{macrocode} |
| 823 |
\def\extension{\gnuplottexextension{\gnuplotterminal}} |
| 824 |
\long\gdef\gnuplotgraphicsprocess{% |
| 825 |
\ifShellEscape% |
| 826 |
\IfFileExists{\subfolder/\figname.gnuplot}{% |
| 827 |
\ifmiktex |
| 828 |
\immediate\write18{\gnuplotexe\space \subfolder/\figname.gnuplot}% |
| 829 |
\else |
| 830 |
\immediate\write18{\gnuplotexe\space \subfolder/\figname.gnuplot\space 2>>\jobname.gnuploterrors}% |
| 831 |
\fi% |
| 832 |
\IfFileExists{\subfolder/\figname.\extension}{% |
| 833 |
\PackageInfo{gnuplottex}{\subfolder/\figname.gnuplot converted}% |
| 834 |
\ifcleanup |
| 835 |
\ifmiktex |
| 836 |
\immediate\write18{del "\subfolder/\figname.gnuplot"}% |
| 837 |
\else |
| 838 |
\immediate\write18{rm -f "\subfolder/\figname.gnuplot"}% |
| 839 |
\fi% |
| 840 |
\fi% |
| 841 |
} |
| 842 |
{\PackageWarningNoLine{gnuplottex} |
| 843 |
{Conversion of \subfolder/\figname.gnuplot failed}}}{}% |
| 844 |
\fi} |
| 845 |
\long\def\gnuploterrors@eatpar#1#2\@nil{\def\gnuploterrors@{#2}} |
| 846 |
\AtEndDocument{% |
| 847 |
\ifmiktex |
| 848 |
\else |
| 849 |
\IfFileExists{\jobname.gnuploterrors}{% |
| 850 |
\CatchFileDef\gnuploterrors@{\jobname.gnuploterrors}{\endlinechar=`^^J \catcode`\ =12 }% |
| 851 |
\expandafter\gnuploterrors@eatpar\gnuploterrors@\@nil |
| 852 |
\ifx\gnuploterrors@\@empty\else |
| 853 |
\PackageWarningNoLine{gnuplottex}{Gnuplot execution produced errors:^^J% |
| 854 |
\detokenize\expandafter{\gnuploterrors@}}% |
| 855 |
\fi |
| 856 |
}{} |
| 857 |
\fi |
| 858 |
} |
| 859 |
% \end{macrocode} |
| 860 |
% |
| 861 |
% \subsection{Graph inclusion} |
| 862 |
% \begin{macrocode} |
| 863 |
\long\gdef\gnuplotgraphicsinclude{% |
| 864 |
\IfFileExists{\subfolder/\figname.\extension}{% |
| 865 |
\ifthenelse{\equal{\extension}{\string tex}} |
| 866 |
{\scalebox{\gnuplotscale}{\input{\subfolder/\figname.\extension}}} |
| 867 |
{\includegraphics[scale=\gnuplotscale]{\subfolder/\figname.\extension}} |
| 868 |
} |
| 869 |
{\PackageWarningNoLine{gnuplottex} |
| 870 |
{Please convert \subfolder/\figname.gnuplot manually}} |
| 871 |
} |
| 872 |
% \end{macrocode} |
| 873 |
% |
| 874 |
% \subsection{\texttt{.gnuplot} file processing} |
| 875 |
% \begin{macrocode} |
| 876 |
\newcommand{\gnuplotloadfilewrite}[2]{% |
| 877 |
\immediate\openout \verbatim@out #1% |
| 878 |
\message{Opening gnuplot stream #1}% |
| 879 |
\immediate\write\verbatim@out{\string set terminal \gnuplotterminal \gnuplotterminaloptions}% |
| 880 |
\immediate\write\verbatim@out{\string set output '\subfolder/\figname.\gnuplottexextension{\gnuplotterminal}'}% |
| 881 |
\ifusesiunitx |
| 882 |
\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.}} |
| 883 |
\else |
| 884 |
\relax |
| 885 |
\fi |
| 886 |
\ifusesiunitx |
| 887 |
{\escapechar=-1\edef\percentforgnuplot{\string\%} |
| 888 |
\escapechar=-1\edef\backslashforgnuplot{\string\\} |
| 889 |
\immediate\write\verbatim@out{set format '\backslashforgnuplot num{\percentforgnuplot g}'}} |
| 890 |
\else |
| 891 |
\relax |
| 892 |
\fi |
| 893 |
\immediate\write\verbatim@out{\string load '#2'}% |
| 894 |
\immediate\closeout\verbatim@out% |
| 895 |
} |
| 896 |
|
| 897 |
\newcommand{\gnuplotloadfile}[2][]{ |
| 898 |
\stepcounter{fignum}% |
| 899 |
\def\gnuplotterminal{latex} |
| 900 |
\def\gnuplotterminaloptions{} |
| 901 |
\def\gnuplotscale{1} |
| 902 |
\setkeys{pic}{#1} |
| 903 |
\xdef\gnuplotCutFile{\subfolder/\figname.gnuplot} |
| 904 |
\gnuplotloadfilewrite{\gnuplotCutFile}{#2} |
| 905 |
\gnuplotgraphicsprocess% |
| 906 |
\gnuplotgraphicsinclude |
| 907 |
} |
| 908 |
% \end{macrocode} |
| 909 |
% |
| 910 |
% \Finale |
| 911 |
\endinput |