% \iffalse meta-comment
%<*internal>
\iffalse
%</internal>
%<*readme>
simplot --- LaTeX inline simplot graphics
E-mail: wybodekker@me.com
Released under the LaTeX Project Public License v1.3c or later
See http://www.latex-project.org/lppl.txt
----------------------------------------------------------------
LaTeX inline simplot graphics

Short description:
This package provides the \simplot macro, which lets you use inline Simplot
commands to generate graphics. Simplot is an interpreter program to
generate vector graphics and is described in the documentation. The
descriptions for the individual commands can be found in the documentation
of the simplot library, see:
http://www.dekkerdocumenten.nl/simplot/program.shtml

Full documentation:
https://bitbucket.org/wybodekker/isodoc/downloads/simplot.pdf

Installation:
Execute the inst script with the --help option for more information.

%</readme>
%<*internal>
\fi
\def\nameofplainTeX{plain}
\ifx\fmtname\nameofplainTeX\else
  \expandafter\begingroup
\fi
%</internal>
%<*install>
\input docstrip.tex
\keepsilent
\askforoverwritefalse
\preamble
----------------------------------------------------------------
simplot --- LaTeX inline simplot graphics
E-mail: wybodekker@me.com
Released under the LaTeX Project Public License v1.3c or later
See http://www.latex-project.org/lppl.txt
----------------------------------------------------------------

\endpreamble
\postamble

Copyright (C) 2011 by Wybo Dekker <wybodekker@me.com>

This work may be distributed and/or modified under the
conditions of the LaTeX Project Public License (LPPL).
The latest version of this license is in:

http://www.latex-project.org/lppl.txt

This work consists of the self-extracting file simplot.dtx
To create the style file and its documentation, just run:

pdflatex simplot.dtx
\endpostamble
\usedir{tex/latex/demopkg}
\generate{
  \file{\jobname.sty}{\from{\jobname.dtx}{package}}
}
%</install>
%<install>\endbatchfile
%<*internal>
\usedir{source/latex/simplot}
\generate{
  \file{\jobname.ins}{\from{\jobname.dtx}{install}}
}
\nopreamble\nopostamble
\usedir{doc/latex/simplot}
\generate{
  \file{README}{\from{\jobname.dtx}{readme}}
}
\ifx\fmtname\nameofplainTeX
  \expandafter\endbatchfile
\else
  \expandafter\endgroup
\fi
%</internal>
%<*package>
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{simplot}
   [2014/07/21 v1.02 simplot package for LaTeX inline simplot graphics]
%</package>
%<*driver>
\documentclass{ltxdoc}
\usepackage[T1]{fontenc}
\usepackage{charter}
\usepackage{simplot}
\usepackage[numbered]{hypdoc}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\begin{document}
  \DocInput{\jobname.dtx}
\end{document}
%</driver>
% \fi
% 
% \GetFileInfo{\jobname.sty}
% \DoNotIndex{
% \advance, \jobname, \global, \newcommand,
% \newcount, \the, \immediate,
% \includegraphics, \RequirePackage, \write
% }
%
%\title{^^A
%  \textsf{simplot} --- LaTeX inline simplot graphics\thanks{^^A
%    This file describes version \fileversion, last revised \filedate.^^A
%  }^^A
%}
%\author{^^A
%  Wybo Dekker\thanks{E-mail: wybodekker@me.com}^^A
%}
%\date{Released \filedate}
%
%\maketitle
%
%
% \section{Introduction}
%
% This package provides the |\simplot| macro, which lets you use inline Simplot
% commands to generate graphics. Simplot is an interpreter program to generate
% vector graphics and is described in the
% \href{http://www.dekkerdocumenten.nl/simplot/program.shtml}{documentation}.
% \noindent The descriptions for the individual commands can be found in the
% \href{http://www.dekkerdocumenten.nl/simplot/index.shtml}{documentation of the
% simplot library}.
%
% \section{Usage}
%
% In your preamble, load the simplot style with |\usepackage{simplot}|.
% In your document you can then generate a graphic with the |\simplot| macro.
% For example, to generate a circle with a radius of 5 mm you can say:\\
% |\simplot{20 20 10 10 "" "" plarc 0 0 5 0 360 DOWN}|\\
% This generates a plotting field of 20x20 mm with the origin in the middle
% (10,10). The "" "" let the font and the altenate font at their defaults (Adobe Times
% and Symbol) and the arc is plotted with its center at the origin (0,0), a
% radius of 5 mm, starting at 0 degrees and continuing over 360 degrees.
%
% Since the macro compiles the Simplot commands on the fly, you must either, in
% your |texmf.cnf|, enable the |\write18| command, or you must compile you
% document with the |-shell-escape| option.
%
% \DescribeMacro{\simplot}
% The |\simplot|  macro has one argument, consisting of all Simplot commands generating a
% graphic, with one exception: normally a Simplot script starts with a call to
% |plinit|:
% \\[2ex]
% |plinit PDF filename pagewidth pageheight x-origin y-origin font alt font|
% \\[2ex]
% Here, the first three elements: |plinit PDF filename| are left out. This is
% because the filename of the \textsc{pdf} graphic is automatically genenrated.
% The first will be named |\jobname_1.pdf|, the second |\jobname_2.pdf|, and so
% on. So when your \TeX\ source is named |test.tex|, the graphics will be called
% |test_1.pdf|, |test_2.pdf|, and so on.
%
% \section{Examples}
% Here is a simple example, printing a text with a arrow under it:
%
% \begin{verbatim}
% 
% \documentclass{article}
% \usepackage[papersize={100mm,100mm},margin=5mm]{geometry}
% \usepackage{simplot}
% \begin{document}\newfont{\HUGE}{txb at 40pt}
% \center\HUGE
% \quad Entrance\\
% \simplot{
%   90 20 0 0 "" ""
%   plset PENDIA 2
%   plcolor .8 0 0
%   plu 75 18 pld 20 18
%   plarrow -15 -10 10 15 25 0 0 0 0 ""
% }
% \end{document}
%
% \end{verbatim}
%
% \noindent And this is how it looks:
% \newfont{\HUGE}{txb at 40pt}
% \begin{center}\HUGE
% \quad Entrance\\
% \simplot{
%   190 20 0 0 "" ""
%   plset PENDIA 2
%   plcolor .8 0 0
%   plu 75 18 pld 20 18
%   plarrow -15 -10 10 15 25 0 0 0 0 ""
% }
% \end{center}
% Here is another example:
% \begin{verbatim}
% 
% \documentclass{article}
% \usepackage[papersize={100mm,100mm},margin=5mm]{geometry}
% \usepackage{simplot}
% \begin{document}
% 
% \simplot{
%   90 20 0 0 "" ""
%   plset PENDIA 2
%   plu 75 18 pld 20 18
%   plarrow -15 -10 10 15 25 0 0 0 0 ""
% }
% \end{document}
%
% \end{verbatim}
%
% \noindent which produces just a picture:
%
% \simplot{
%  A4 50 50 "" ""
%  plrdxy 5 0 0 2 8 3 100 4 1 5 0
%  plaxfit 5 20 50 50 xtext ytext text
%  plpline 5 "" DOWN
%  plframe 5 3
% }
% \changes{v1.01}{2014/04/20}{
%  Added README, standardized inst script
% }
%
%\StopEventually{^^A
%  \PrintChanges
%}
%
%    \begin{macrocode}
%    \end{macrocode}
%
% \section{Implementation}
%
% A counter, |\simplotpicno|, is needed to name the subsequent \textsc{pdf}
% graphics; it start with 1:
%    \begin{macrocode}
%<*package>
\newcount\simplotpicno\simplotpicno=1
%    \end{macrocode}
% 
% \begin{macro}{\simplot}
% The |\simplot| macro takes its argument, prefixes it with the missing 
% |plinit PDF filename| part that makes it a full Simplot script, and pipes the
% resulting string into the |simplot| program, which generates the \textsc{pdf}
% graphic.  That graphic, finally, is included with |\includegraphics|:
%    \begin{macrocode}
\RequirePackage{graphicx}
% \changes{v1.02}{2014/07/21}{
%  force space behind filename
% }
\newcommand{\simplot}[1]{\immediate\write18{%
  echo 'plinit PDF \jobname_\the\simplotpicno\space #1'|simplot}
  \includegraphics{\jobname_\the\simplotpicno}
  \global\advance\simplotpicno by 1
}
%    \end{macrocode}
% \end{macro}
%    \begin{macrocode}
%</package>
%    \end{macrocode}
%\Finale
