diff options
author | Karl Berry <karl@freefriends.org> | 2011-12-21 23:41:34 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2011-12-21 23:41:34 +0000 |
commit | 34adb1fdc882b4cbadf33ef1f919c673c42aae30 (patch) | |
tree | e962d7d9394ebedfd28cda6e0a5127097efcf2b4 /Master/texmf-dist/tex/latex/standalone/standalone.cls | |
parent | caa391301c323d8e1ac20ad46d581f1223a09291 (diff) |
standalone (21dec11)
git-svn-id: svn://tug.org/texlive/trunk@24894 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/standalone/standalone.cls')
-rw-r--r-- | Master/texmf-dist/tex/latex/standalone/standalone.cls | 802 |
1 files changed, 723 insertions, 79 deletions
diff --git a/Master/texmf-dist/tex/latex/standalone/standalone.cls b/Master/texmf-dist/tex/latex/standalone/standalone.cls index 363cd18ce0e..0fd148c0079 100644 --- a/Master/texmf-dist/tex/latex/standalone/standalone.cls +++ b/Master/texmf-dist/tex/latex/standalone/standalone.cls @@ -1,87 +1,642 @@ -%% -%% This is file `standalone.cls', -%% generated with the docstrip utility. -%% -%% The original source files were: -%% -%% standalone.dtx (with options: `cls') -%% -%% Copyright (c) 2010 by Martin Scharrer <martin@scharrer-online.de> -%% +%% Copyright (C) 2011 by Martin Scharrer <martin@scharrer-online.de> +%% --------------------------------------------------------------------------- %% This work may be distributed and/or modified under the -%% conditions of the LaTeX Project Public License, either version 1.3c +%% conditions of the LaTeX Project Public License, either version 1.3 %% 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.3c or later is part of all distributions of LaTeX -%% version 2008/05/04 or later. -%% +%% 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 Martin Scharrer. -%% -%% This work consists of the files standalone.dtx, standalone.ins -%% and the derived file standalone.sty. -%% -% $Id: standalone.dtx 2451 2011-04-07 11:40:38Z martin $ +%% +%% This work consists of the files <+name+>.dtx and <+name+>.ins +%% and the derived filebase <+name+>.sty. +%% \NeedsTeXFormat{LaTeX2e} -\ProvidesClass{standalone} [2011/04/07 v0.4a Class to compile TeX sub-files standalone] +\ProvidesClass{standalone}[% + 2011/12/21 + v1.0 + Class to compile TeX sub-files standalone] \newif\ifstandalone \standalonetrue \newif\ifstandalonebeamer \standalonebeamerfalse \let\onlyifstandalone\@firstofone -\RequirePackage{kvoptions} -\SetupKeyvalOptions{prefix=sa@} -\DeclareBoolOption[true]{preview} -\DeclareStringOption{border} -\let\sa@border\relax -\DeclareVoidOption{beamer}{% - \def\sa@class{beamer}% - \sa@previewfalse - \standalonebeamertrue -} -\DeclareStringOption[article]{class} -\def\sa@classoptionslist{} -\DeclareDefaultOption{% - \xdef\sa@classoptionslist{\sa@classoptionslist,\CurrentOption}% -} -\ProcessKeyvalOptions*\relax -\let\@classoptionslist\sa@classoptionslist +\let\IfStandalone\@firstoftwo +\def\sa@border@left{0.50001bp} +\let\sa@border@right\sa@border@left +\let\sa@border@top\sa@border@left +\let\sa@border@bottom\sa@border@left +\def\rem@bp#1bp\relax#2\@nnil{#1}% +\def\default@bp#1#2{% + \begingroup + \afterassignment\remove@to@nnil + \dimen@ #2bp\relax\@nnil + \expandafter + \endgroup + \expandafter + \def\expandafter#1\expandafter{\the\dimen@}% +} +\def\sa@readborder#1 #2 #3 #4 #5\@nnil{% + \ifx\\#2#3#4\\% + \default@bp\sa@border@left{#1}% + \let\sa@border@right\sa@border@left + \let\sa@border@top\sa@border@left + \let\sa@border@bottom\sa@border@left + \else + \ifx\\#4\\% + \default@bp\sa@border@left{#1}% + \let\sa@border@right\sa@border@left + \default@bp\sa@border@top{#2}% + \let\sa@border@bottom\sa@border@top + \else + \default@bp\sa@border@left{#1}% + \default@bp\sa@border@bottom{#2}% + \default@bp\sa@border@right{#3}% + \default@bp\sa@border@top{#4}% + \fi\fi +}% +\expandafter\ifx\csname ifluatex\endcsname\relax + \IfFileExists{ifluatex.sty}{\@firstoftwo}{\@secondoftwo}{% + \RequirePackage{ifluatex} + }{ + \begingroup + \expandafter\ifx\csname directlua\endcsname\relax + \endgroup + \expandafter\let\csname ifluatex\expandafter\endcsname\csname iffalse\endcsname + \else + \endgroup + \expandafter\let\csname ifluatex\expandafter\endcsname\csname iftrue\endcsname + \fi + } +\fi +\expandafter\ifx\csname ifpdf\endcsname\relax + \IfFileExists{ifpdf.sty}{\@firstoftwo}{\@secondoftwo}{% + \RequirePackage{ifpdf} + }{ + \begingroup + \expandafter\ifx\csname pdfoutput\endcsname\relax + \endgroup + \expandafter\let\csname ifpdf\expandafter\endcsname\csname iffalse\endcsname + \else + \endgroup + \ifnum\pdfoutput<1 + \expandafter\let\csname ifpdf\expandafter\endcsname\csname iffalse\endcsname + \else + \expandafter\let\csname ifpdf\expandafter\endcsname\csname iftrue\endcsname + \fi + \fi + } +\fi +\expandafter\ifx\csname ifxetex\endcsname\relax + \IfFileExists{ifxetex.sty}{\@firstoftwo}{\@secondoftwo}{% + \RequirePackage{ifxetex} + }{ + \begingroup + \expandafter\ifx\csname XeTeXrevision\endcsname\relax + \endgroup + \expandafter\let\csname ifxetex\expandafter\endcsname\csname iffalse\endcsname + \else + \endgroup + \expandafter\let\csname ifxetex\expandafter\endcsname\csname iftrue\endcsname + \fi + } +\fi +\let\sa@classoptionslist\@classoptionslist +\RequirePackage{xkeyval} +\newif\ifsa@preview +\newif\ifsa@crop +\newif\ifsa@multi +\newif\ifsa@varwidth +\newif\ifsa@ignorerest +\newif\ifsa@tikz +\newif\ifsa@pstricks +\newif\ifsa@convert +\newif\ifsa@float +\let\sa@beamertrue\standalonebeamertrue +\let\sa@beamerfalse\standalonebeamerfalse +\def\sa@clsoption{% + \define@key{standalone.cls}% +} +\sa@clsoption{border}{% + \sa@readborder#1 {} {} {} {} \@nnil +} +\def\sa@boolean#1#2{% + \sa@boolorvalue{#1}{#2}% + {\ClassError{standalone}{Invalid value '#2' for boolean key '#1'}{}}% +} +\def\sa@boolorvalue#1#2{% + \begingroup + \edef\@tempa{#2}% + \def\@tempb{true}% + \ifx\@tempa\@tempb + \endgroup + \csname sa@#1true\endcsname + \expandafter\@gobble + \else + \def\@tempb{false}% + \ifx\@tempa\@tempb + \endgroup + \csname sa@#1false\endcsname + \expandafter\expandafter + \expandafter\@gobble + \else + \endgroup + \expandafter\expandafter + \expandafter\@firstofone + \fi\fi +} +\sa@clsoption{preview}[true]{% + \sa@boolean{preview}{#1}% + \ifsa@preview + \setkeys{standalone.cls}{crop=false,float=false}% + \fi +} +\sa@previewtrue +\sa@clsoption{crop}[true]{% + \sa@boolean{crop}{#1}% + \ifsa@crop + \setkeys{standalone.cls}{preview=false,float=false}% + \fi +} +\sa@clsoption{ignorerest}[true]{% + \sa@boolean{ignorerest}{#1}% +} +\sa@clsoption{multi}[true]{% + \sa@boolorvalue{multi}{#1}{\sa@multitrue\AtBeginDocument{\standaloneenv{#1}}}% +} +\sa@clsoption{varwidth}[true]{% + \sa@boolorvalue{varwidth}{#1}{\sa@varwidthtrue\def\sa@width{#1}}% + \ifsa@varwidth + \def\sa@varwidth{\varwidth{\sa@width}}% + \def\sa@endvarwidth{\endvarwidth}% + \else + \let\sa@varwidth\@empty + \let\sa@endvarwidth\@empty + \fi +} +\let\sa@varwidth\@empty +\let\sa@endvarwidth\@empty +\sa@clsoption{tikz}[true]{% + \sa@boolean{tikz}{#1}% + \ifsa@tikz + \setkeys{standalone.cls}{multi=tikzpicture,varwidth=false}% + \fi +} +\sa@clsoption{pstricks}[true]{% + \sa@boolean{pstricks}{#1}% + \ifsa@pstricks + \setkeys{standalone.cls}{multi=pspicture,varwidth=false}% + \fi +} +\sa@clsoption{beamer}[true]{% + \sa@boolean{beamer}{#1}% + \ifstandalonebeamer + \def\sa@class{beamer}% + \setkeys{standalone.cls}{preview=false,crop=false,varwidth=false}% + \else + \begingroup + \def\@tempa{beamer}% + \ifx\@tempa\sa@class + \endgroup + \def\sa@class{article}% + \else + \endgroup + \fi + \fi +} +\sa@clsoption{class}{% + \def\sa@class{#1}% +} +\def\sa@class{article} +\sa@clsoption{float}[true]{% + \sa@boolean{float}{#1}% + \ifsa@float + \let\@float\sa@origfloat + \let\end@float\sa@origendfloat + \else + \ifx\@float\sa@nofloat\else + \let\sa@origfloat\@float + \fi + \ifx\end@float\sa@endnofloat\else + \let\sa@origendfloat\end@float + \fi + \let\@float\sa@nofloat + \let\end@float\sa@endnofloat + \fi +} +\def\sa@nofloat#1{% + \def\@captype{#1}% + \trivlist\item[]% + \@ifnextchar[{% + \begingroup + \def\@tempa[####1]{% + \endgroup + }\@tempa + }{}% +} +\def\sa@endnofloat{% + \endtrivlist +} +\sa@clsoption{convert}[true]{% + \setkeys{standalone.cls/convert}{#1}% +} +\sa@clsoption{disable@convert}[]{% + \typeout{Disable conversion} + \sa@convertfalse + \let\sa@converttrue\relax +} +\def\sa@convertoption{% + \define@key{standalone.cls/convert}% +} +\def\sa@convertvar#1#2{% + \define@key{standalone.cls/convert}{#1}{% + \@namedef{sa@convert@#1}{##1}% + }% + \@namedef{sa@convert@#1}{#2}% +} +\sa@convertoption{true}[]{% + \sa@converttrue +} +\sa@convertoption{false}[]{% + \sa@convertfalse +} +\sa@convertoption{png}[]{% + \setkeys{standalone.cls/convert}{true,outext={.png}}% +} +\sa@clsoption{png}[]{% + \setkeys{standalone.cls/convert}{png,#1}% +} +\sa@convertoption{jpg}[]{% + \setkeys{standalone.cls/convert}{true,outext={.jpg}}% +} +\sa@clsoption{jpg}[]{% + \setkeys{standalone.cls/convert}{jpg,#1}% +} +\sa@convertoption{gif}[]{% + \setkeys{standalone.cls/convert}{true,outext={.gif}}% +} +\sa@clsoption{gif}[]{% + \setkeys{standalone.cls/convert}{gif,#1}% +} +\sa@convertoption{onfailure}{% + \begingroup + \edef\@tempa{#1}% + \def\@tempb{error}% + \ifx\@tempa\@tempb + \endgroup + \let\sa@convert@failuremsg\ClassError + \else + \def\@tempb{warning}% + \ifx\@tempa\@tempb + \endgroup + \let\sa@convert@failuremsg\ClassWarning + \else + \def\@tempb{info}% + \ifx\@tempa\@tempb + \endgroup + \let\sa@convert@failuremsg\ClassInfo + \else + \def\@tempb{ignore}% + \ifx\@tempa\@tempb + \endgroup + \def\sa@convert@failuremsg##1##2##3{}% + \let\sa@convert@notfoundmsg\@gobbletwo + \else + \let\on@line\@empty + \ClassError{standalone}{Invalid value '\@tempa' for the 'onfailure' option.\MessageBreak + Valid values: 'error', 'warning', 'info', 'ignore'}{}% + \endgroup + \fi\fi\fi\fi +} +\let\sa@convert@failuremsg\ClassWarning +\let\sa@convert@notfoundmsg\ClassWarning +\sa@convertoption{defgsdevice}{% + \sa@defgsdevice#1\relax\relax +} +\def\sa@defgsdevice#1#2{% + \@namedef{sa@gsdevice@#1}{#2}% +} +\@namedef{sa@gsdevice@.jpg}{jpeg}% +\@namedef{sa@gsdevice@.png}{png16m}% +\sa@convertoption{imagemagick}[]{% + \def\sa@convert@command{\convertexe\space -density \density\space \infile\space \ifx\size\empty\else -resize \size\fi\space -quality 90 \outfile}% +} +\sa@convertoption{ghostscript}[]{% + \def\sa@convert@command{\gsexe\space -dSAFER -dBATCH -dNOPAUSE -sDEVICE=\gsdevice\space -r\density\space -sOutputFile=\outfile\space \infile}% +} +\sa@convertvar{subjobname}{\jobname} +\sa@convertvar{size}{} +\sa@convertvar{inname}{\subjobname} +\sa@convertvar{infile}{\inname\inext} +\sa@convertvar{outext}{.png} +\sa@convertvar{outname}{\inname} +\sa@convertvar{outfile}{\outname\ifsa@multi-\@percentchar d\fi\outext} +\sa@convertvar{density}{300} +\sa@convertvar{gsdevice}{% + \expandafter\ifx\csname sa@gsdevice@\outext\endcsname\relax + \expandafter\@gobble\outext + \else + \csname sa@gsdevice@\outext\endcsname + \fi +} +\ifluatex + \sa@convertvar{latex}{lualatex} + \sa@convertvar{inext}{.pdf} + \sa@convertvar{precommand}{} + \setkeys{standalone.cls/convert}{imagemagick} +\else +\ifpdf + \sa@convertvar{latex}{pdflatex} + \sa@convertvar{inext}{.pdf} + \sa@convertvar{precommand}{} + \setkeys{standalone.cls/convert}{imagemagick} +\else +\ifxetex + \sa@convertvar{latex}{xelatex} + \sa@convertvar{inext}{.pdf} + \sa@convertvar{precommand}{} + \setkeys{standalone.cls/convert}{imagemagick} +\else + \sa@convertvar{latex}{latex} + \sa@convertvar{inext}{.ps} + \sa@convertvar{precommand}{dvips \jobname.dvi} + \setkeys{standalone.cls/convert}{ghostscript} +\fi\fi\fi \begingroup -\xdef\@tempa{[\sa@classoptionslist]{\sa@class}} -\expandafter -\endgroup -\expandafter\LoadClass\@tempa +\ifluatex + \csname @tempswa\directlua{ + if os.type == "windows" then + tex.sprint("true") + else + tex.sprint("false") + end + }\endcsname +\else + \IfFileExists{/dev/null}{\@tempswafalse}{\@tempswatrue}% +\fi +\if@tempswa + \endgroup + \sa@convertvar{convertexe}{imgconvert} + \sa@convertvar{gsexe}{gswin32c} +\else + \endgroup + \sa@convertvar{convertexe}{convert} + \sa@convertvar{gsexe}{gs} +\fi +\newcommand*\standaloneenv[1]{% + \begingroup + \edef\@tempa{\endgroup\noexpand\@for\noexpand\@tempa:=\zap@space#1 \@empty}% + \@tempa\do{\expandafter\@standaloneenv\expandafter{\@tempa}}% + \setkeys{standalone.cls}{multi}% +} +\@onlypreamble\standaloneenv +\newcommand*{\standaloneconfig}{\setkeys{standalone.cls}} +\let\@standaloneenv\@gobble +\newcount\sa@internal \let\standalone\empty \let\endstandalone\relax -\input{standalone.cfg} +\def\sa@width{\linewidth} +\InputIfFileExists{standalone.cfg}{}{} +\begingroup +\def\@tempa{\endgroup\setkeys*{standalone.cls}} +\expandafter\expandafter\expandafter\@tempa +\expandafter\expandafter\expandafter{\csname opt@standalone.cls\endcsname} +\let\@classoptionslist\XKV@rm +\disable@keys{standalone.cls}{crop,preview,class,beamer,ignorerest} +\AtBeginDocument{% + \disable@keys{standalone.cls}{multi}% +} +\expandafter\expandafter\expandafter\LoadClass +\expandafter\expandafter\expandafter[% +\expandafter\@classoptionslist +\expandafter]\expandafter{\sa@class} +\ifsa@varwidth + \RequirePackage{varwidth} +\fi +\ifsa@tikz + \RequirePackage{tikz} +\fi +\ifsa@pstricks + \RequirePackage{pstricks} +\fi \ifsa@preview - \@ifundefined{endstandalone}{% - \renewenvironment{standalone} - {\preview } - {\endpreview} - }{}% - \RequirePackage{preview} - \ifx\sa@border\relax\else - \begingroup - \def\rem@bp#1bp\relax#2\@nnil{#1}% - \def\default@bp#1{\expandafter\rem@bp\the\dimexpr#1 bp\relax bp\relax\@nnil}% - \def\sa@readborder#1 #2 #3 #4 {% - \ifx\\#2#3#4\\% - \@defaultunits\global\PreviewBorder=\dimexpr#1 bp\relax\@nnil% - \else - \ifx\\#4\\% - \xdef\PreviewBbAdjust{-\default@bp{#1} -\default@bp{#2} \default@bp{#1} \default@bp{#2}}% - \else - \xdef\PreviewBbAdjust{-\default@bp{#1} -\default@bp{#2} \default@bp{#3} \default@bp{#4}}% - \fi\fi +\RequirePackage{preview} +\ifsa@multi\else + \@ifundefined{endstandalone}{% + \renewenvironment{standalone} + {\preview\sa@varwidth} + {\sa@endvarwidth\endpreview} + }{}% TODO: Add info message? +\fi +\def\PreviewBbAdjust{-\sa@border@left\space -\sa@border@bottom\space \sa@border@right\space \sa@border@top}% +\def\@standaloneenv#1{% + \expandafter\ifx\csname sa@orig@#1\endcsname\relax + \expandafter\let\csname sa@orig@#1\expandafter\endcsname\csname #1\endcsname + \expandafter\let\csname sa@orig@end#1\expandafter\endcsname\csname end#1\endcsname + \fi + \expandafter\def\csname #1\endcsname{% + \ifnum\sa@internal=0 + \preview + \sa@varwidth + \fi + \advance\sa@internal\@ne + \csname sa@orig@#1\endcsname }% - \@firstofone{\expandafter\sa@readborder\sa@border} {} {} {} {} \relax - \endgroup - \fi + \expandafter\def\csname end#1\endcsname{% + \csname sa@orig@end#1\endcsname + \advance\sa@internal\m@ne + \ifnum\sa@internal=0 + \sa@endvarwidth + \endpreview + \fi + }% +}% +\fi +\ifsa@crop +\newbox\sa@box +\pagestyle{empty} +\hoffset=-72.27pt +\voffset=-72.27pt +\topmargin=0pt +\headheight=0pt +\headsep=0pt +\marginparsep=0pt +\marginparwidth=0pt +\footskip=0pt +\marginparpush=0pt +\oddsidemargin=0pt +\evensidemargin=0pt +\topskip=0pt +\textheight=\maxdimen +\def\sa@boxit{% + \setbox\sa@box\hbox\bgroup\color@setgroup\sa@varwidth +}% +\def\endsa@boxit{% + \sa@endvarwidth\color@endgroup\egroup +}% +\renewenvironment{standalone}{% + \ifsa@multi + \ifsa@ignorerest + \sa@boxit + \fi + \else + \sa@boxit + \fi +}{% + \ifsa@multi + \ifsa@ignorerest + \endsa@boxit + \fi + \else + \endsa@boxit + \sa@handlebox + \fi +} +\ifsa@multi\else + \sa@ignorerestfalse +\fi +\ifsa@ignorerest + \def\@standaloneenv#1{% + \expandafter\ifx\csname sa@orig@#1\endcsname\relax + \expandafter\let\csname sa@orig@#1\expandafter\endcsname\csname #1\endcsname + \expandafter\let\csname sa@orig@end#1\expandafter\endcsname\csname end#1\endcsname + \fi + \expandafter\def\csname #1\endcsname{% + \ifnum\sa@internal=0 + \edef\@tempa{\endgroup + \noexpand\endsa@boxit + \begingroup + \def\noexpand\@currenvir{\@currenvir}% + \def\noexpand\@currenvline{\@currenvline}% + }% + \@tempa + \sa@boxit + \fi + \advance\sa@internal\@ne + \csname sa@orig@#1\endcsname + }% + \expandafter\def\csname end#1\endcsname{% + \csname sa@orig@end#1\endcsname + \advance\sa@internal\m@ne + \ifnum\sa@internal=0 + \endsa@boxit + \sa@handlebox + \aftergroup\sa@boxit + \fi + }% + }% +\else + \def\@standaloneenv#1{% + \expandafter\ifx\csname sa@orig@#1\endcsname\relax + \expandafter\let\csname sa@orig@#1\expandafter\endcsname\csname #1\endcsname + \expandafter\let\csname sa@orig@end#1\expandafter\endcsname\csname end#1\endcsname + \fi + \expandafter\def\csname #1\endcsname{% + \ifnum\sa@internal=0 + \sa@boxit + \fi + \advance\sa@internal\@ne + \csname sa@orig@#1\endcsname + }% + \expandafter\def\csname end#1\endcsname{% + \csname sa@orig@end#1\endcsname + \advance\sa@internal\m@ne + \ifnum\sa@internal=0 + \endsa@boxit + \sa@handlebox + \fi + }% + }% +\fi +\def\sa@handlebox{% + \sbox\sa@box{% + \hskip\sa@border@left + \@tempdima=\ht\sa@box + \advance\@tempdima\sa@border@top\relax + \ht\sa@box=\@tempdima + \@tempdima=\dp\sa@box + \advance\@tempdima\sa@border@bottom\relax + \dp\sa@box=\@tempdima + \raise\dp\sa@box + \box\sa@box + \hskip\sa@border@right + }% + \sa@placebox +} +\ifcase0% + \ifpdf\else\ifluatex\else\ifxetex\else 1\fi\fi\fi + \relax + \def\sa@placebox{% + \newpage + \global\pdfpagewidth=\wd\sa@box + \global\pdfpageheight=\ht\sa@box + \global\paperwidth=\wd\sa@box + \global\paperheight=\ht\sa@box + \global\hsize=\wd\sa@box + \global\vsize=\ht\sa@box + \global\@colht=\ht\sa@box + \global\@colroom=\ht\sa@box + \noindent\usebox\sa@box + \newpage + } + \else + \def\sa@placebox{% + \global\paperwidth=\wd\sa@box + \global\paperheight=\ht\sa@box + \global\@colht=\maxdimen + \global\@colroom=\maxdimen + \global\hsize=\maxdimen + \global\vsize=\maxdimen + \sa@papersize + \ifsa@multi + \begingroup + \@tempdima0.99626\paperwidth + \@tempdimb0.99626\paperheight + \edef\@tempc{\strip@pt\@tempdima}% + \edef\@tempd{\strip@pt\@tempdimb}% + \advance\@tempdima by .998pt + \advance\@tempdimb by .998pt + \def\strip@float##1.##2\relax{##1}% + \edef\@tempa{\expandafter\strip@float\the\@tempdima\relax}% + \edef\@tempb{\expandafter\strip@float\the\@tempdimb\relax}% + \special{ps::% + \@percentchar\@percentchar PageBoundingBox: 0 0 \@tempa\space\@tempb^^J% + \@percentchar\@percentchar HiResPageBoundingBox: 0 0 \@tempc\space\@tempd^^J% + \@percentchar\@percentchar BeginPageSetup^^J% + << /PageSize [\@tempc\space\@tempd] + >> setpagedevice^^J%<< + 0 0 bop^^J% + \@percentchar\@percentchar EndPageSetup}% + \endgroup + \fi + \topskip=0pt + \noindent\sa@ps@content + \newpage + } +\def\sa@ps@content{% + \noindent\usebox\sa@box + \global\def\sa@ps@content{% + \@tempdima\sa@yoffset + \advance\@tempdima-\topskip + \dp\sa@box\z@ + \ht\sa@box\z@ + \noindent\lower\@tempdima\copy\sa@box + }% +} +\def\sa@papersize{% + \global\let\sa@papersize\relax + \special{papersize=\the\paperwidth,\the\paperheight}% + \global\sa@yoffset=\paperheight + \special{ps::% + \@percentchar\@percentchar HiResBoundingBox: 0 0 \the\paperwidth\space\the\paperheight^^J% + }% +} +\newlength\sa@yoffset +\fi \fi \ifstandalonebeamer \newenvironment{standaloneframe}{% @@ -114,19 +669,108 @@ \begin{frame}#1[environment=standaloneframe,#2]% }% \fi -\let\sa@cls@orig@document\document -\let\sa@cls@orig@enddocument\enddocument -\def\document{% - \sa@cls@orig@document - \let\documentclass\sa@documentclass % TODO: really required? - \sa@cls@afterbegindocument +\expandafter\ifx\csname sa@internal@run\endcsname\relax\else + \sa@convertfalse +\fi +\ifsa@convert +\begingroup +\let\on@line\@gobble +\def\sa@convert#1{% + \IfFileExists{\outfile}{% + \edef\filemodbefore{\csname pdffilemoddate\endcsname{\outfile}}% + }{% + \IfFileExists{\outname\outext}{% + \edef\filemodbefore{\csname pdffilemoddate\endcsname{\outname\outext}}% + }{% + \IfFileExists{\outname-0\outext}{% + \edef\filemodbefore{\csname pdffilemoddate\endcsname{\outname-0\outext}}% + }{% + \IfFileExists{\outname-1\outext}{% + \edef\filemodbefore{\csname pdffilemoddate\endcsname{\outname-1\outext}}% + }{% + \def\filemodbefore{}% + }}}}% + \immediate\write18{\sa@convert@latex\space -jobname '\sa@convert@subjobname' '\noexpand\expandafter\def\noexpand\csname sa@internal@run\noexpand\endcsname{1}\noexpand\input{\jobname}'}% + \edef\sa@convert@precommand{\sa@convert@precommand}% + \ifx\sa@convert@precommand\@empty\else + \immediate\write18{\sa@convert@precommand}% + \fi + \immediate\write18{\sa@convert@command}% + \@tempswafalse + \IfFileExists{\outfile}{% + \@tempswatrue + }{% + \IfFileExists{\outname\outext}{% + \@tempswatrue + \def\outfile{\outname\outext}% + }{% + \IfFileExists{\outname-0\outext}{% + \@tempswatrue + \def\outfile{\outname-0\outext}% + }{% + \IfFileExists{\outname-1\outext}{% + \@tempswatrue + \def\outfile{\outname-1\outext}% + }{% + }}}}% + \if@tempswa + \edef\filemodafter{\csname pdffilemoddate\endcsname{\outfile}}% + \ifx\filemodbefore\filemodafter + \expandafter\ifx\csname pdffilemoddate\endcsname\relax\else + \sa@convert@failuremsg{standalone}{#1}{}% + \fi + \else + \ClassInfo{standalone}{Conversion successfull.}% + \fi + \else + \sa@convert@failuremsg{standalone}{#1}{}% + \fi } -\def\enddocument{% - \sa@cls@beforeenddocument - \sa@cls@orig@enddocument +\let\subjobname\sa@convert@subjobname +\let\infile\sa@convert@infile +\let\inext\sa@convert@inext +\let\inname\sa@convert@inname +\let\gsdevice\sa@convert@gsdevice +\let\convertexe\sa@convert@convertexe +\let\gsexe\sa@convert@gsexe +\let\density\sa@convert@density +\let\size\sa@convert@size +\let\outext\sa@convert@outext +\let\outname\sa@convert@outname +\let\outfile\sa@convert@outfile +\let\percent\@percentchar +\ifcase0% + \expandafter\ifx\csname pdfshellescape\endcsname\relax + \ifeof18 \else 3\fi + \else\the\pdfshellescape\fi +\relax% 0 + \sa@convert@failuremsg + {standalone}{Shell escape disabled! Cannot convert file '\infile'.}{}% +\or% 1 + \sa@convert{Conversion unsuccessful!\MessageBreak + There might be something wrong with your\MessageBreak + conversation software or the file permissions!}% +\else% 2 or 3 + \sa@convert{Conversion failed! Please ensure that shell escape\MessageBreak is enabled (e.g. use '-shell-escape').}% +\fi +\endgroup +\expandafter\stop +\fi +\begingroup +\toks@\expandafter{% + \document + \sa@cls@afterbegindocument } -\def\sa@cls@afterbegindocument{\expandafter\standalone\ignorespaces} -\def\sa@cls@beforeenddocument{\unskip\endstandalone} +\xdef\document{\the\toks@}% +\toks@\expandafter{% + \expandafter + \sa@cls@beforeenddocument + \enddocument +} +\xdef\enddocument{\the\toks@}% +\endgroup +\def\sa@cls@afterbegindocument{\standalone\ignorespaces} +\def\sa@cls@beforeenddocument{\ifhmode\unskip\fi\endstandalone} \endinput %% %% End of file `standalone.cls'. |