diff options
author | Karl Berry <karl@freefriends.org> | 2011-05-28 16:52:13 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2011-05-28 16:52:13 +0000 |
commit | dc8edc4b8f4c2f75e5785045925cd7cd6e7df871 (patch) | |
tree | 76149c373d7e59beeea52aef0793bf9189cb7b9b /Master/texmf/tex | |
parent | c96567a73dfa159f9672fa2819ce0b3cd198d764 (diff) |
asymptote 2.10
git-svn-id: svn://tug.org/texlive/trunk@22643 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf/tex')
-rw-r--r-- | Master/texmf/tex/latex/asymptote/asymptote.sty | 606 |
1 files changed, 350 insertions, 256 deletions
diff --git a/Master/texmf/tex/latex/asymptote/asymptote.sty b/Master/texmf/tex/latex/asymptote/asymptote.sty index 4db253d4095..6518baba61f 100644 --- a/Master/texmf/tex/latex/asymptote/asymptote.sty +++ b/Master/texmf/tex/latex/asymptote/asymptote.sty @@ -1,304 +1,398 @@ -%%% Asymptote style file for LaTeX -%%% Contributed by Tom Prince 14 May 2003 -%%% Modified by John Bowman -%%% Adapted from comment.sty (Under GPL v2+) - -\ProvidesPackage{asymptote}[2010/07/10 v1.15 Asymptote style file for LaTeX] +%% +%% This is file `asymptote.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% asy-latex.dtx (with options: `pkg') +%% ____________________________ +%% The ASYMPTOTE package +%% +%% (C) 2003 Tom Prince +%% (C) 2003-2010 John Bowman +%% (C) 2010 Will Robertson +%% +%% Adapted from comment.sty +%% +%% Licence: GPL2+ +%% +\ProvidesPackage{asymptote} + [2011/05/15 v1.24 Asymptote style file for LaTeX] +\def\Asymptote{{\tt Asymptote}} +\InputIfFileExists{\jobname.pre}{}{} +\newbox\ASYbox +\newcounter{asy} +\newwrite\AsyStream +\newwrite\AsyPreStream +\newif\ifASYinline +\newif\ifASYattach +\newif\ifASYkeepAspect +\ASYkeepAspecttrue \RequirePackage{keyval} \RequirePackage{ifthen} -\newif\ifASYdefaultinline -\newif\ifASYdefaultattach -\DeclareOption{inline}{\ASYdefaultinlinetrue} -\DeclareOption{attach}{\ASYdefaultattachtrue} -\ProcessOptions* - -\def\unquoteJobname#1"#2"#3\relax{\def\rawJobname{#1}% - \ifx\rawJobname\empty\def\rawJobname{#2}\fi} -\expandafter\unquoteJobname\jobname""\relax -% Work around jobname bug in MiKTeX 2.5 and 2.6: -% Turn stars in file names (resulting from spaces, etc.) into minus signs -\def\fixstar#1*#2\relax{\def\argtwo{#2}\ifx\argtwo\empty\gdef\Jobname{#1}\else -\fixstar#1-#2\relax\fi} -\expandafter\fixstar\rawJobname*\relax - \RequirePackage{color,graphicx} - -\def\makeinnocent#1{\catcode`#1=12 } +\IfFileExists{ifpdf.sty}{ + \RequirePackage{ifpdf} +}{ + \expandafter\newif\csname ifpdf\endcsname + \ifx\pdfoutput\@undefined\else + \ifcase\pdfoutput\else + \pdftrue + \fi + \fi +} +\IfFileExists{ifxetex.sty}{ + \RequirePackage{ifxetex} +}{ + \expandafter\newif\csname ifxetex\endcsname + \ifx\XeTeXversion\@undefined\else + \xetextrue + \fi +} +\IfFileExists{catchfile.sty}{ + \RequirePackage{catchfile} +}{ + \newcommand\CatchFileDef[3]{% + \begingroup + \everyeof{% + \ENDCATCHFILEMARKER + \noexpand + }% + \long\def\@tempa##1\ENDCATCHFILEMARKER{% + \endgroup + \def#1{##1}% + }% + #3% + \expandafter\@tempa\@@input #2\relax + } +} +\newif\if@asy@attachfile@loaded +\AtBeginDocument{% + \@ifpackageloaded{attachfile2}{\@asy@attachfile@loadedtrue}{}% + \let\asy@check@attachfile\asy@check@attachfile@loaded +} +\newcommand\asy@check@attachfile@loaded{% + \if@asy@attachfile@loaded\else + \PackageError{asymptote}{You must load the attachfile2 package}{^^J% + You have requested the [attach] option for some or all of your^^J% + Asymptote graphics, which requires the attachfile2 package.^^J% + Please load it in the document preamble.^^J% + }% + \fi +} +\newcommand\asy@check@attachfile{% + \AtBeginDocument{\asy@check@attachfile@loaded}% + \let\asy@check@attachfile\@empty +} \def\csarg#1#2{\expandafter#1\csname#2\endcsname} -\newwrite\AsyStream -\newwrite\AsyPreStream -\newread\AsyTestStream - -\def\AsyInput#1{\openin\AsyTestStream=#1 -\ifeof\AsyTestStream -\else - \input #1 -\fi -\closein\AsyTestStream% +\DeclareOption{inline}{% + \ASYinlinetrue } - -\AsyInput{\jobname.pre} - -\immediate\openout\AsyPreStream=\jobname.pre - -\newif\ifASYinline -\newif\ifASYattach +\DeclareOption{attach}{% + \asy@check@attachfile + \ASYattachtrue +} +\ProcessOptions* +\def\asydir{} +\def\ASYprefix{} \newif\ifASYPDF - -\ifx\pdfoutput\undefined -\else -\ifcase\pdfoutput +\ifxetex + \ASYPDFtrue \else -\ASYPDFtrue + \ifpdf + \ASYPDFtrue + \fi \fi +\ifASYPDF + \def\AsyExtension{pdf} +\else + \def\AsyExtension{eps} \fi - -\newbox\ASYbox -\newcounter{asy} - -\def\ProcessAsymptote#1% start it all off -{\begingroup +\def\unquoteJobname#1"#2"#3\relax{% + \def\rawJobname{#1}% + \ifx\rawJobname\empty + \def\rawJobname{#2}% + \fi +} +\expandafter\unquoteJobname\jobname""\relax +\def\fixstar#1*#2\relax{% + \def\argtwo{#2}% + \ifx\argtwo\empty + \gdef\Jobname{#1}% + \else + \fixstar#1-#2\relax + \fi +} +\expandafter\fixstar\rawJobname*\relax +\def\Ginclude@eps#1{% + \message{<#1>}% + \bgroup + \def\@tempa{!}% + \dimen@\Gin@req@width + \dimen@ii.1bp\relax + \divide\dimen@\dimen@ii + \@tempdima\Gin@req@height + \divide\@tempdima\dimen@ii + \special{PSfile=#1\space + llx=\Gin@llx\space + lly=\Gin@lly\space + urx=\Gin@urx\space + ury=\Gin@ury\space + \ifx\Gin@scalex\@tempa\else rwi=\number\dimen@\space\fi + \ifx\Gin@scaley\@tempa\else rhi=\number\@tempdima\space\fi + \ifGin@clip clip\fi}% + \egroup +} +\immediate\openout\AsyPreStream=\jobname.pre\relax +\AtEndDocument{\immediate\closeout\AsyPreStream} +\def\WriteAsyLine#1{% + \immediate\write\AsyStream{\detokenize{#1}}% +} +\def\globalASYdefs{} +\def\WriteGlobalAsyLine#1{% + \expandafter\g@addto@macro + \expandafter\globalASYdefs + \expandafter{\detokenize{#1^^J}}% +} +\def\ProcessAsymptote#1{% + \begingroup \def\CurrentAsymptote{#1}% - \let\do\makeinnocent \dospecials - \makeinnocent\^^L% and whatever other special cases - \endlinechar`\^^M \catcode`\^^M=12 \xAsymptote} -{\catcode`\^^M=12 \endlinechar=-1 % + \let\do\@makeother \dospecials + \@makeother\^^L% and whatever other special cases + \catcode`\ =10 + \endlinechar`\^^M \catcode`\^^M=12 \xAsymptote +} +\begingroup + \catcode`\^^M=12 \endlinechar=-1\relax% \gdef\xAsymptote{% - \expandafter\ProcessAsymptoteLine} - \gdef\ProcessAsymptoteLine#1^^M{\def\test{#1} - \csarg\ifx{End\CurrentAsymptote Test}\test - \edef\next{\noexpand\EndOfAsymptote{\CurrentAsymptote}}% - \else \ThisAsymptote{#1}\let\next\ProcessAsymptoteLine - \fi \next} -} - -\def\ASYstringmeaning#1{\expandafter\ASYgobblearrow\meaning#1} -\def\ASYstringcsnoescape#1{\expandafter\ASYgobbleescape\string#1} -{\escapechar-1 - \expandafter\expandafter\expandafter\gdef - \expandafter\expandafter\expandafter\ASYgobblearrow - \expandafter\string\csname macro:->\endcsname{} -} -\def\ASYgobbleescape#1{\ifnum`\\=`#1 \else #1\fi} - -\def\WriteAsyLine#1{\def\ASYtmp{#1}% - \immediate\write\AsyStream{\ASYstringmeaning\ASYtmp}} - -\def\gedefappend#1#2{% - \toks@ = \expandafter{#1}% - \global\edef#1{\the\toks@ #2}% -}% -\def\globalASYdefs{} -\def\WriteGlobalAsyLine#1{\def\ASYtmp{#1^^J}% -\gedefappend\globalASYdefs{\ASYstringmeaning\ASYtmp}} - -\def\EndOfAsymptote#1{\endgroup\end{#1}% - \csname After#1Asymptote\endcsname} -\def\AsymptoteEndDef#1{{\escapechar=-1\relax - \csarg\xdef{End#1Test}{\string\\end\string\{#1\string\}}% - }} - -\def\AfterasyAsymptote{% - \ifx\ASYwidth\empty - \ifx\ASYheight\empty + \expandafter\ProcessAsymptoteLine% + } + \gdef\ProcessAsymptoteLine#1^^M{% + \def\@tempa{#1}% + {% + \escapechar=-1\relax% + \xdef\@tempb{\string\\end\string\{\CurrentAsymptote\string\}}% + }% + \ifx\@tempa\@tempb% + \edef\next{\endgroup\noexpand\end{\CurrentAsymptote}}% + \else% + \ThisAsymptote{#1}% + \let\next\ProcessAsymptoteLine% + \fi% + \next% + } +\endgroup +\newcommand\asy[1][]{% + \stepcounter{asy}% + \setkeys{ASYkeys}{#1}% + \ifASYattach + \ASYinlinefalse + \fi + \ifx\asydir\empty\else + \def\ASYprefix{\asydir/}% + \fi + \immediate\write\AsyPreStream{% + \noexpand\InputIfFileExists{% + \ASYprefix\noexpand\jobname-\the\c@asy.pre}{}{}% + } + \asy@write@graphic@header + \let\ThisAsymptote\WriteAsyLine + \ProcessAsymptote{asy}% +} +\def\endasy{% + \asy@finalise@stream + \asy@input@graphic +} +\def\asy@write@graphic@header{% + \immediate\openout\AsyStream=\ASYprefix\jobname-\the\c@asy.asy\relax + \gdef\AsyFile{\ASYprefix\Jobname-\the\c@asy}% + \immediate\write\AsyStream{% + if(!settings.multipleView) settings.batchView=false;^^J% + \ifxetex + settings.tex="xelatex";^^J% + \else\ifASYPDF + settings.tex="pdflatex";^^J% + \fi\fi + \ifASYinline + settings.inlinetex=true;^^J% + deletepreamble();^^J% + \fi + defaultfilename="\Jobname-\the\c@asy";^^J% + if(settings.render < 0) settings.render=4;^^J% + settings.outformat="";^^J% + \ifASYattach + settings.inlineimage=false;^^J% + settings.embed=false;^^J% + settings.toolbar=true;^^J% \else - \immediate\write\AsyStream{size(0,\ASYheight);}% + settings.inlineimage=true;^^J% + settings.embed=true;^^J% + settings.toolbar=false;^^J% + viewportmargin=(2,2);^^J% \fi - \else - \ifx\ASYheight\empty - \immediate\write\AsyStream{size(\ASYwidth,0);}% + \globalASYdefs + }% +} +\def\asy@expand@keepAspect{% + \ifASYkeepAspect keepAspect=true% + \else keepAspect=false% + \fi% +} +\def\asy@finalise@stream{% + \ifx\ASYwidth\@empty + \ifx\ASYheight\@empty + % write nothing! \else - \immediate\write\AsyStream{size(\ASYwidth,\ASYheight);}% + \immediate\write\AsyStream{size(0,\ASYheight,\asy@expand@keepAspect);}% \fi - \fi - \ifASYattach - \def\ASYdefaultviewportwidth{0}% \else - \def\ASYdefaultviewportwidth{\the\linewidth}% + \ifx\ASYheight\@empty + \immediate\write\AsyStream{size(\ASYwidth,0,\asy@expand@keepAspect);}% + \else + \immediate\write\AsyStream{size(\ASYwidth,\ASYheight,\asy@expand@keepAspect);}% + \fi \fi - \ifx\ASYviewportwidth\empty - \ifx\ASYviewportheight\empty + \edef\ASYviewportwidth{\ASYviewportwidth}% locally "freeze" viewportwidth + \ifx\ASYviewportwidth\@empty + \ifx\ASYviewportheight\@empty + % write nothing! \else \immediate\write\AsyStream{viewportsize=(0,\ASYviewportheight);}% \fi \else - \ifx\ASYviewportheight\empty + \ifx\ASYviewportheight\@empty \immediate\write\AsyStream{viewportsize=(\ASYviewportwidth,0);}% \else - \immediate\write% - \AsyStream{viewportsize=(\ASYviewportwidth,\ASYviewportheight);}% + \immediate\write\AsyStream{% + viewportsize=(\ASYviewportwidth,\ASYviewportheight);}% \fi \fi - \gdef\ASYwidth{}% - \gdef\ASYheight{}% - \gdef\ASYviewportwidth{\ASYdefaultviewportwidth}% - \gdef\ASYviewportheight{}% \immediate\closeout\AsyStream - +} +\def\asy@input@graphic{% \ifASYinline - \openin\AsyTestStream=\AsyFile.tex - \else - \ifASYPDF - \openin\AsyTestStream=\AsyFile.pdf - \else - \openin\AsyTestStream=\AsyFile.eps - \fi - \fi - \ifeof\AsyTestStream - \ifASYinline + \IfFileExists{"\AsyFile.tex"}{% + \catcode`:=12\relax + \@@input"\AsyFile.tex"\relax + }{% \PackageWarning{asymptote}{file `\AsyFile.tex' not found}% - \closein\AsyTestStream% - \else - \closein\AsyTestStream% - \openin\AsyTestStream=\AsyFile.tex - \ifeof\AsyTestStream + }% + \else + \IfFileExists{"\AsyFile.\AsyExtension"}{% + \ifASYattach \ifASYPDF - \PackageWarning{asymptote}{file `\AsyFile.pdf' not found}% + \IfFileExists{"\AsyFile+0.pdf"}{% + \setbox\ASYbox=\hbox{\includegraphics[hiresbb]{"\AsyFile+0".pdf}}% + }{% + \setbox\ASYbox=\hbox{\includegraphics[hiresbb]{"\AsyFile".pdf}}% + }% \else - \PackageWarning{asymptote}{file `\AsyFile.eps' not found}% + \setbox\ASYbox=\hbox{\includegraphics[hiresbb]{"\AsyFile.eps"}}% \fi + \textattachfile{\AsyFile.\AsyExtension}{\phantom{\copy\ASYbox}}% + \vskip-\ht\ASYbox + \indent + \box\ASYbox \else - \catcode`:=12 - \input \AsyFile.tex% - \fi - \closein\AsyTestStream% - \fi - \else - \closein\AsyTestStream% - \ifASYinline - \catcode`:=12 - \input \AsyFile.tex% - \else - \ifASYattach \ifASYPDF - \openin\AsyTestStream=\AsyFile+0.pdf - \fi - \ifeof\AsyTestStream - \setbox\ASYbox=\hbox{\includegraphics[hiresbb]{\AsyFile}}% + \includegraphics[hiresbb]{"\AsyFile".pdf}% \else - \setbox\ASYbox=\hbox{\includegraphics[hiresbb]{\AsyFile+0}}% + \includegraphics[hiresbb]{"\AsyFile.eps"}% \fi - \textattachfile{\AsyFile.pdf}{\phantom{\copy\ASYbox}}% - \vskip-\ht\ASYbox% - \indent% - \box\ASYbox% - \closein\AsyTestStream% - \else - \includegraphics[hiresbb]{\AsyFile}% \fi - \fi + }{% + \IfFileExists{"\AsyFile.tex"}{% + \catcode`:=12 + \@@input"\AsyFile.tex"\relax + }{% + \PackageWarning{asymptote}{% + file `\AsyFile.\AsyExtension' not found% + }% + }% + }% \fi - \relax% - \endgroup} -\gdef\ASYwidth{}% +} +\def\asydef{% + \let\ThisAsymptote\WriteGlobalAsyLine + \ProcessAsymptote{asydef}% +} +\newcommand\asyinclude[2][]{% + \begingroup + \stepcounter{asy}% + \setkeys{ASYkeys}{#1}% + \ifASYattach + \ASYinlinefalse + \fi + \ifx\asydir\empty\else + \def\ASYprefix{\asydir/}% + \fi + \immediate\write\AsyPreStream{% + \noexpand\InputIfFileExists{% + \ASYprefix\noexpand\jobname-\the\c@asy.pre}{}{}% + } + \asy@write@graphic@header + \IfFileExists{#2.asy}{% + \CatchFileDef\@tempa{#2.asy}{% + \let\do\@makeother + \dospecials + \endlinechar=10\relax + } + }{ + \IfFileExists{#2}{% + \CatchFileDef\@tempa{#2}{% + \let\do\@makeother + \dospecials + \endlinechar=10\relax + } + }{ + \PackageWarning{asymptote}{file #2 not found}% + } + } + \immediate\write\AsyStream{\unexpanded\expandafter{\@tempa}}% + \asy@finalise@stream + \asy@input@graphic + \endgroup +} +\newcommand{\ASYanimategraphics}[5][]{% + \IfFileExists{_#3.pdf}{% + \animategraphics[{#1}]{#2}{_#3}{#4}{#5}% + }{} +} +\newcommand\asysetup[1]{\setkeys{ASYkeys}{#1}} +\define@key{ASYkeys}{dir}{% + \def\asydir{#1}% +} +\def\ASYwidth{} \define@key{ASYkeys}{width}{% - \gdef\ASYwidth{#1}% + \edef\ASYwidth{\the\dimexpr#1\relax}% } -\gdef\ASYheight{}% +\def\ASYheight{} \define@key{ASYkeys}{height}{% - \gdef\ASYheight{#1}% + \edef\ASYheight{\the\dimexpr#1\relax}% +} +\define@key{ASYkeys}{keepAspect}[true]{% + \ifthenelse{\equal{#1}{true}} + {\ASYkeepAspecttrue} + {\ASYkeepAspectfalse}% +} +\def\ASYviewportwidth{\ASYdefaultviewportwidth} +\def\ASYdefaultviewportwidth{% + \ifASYattach \@empty \else \the\linewidth \fi } -\gdef\ASYviewportwidth{\ASYdefaultviewportwidth}% \define@key{ASYkeys}{viewportwidth}{% - \gdef\ASYviewportwidth{#1}% + \edef\ASYviewportwidth{\the\dimexpr#1\relax}% } -\gdef\ASYviewportheight{}% +\def\ASYviewportheight{} \define@key{ASYkeys}{viewportheight}{% - \gdef\ASYviewportheight{#1}% -} -\define@key{ASYkeys}{attach}[true]{% - \ifthenelse{\equal{#1}{true}}{\global\ASYattachtrue}{\global\ASYattachfalse}% + \edef\ASYviewportheight{\the\dimexpr#1\relax}% } \define@key{ASYkeys}{inline}[true]{% - \ifthenelse{\equal{#1}{true}}{\global\ASYinlinetrue}{\global\ASYinlinefalse}% + \ifthenelse{\equal{#1}{true}} + {\ASYinlinetrue} + {\ASYinlinefalse}% } -\newcommand\asy[1][]{% - \begingroup - \let\par\empty - \stepcounter{asy}% - \global\let\ifASYinline\ifASYdefaultinline - \global\let\ifASYattach\ifASYdefaultattach - \setkeys{ASYkeys}{#1}% - \ifASYattach - \global\ASYinlinefalse - \fi - \immediate\write\AsyPreStream% - {\@backslashchar AsyInput{\jobname-\the\c@asy.pre}} - \immediate\openout\AsyStream=\jobname-\the\c@asy.asy - \gdef\AsyFile{\Jobname-\the\c@asy}% - \immediate\write\AsyStream{if(!settings.multipleView)}% - \immediate\write\AsyStream{ settings.batchView=false;}% - \ifx\XeTeXversion\undefined - \ifASYPDF - \immediate\write\AsyStream{settings.tex="pdflatex";}% - \fi - \else - \immediate\write\AsyStream{settings.tex="xelatex";}% - \ASYPDFtrue - \fi - - \ifASYinline - \immediate\write\AsyStream{settings.inlinetex=true;}% - \immediate\write\AsyStream{deletepreamble();}% - \fi - \immediate\write\AsyStream{defaultfilename="\AsyFile";}% - \immediate\write\AsyStream{if(settings.render < 0) settings.render=4;}% - \ifASYattach - \immediate\write\AsyStream{settings.inlineimage=false;}% - \immediate\write\AsyStream{settings.embed=false;}% - \immediate\write\AsyStream{settings.outformat="pdf";}% - \immediate\write\AsyStream{settings.toolbar=true;}% - \else - \immediate\write\AsyStream{settings.inlineimage=true;}% - \immediate\write\AsyStream{settings.embed=true;}% - \immediate\write\AsyStream{settings.outformat="";}% - \immediate\write\AsyStream{settings.toolbar=false;}% - \immediate\write\AsyStream{viewportmargin=(2,2);}% - \fi - \immediate\write\AsyStream{\globalASYdefs}% - \let\ThisAsymptote\WriteAsyLine% - \ProcessAsymptote{asy}% +\define@key{ASYkeys}{attach}[true]{% + \ifthenelse{\equal{#1}{true}} + {\ASYattachtrue} + {\ASYattachfalse}% } -\AsymptoteEndDef{asy} -\def\asydef{% - \let\ThisAsymptote\WriteGlobalAsyLine% - \ProcessAsymptote{asydef}} -\AsymptoteEndDef{asydef} -\def\AfterasydefAsymptote{} - -\AtEndDocument{\immediate\closeout\AsyPreStream} - -\newcommand{\ASYanimategraphics}[5][]{% -\openin\AsyTestStream=_#3.pdf -\ifeof\AsyTestStream% -\else% -\animategraphics[{#1}]{#2}{_#3}{#4}{#5}% -\fi% -} - -% Work around bug in dvips.def: allow spaces in file names. -\def\Ginclude@eps#1{% - \message{<#1>}% - \bgroup - \def\@tempa{!}% - \dimen@\Gin@req@width - \dimen@ii.1bp% - \divide\dimen@\dimen@ii - \@tempdima\Gin@req@height - \divide\@tempdima\dimen@ii - \special{PSfile=#1\space - llx=\Gin@llx\space - lly=\Gin@lly\space - urx=\Gin@urx\space - ury=\Gin@ury\space - \ifx\Gin@scalex\@tempa\else rwi=\number\dimen@\space\fi - \ifx\Gin@scaley\@tempa\else rhi=\number\@tempdima\space\fi - \ifGin@clip clip\fi}% - \egroup} - -\def\Asymptote{{\tt Asymptote}} - -%%% Local Variables: -%%% mode: latex -%%% TeX-master: "shared" -%%% End: |