diff options
author | Karl Berry <karl@freefriends.org> | 2011-03-11 23:57:57 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2011-03-11 23:57:57 +0000 |
commit | 9860f8848b76b157121e0dd83ed89a32858bf598 (patch) | |
tree | 8ba000143965668d761ecc9203469906af7f7456 /Master/texmf-dist/tex/latex | |
parent | b8a676e6a9163cce8c8630c430b5501fe16562bd (diff) |
new latex/metapost package gmp (10mar11)
git-svn-id: svn://tug.org/texlive/trunk@21691 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex')
-rw-r--r-- | Master/texmf-dist/tex/latex/gmp/gmp.sty | 329 |
1 files changed, 329 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/gmp/gmp.sty b/Master/texmf-dist/tex/latex/gmp/gmp.sty new file mode 100644 index 00000000000..b0afa6fdad3 --- /dev/null +++ b/Master/texmf-dist/tex/latex/gmp/gmp.sty @@ -0,0 +1,329 @@ +%% +%% This is file `gmp.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% gmp.dtx (with options: `package') +%% +%% This is a generated file. +%% +%% Copyright (C) 2011 by Enrico Gregorio +%% <Enrico dot Gregorio at univr dot it> +%% ------------------------------------------------------- +%% +%% This work may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either +%% version 1.3c of this license or (at your option) any +%% later version. The latest version of this license is in +%% http://www.latex-project.org/lppl.txt +%% and version 1.3 or later is part of all distributions +%% of LaTeX version 2005/12/01 or later. +%% +%% This work has the LPPL maintenance status `maintained'. +%% +%% The Current Maintainer of this work is Enrico Gregorio. +%% +%% This work consists of the files +%% gmp.dtx +%% gmp.ins +%% and the derived file gmp.sty. +%% +\NeedsTeXFormat{LaTeX2e}[2008/04/05] +\ProvidesPackage{gmp} + [2011/03/10 v1.0 Integrate MetaPost with LaTeX (EG)] +%%macro arguments: +%%#1 = desired width +%%#2 = desired height +%%#3 = pen thickness (relative) +%%#4 = line color +%%#5 = dot color +\@ifundefined{eTeXversion}{% + \PackageError{gmp}{This package requires a e-TeX extensions} + {The gmp package requires a modern TeX engine, please upgrade}% + \endinput}{} +\RequirePackage{xkeyval}[2005/01/30] + +\newif\ifgmp@latex % true if always using latex for mpx +\newif\ifgmp@locallatex % true if using latex for mpx for a + % single figure + +\newif\ifgmp@nogen % true if we are not generating the mps files +\newif\ifgmp@nowrite % true if we are not writing the mp files +\newif\ifgmp@warn % true if we are issuing the final message + +\DeclareOptionX<ggmp>{tex}{\def\gmp@mpxprogram{tex}% + \gmp@latexfalse\gmp@locallatexfalse} +\DeclareOptionX<ggmp>{latex}{\def\gmp@mpxprogram{latex}% + \gmp@latextrue\gmp@locallatextrue} + +\DeclareOptionX<ggmp>{noshellescape}{\gmp@nogentrue} +\DeclareOptionX<ggmp>{shellescape}{\gmp@nogenfalse} + +\DeclareOptionX<ggmp>{nowrite}{\gmp@nowritetrue} +\DeclareOptionX<ggmp>{write}{\gmp@nowritefalse} + +\DeclareOptionX<ggmp>{envname}{\def\gmp@envname{#1}} +\DeclareOptionX<ggmp>{extension}{\def\gmp@ext{#1}} + +\def\gmp@preoptions{} +\DeclareOptionX<ggmp>{everymp}{\edef\gmp@preoptions{\gmp@preoptions^^J#1}} + +\DeclareOptionX<ggmp>{clean}{\def\gmp@clean{#1}} + +\DeclareOptionX<ggmp>{rmcommand}{\def\gmp@remove{#1}} +\DeclareOptionX<ggmp>{postrmcommand}{\def\gmp@postremove{#1}} + +\def\gmp@jobname{\jobname} +\ExecuteOptionsX<ggmp>{tex,noshellescape,write,clean=none} +\ExecuteOptionsX<ggmp>{envname=mpost,extension=+mp, + rmcommand=rm -f,postrmcommand={}} +\ProcessOptionsX<ggmp>\relax +\RequirePackage{graphicx} +\RequirePackage{ifpdf} +\RequirePackage{ifxetex} +\RequirePackage{environ} +\ifxetex + \let\gmp@shellescape\shellescape + \def\gmp@preoptions{prologues:=3;^^J} +\else + \ifdefined\pdfshellescape % (pdf)latex + \let\gmp@shellescape\pdfshellescape + \else % lualatex + \chardef\gmp@shellescape=\z@ + \gmp@nogentrue + \fi +\fi +\def\gmp@msgdisallowed{\PackageWarningNoLine{gmp}{Compilation and + writing of MetaPost files has been\MessageBreak disallowed by the + `nowrite' option}\gdef\gmp@nemessage{}} +\def\gmp@msgnonexistent{\PackageWarning{gmp}{Non existent MetaPost + file requested}\ifgmp@warn\else\global\gmp@warntrue\fi} +\def\gmp@msgrequestx{\PackageWarningNoLine{gmp}{The MetaPost file you + requested does not exist,\MessageBreak perhaps by a compilation + error}} +\def\gmp@msgremember{\PackageWarningNoLine{gmp}{Remember to run `sh + \gmp@jobname\gmp@ext.sh' and rerun (pdf)LaTeX}} +\def\gmp@msgensure{% + \PackageWarningNoLine{gmp}{Ensure that you have enabled the shell + escape feature, or\MessageBreak you can be in trouble. The + available MetaPost generated\MessageBreak files will be used + anyway. Use option `nowrite' if they\MessageBreak are already + in final form}% + \let\gmp@message\@gobble + \let\gmp@writexviii\@gobble + \def\gmp@openout##1##2\@nil{}% + \let\gmp@write\@gobbletwo + \let\gmp@closeout\@gobble} +\let\gmp@message\message +\def\gmp@writexviii{\immediate\write18 } +\def\gmp@openout#1#2\@nil{\immediate\openout#1#2} +\def\gmp@write{\immediate\write} +\def\gmp@closeout{\immediate\closeout} +\def\gmp@setupmacros{% +\ifgmp@nowrite + \let\gmp@nemessage\gmp@msgdisallowed +\else + \ifgmp@nogen + \let\gmp@nemessage\gmp@msgnonexistent + \def\gmp@command{% + mpost \ifx\gmp@mpmem\empty\else\space\gmp@mpmem\space\fi}% + \newwrite\gmp@shellout + \immediate\openout\gmp@shellout=\gmp@jobname\gmp@ext.sh% + \immediate\write\gmp@shellout{\string##!/bin/sh}% + \def\gmp@shellcommand##1{\immediate\write\gmp@shellout{##1}}% + \AtEndDocument{\ifgmp@warn\gmp@msgremember\gmp@warnfalse\fi}% + \else + \let\gmp@nemessage\gmp@msgrequestx + \ifnum\gmp@shellescape=\@ne + \def\gmp@command{% + mpost -interaction=nonstopmode % + \ifx\gmp@mpmem\empty\else\space\gmp@mpmem\space\fi}% + \def\gmp@shellcommand##1{% + \gmp@message{^^J(gmp) Doing external command^^J(gmp) \string"}% + \gmp@writexviii{echo ##1'\string"'}\gmp@writexviii{##1}% + }% + \else + \gmp@msgensure\let\gmp@shellcommand\@gobble + \fi + \fi +\fi +} +\gmp@setupmacros +\def\gmpoptions#1{\setkeys{ggmp}{#1}\gmp@setupmacros} +\@onlypreamble\gmpoptions +\def\gmp@latexpreamble{%^^J% + \gmp@percent\string&latex^^J% + \string\documentclass[1\@ptsize pt]{article}^^J% + \ifx\empty\gmp@packages\else\the\gmp@packages^^J\fi% + \ifx\empty\gmp@commands\else\the\gmp@commands^^J\fi% + \string\begin{document}^^J} +\newcommand\usempxclass[2][]{% + \def\gmp@latexpreamble{^^J% + \gmp@percent\string&latex^^J% + \string\documentclass[#1]{#2}^^J% + \ifx\empty\gmp@packages\else\the\gmp@packages^^J\fi% + \ifx\empty\gmp@commands\else\the\gmp@commands^^J\fi% + \string\begin{document}^^J}} +\newtoks\gmp@packages +\newcommand\usempxpackage[2][]{% + \gmp@packages=\expandafter{\the\gmp@packages^^J% + \usepackage[#1]{#2}}} +\newcommand\resetmpxpackages{\gmp@packages={}} +\newtoks\gmp@commands +\newcommand\mpxcommands[1]{% + \gmp@commands=\expandafter{\the\gmp@commands^^J% + #1}} +\newcommand\resetmpxcommands{\gmp@commands={}} +\def\mpdim#1{ begingroup \the\dimexpr#1\relax\space endgroup } +\newwrite\gmp@out +\newcounter{gmp@count} +\AtEndDocument{% + \refstepcounter{gmp@count}% + \label{gmp@finallabel}% +} +\newenvironment{\gmp@envname}[1][] + {\@bsphack + \global\gmp@usefalse + \refstepcounter{gmp@count}\label{gmp@label@\thegmp@count}% + \bgroup + \edef\gmp@number{\thegmp@count}% + \gmp@grab{#1}} + {\@esphack} +\def\gmp@writeunex#1{\begingroup + \edef\x{\endgroup\noexpand\begin{\gmp@envname}[\the\toks@]% + \unexpanded{\unexpanded{#1}}\noexpand\end{\gmp@envname}}\x} +\newenvironment{\gmp@envname*}[1][] + {\toks@{#1}\Collect@Body\gmp@writeunex}{} +\def\gmp@fourdigits#1{% + \ifnum#1<10 0\fi + \ifnum#1<100 0\fi + \ifnum#1<1000 0\fi\number #1} +\def\gmp@not@a@name@{@not@a@name@} +\def\gmp@choosetex{\gmp@locallatexfalse} +\def\gmp@chooselatex{\gmp@locallatextrue} +\def\gmp@doiflatex#1{\ifgmp@latex#1\else\ifgmp@locallatex#1\fi\fi} +\def\gmp@mpmem{} +\newif\ifgmp@use +\define@key{gmp}{name}[@not@a@name@]{% + \def\gmp@thisname{#1}% + \expandafter\xdef\csname gmp@fig#1\endcsname + {\gmp@fourdigits{\gmp@number}}} +\define@key{gmp}{use}[true]{\global\csname gmp@use#1\endcsname} +\define@key{gmp}{mpmem}{\def\gmp@mpmem{-mem #1}} +\define@key{gmp}{mpsettings}{\edef\gmp@preoptions{\gmp@preoptions^^J#1}} +\define@key{gmp}{mpxcommands}{% + \gmp@commands=\expandafter{\the\gmp@commands^^J#1}} +\define@key{gmp}{mpxprogram}{% + \def\gmp@mpxprogram{#1}% + \csname gmp@choose#1\endcsname} +\define@key{gmp}{runs}{\chardef\gmp@runs=#1\relax} +\def\gmp@grab#1{% + \setkeys{gmp}{name}% + \setkeys{gmp}{runs=1}% + \setkeys{gmp}{#1}% + \ifx\gmp@thisname\gmp@not@a@name@ + \global\gmp@usetrue + \fi + \gmp@setup\gmp@innermpost} +\begingroup\@makeother\%\def\x{\endgroup\def\gmp@percent{%}}\x +\def\gmp@activesc{\catcode`\;=\active + \begingroup\lccode`\~=`\; + \lowercase{\endgroup\edef~}{\string;^^J}} +\def\gmp@otherchars{\do\!\do\=\do\:\do\"\do\?\do\'\do\`\do\|} +\def\gmp@setup{% + \let\do\@makeother\gmp@otherchars\newlinechar=`\^^J + \gmp@activesc + \def\par{^^J}% + \ifgmp@nowrite\else + \edef\@temp{\gmp@jobname\gmp@ext\gmp@fourdigits{\gmp@number}.mp}% + \expandafter\gmp@openout\expandafter\gmp@out\@temp\@nil + \gmp@write\gmp@out{% + \gmp@percent\gmp@percent\space + Do not edit, this file has been generated^^J% + \gmp@percent\gmp@percent\space + automatically by \jobname.tex via gmp.sty^^J^^J% + \gmp@doiflatex{verbatimtex\gmp@latexpreamble etex;^^J}% + \ifx\empty\gmp@preoptions\else\gmp@preoptions^^J\fi% + outputtemplate:= "\gmp@percent j.mps";^^J% + beginfig(\gmp@number);%^^J% + }% + \fi} +\long\def\gmp@innermpost#1\end#2{% + \ifgmp@nowrite\else + \gmp@write\gmp@out{% + #1^^Jendfig;^^Jend.% + \gmp@doiflatex{^^Jverbatimtex^^J\string\end{document}^^Jetex}}% + \gmp@closeout\gmp@out + \count@=\gmp@runs + \loop\ifnum\count@>\z@ + \gmp@shellcommand{\gmp@command\space + -tex=\gmp@mpxprogram\space\gmp@jobname\gmp@ext + \gmp@fourdigits{\gmp@number}}% + \advance\count@\m@ne + \repeat + \ifxetex + \gmp@shellcommand{epstopdf --hires \gmp@jobname\gmp@ext + \gmp@fourdigits{\gmp@number}.mps}% + \fi + \fi + \egroup + \end{#2}\ifgmp@use + \gmp@usempost{\thegmp@count}\fi} +\ifxetex + \def\gmp@usempost#1{% + \edef\gmp@thempsfile{\gmp@jobname\gmp@ext\gmp@fourdigits{#1}}% + \IfFileExists{\gmp@thempsfile.pdf}% + {\includegraphics{\gmp@thempsfile.pdf}}% + {\gmp@nemessage\gmp@box}} + \newcommand\usempost[2][]{% + \IfFileExists{\gmp@jobname\gmp@ext\csname gmp@fig#2\endcsname.pdf}% + {\includegraphics[#1] + {\gmp@jobname\gmp@ext\csname gmp@fig#2\endcsname.pdf}}% + {\gmp@nemessage\gmp@box}} +\else + \def\gmp@usempost#1{% + \edef\gmp@thempsfile{\gmp@jobname\gmp@ext\gmp@fourdigits{#1}}% + \IfFileExists{\gmp@thempsfile.mps}% + {\includegraphics[hiresbb]{\gmp@thempsfile.mps}}% + {\gmp@nemessage\gmp@box}} +\newcommand\usempost[2][]{% + \IfFileExists{\gmp@jobname\gmp@ext\csname gmp@fig#2\endcsname.mps}% + {\includegraphics[hiresbb,#1] + {\gmp@jobname\gmp@ext\csname gmp@fig#2\endcsname.mps}}% + {\gmp@nemessage\gmp@box}} +\fi +\def\gmp@box{\fbox{\@ifundefined{color}{}{\color{red}}MP}} +\AtEndDocument{% + \@ifundefined{gmp@doclean@\gmp@clean} + {\expandafter\gmp@badcleaning\expandafter{\gmp@clean}} + {\@nameuse{gmp@doclean@\gmp@clean}}} +\def\gmp@badcleaning#1{\PackageWarningNoLine{gmp}{% + Wrong cleaning option `clean=#1'; `clean=none' used}} +\def\gmp@doclean@none{} +\def\gmp@doclean@aux{% + \gmp@shellcommand{\gmp@remove\space + \jobname\gmp@ext*.log\space\gmp@postremove}% + \gmp@shellcommand{\gmp@remove\space + \jobname\gmp@ext*.mpx\space\gmp@postremove}% + \gmp@shellcommand{\gmp@remove\space + \jobname\gmp@ext*.mpo\space\gmp@postremove}% + } +\def\gmp@doclean@mp{% + \gmp@shellcommand{\gmp@remove\space + \jobname\gmp@ext*.log\space\gmp@postremove}% + \gmp@shellcommand{\gmp@remove\space + \jobname\gmp@ext*.mpx\space\gmp@postremove}% + \gmp@shellcommand{\gmp@remove\space + \jobname\gmp@ext*.mpo\space\gmp@postremove}% + \gmp@shellcommand{\gmp@remove\space + \jobname\gmp@ext*.mp\space\gmp@postremove}% + \ifxetex + \gmp@shellcommand{\gmp@remove\space + \jobname\gmp@ext*.mps\space\gmp@postremove}% + \fi} +\long\def\verbatimtex#1etex{verbatimtex \unexpanded{#1} etex} +\long\def\btex#1etex{btex \unexpanded{#1} etex} +\endinput +%% +%% End of file `gmp.sty'. |