diff options
author | Karl Berry <karl@freefriends.org> | 2015-07-17 22:41:42 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2015-07-17 22:41:42 +0000 |
commit | de0e37b2f2d2da31dfe9bcbfbb27140db33fad40 (patch) | |
tree | d38854a57b1d412acfa51256c0e4c56058940dbe /Master/texmf-dist/tex/latex/standalone/standalone.cls | |
parent | 62111b5c7ed986bbc803ac5f044c49b508f5dde1 (diff) |
standalone (16jul15)
git-svn-id: svn://tug.org/texlive/trunk@37875 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 | 123 |
1 files changed, 87 insertions, 36 deletions
diff --git a/Master/texmf-dist/tex/latex/standalone/standalone.cls b/Master/texmf-dist/tex/latex/standalone/standalone.cls index 84c696f0d31..958de71d619 100644 --- a/Master/texmf-dist/tex/latex/standalone/standalone.cls +++ b/Master/texmf-dist/tex/latex/standalone/standalone.cls @@ -18,8 +18,8 @@ %% \NeedsTeXFormat{LaTeX2e} \ProvidesClass{standalone}[% - 2012/09/15 - v1.1b + 2015/07/15 + v1.2 Class to compile TeX sub-files standalone] \newif\ifstandalone \standalonetrue @@ -111,6 +111,7 @@ \newif\ifsa@preview \newif\ifsa@crop \newif\ifsa@multi +\newif\ifsa@multido \newif\ifsa@varwidth \newif\ifsa@ignorerest \newif\ifsa@ignoreempty @@ -177,6 +178,12 @@ \sa@clsoption{multi}[true]{% \sa@boolorvalue{multi}{#1}{\sa@multitrue\AtBeginDocument{\standaloneenv{#1}}}% } +\sa@clsoption{multido}[true]{% + \sa@boolean{multido}{#1}% + \ifsa@multido + \setkeys{standalone.cls}{multi=samultido}% + \fi +} \sa@clsoption{math}[true]{% \sa@boolean{math}{#1}% \ifsa@math @@ -383,9 +390,11 @@ } \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}% + \let\sa@convert@pageoffset\m@ne } \sa@convertoption{ghostscript}[]{% \def\sa@convert@command{\gsexe\space -dSAFER -dBATCH -dNOPAUSE -sDEVICE=\gsdevice\space -r\density\space -sOutputFile=\outfile\space \infile}% + \let\sa@convert@pageoffset\z@ } \sa@convertvar{latexoptions}{ -shell-escape } \sa@convertvar{subjobname}{\jobname} @@ -397,7 +406,8 @@ \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{outfile}{\outname\ifsa@multi\sa@multi@pagemark\fi\outext} +\def\sa@multi@pagemark{-\percent0d}% \sa@convertvar{density}{300} \sa@convertvar{gsdevice}{% \expandafter\ifx\csname sa@gsdevice@\outext\endcsname\relax @@ -460,6 +470,7 @@ \newcommand*{\standaloneconfig}{\setkeys{standalone.cls}} \let\@standaloneenv\@gobble \newcount\sa@internal +\newcounter{sapage} \let\standalone\empty \let\endstandalone\relax \def\sa@width{\linewidth} @@ -473,6 +484,36 @@ \AtBeginDocument{% \disable@keys{standalone.cls}{multi}% } +\expandafter\expandafter\expandafter\LoadClass +\expandafter\expandafter\expandafter[% +\expandafter\@classoptionslist +\expandafter]\expandafter{\sa@class} +\ifsa@ignorerest + \def\sa@startignore{\sa@boxit} +\else + \let\sa@startignore\relax +\fi +\ifsa@ignorerest + \def\sa@stopignore{\endsa@boxit} +\else + \let\sa@stopignore\relax +\fi +\ifsa@multido +\RequirePackage{multido} +\let\sa@orig@multido@\multido@ +\renewcommand{\multido@}[6]{% + \sa@stopignore + \sa@orig@multido@{#1}{#2}{#3}{#4}{#5}{% + \sa@startignore + \begin{samultido}% + \let\multido@\sa@orig@multido@ + #6% + \end{samultido}% + \sa@stopignore + }% + \sa@startignore +} +\fi \ifsa@convert \ifx\sa@convert@quote\relax \begingroup @@ -502,10 +543,6 @@ \fi \fi \fi -\expandafter\expandafter\expandafter\LoadClass -\expandafter\expandafter\expandafter[% -\expandafter\@classoptionslist -\expandafter]\expandafter{\sa@class} \ifsa@varwidth \RequirePackage{varwidth} \fi @@ -532,6 +569,7 @@ \fi \expandafter\def\csname #1\endcsname{% \ifnum\sa@internal=0 + \addtocounter{sapage}\@ne \preview \sa@varwidth \fi @@ -572,17 +610,13 @@ }% \renewenvironment{standalone}{% \ifsa@multi - \ifsa@ignorerest - \sa@boxit - \fi + \sa@startignore \else \sa@boxit \fi }{% \ifsa@multi - \ifsa@ignorerest - \endsa@boxit - \fi + \sa@stopignore \else \endsa@boxit \sa@handlebox @@ -599,6 +633,7 @@ \fi \expandafter\def\csname #1\endcsname{% \ifnum\sa@internal=0 + \addtocounter{sapage}\@ne \edef\@tempa{\endgroup \noexpand\endsa@boxit \begingroup @@ -629,6 +664,7 @@ \fi \expandafter\def\csname #1\endcsname{% \ifnum\sa@internal=0 + \addtocounter{sapage}\@ne \sa@boxit \fi \advance\sa@internal\@ne @@ -773,6 +809,9 @@ }% \fi \expandafter\ifx\csname sa@internal@run\endcsname\relax\else + \AtEndDocument{% + \immediate\write\@mainaux{\gdef\noexpand\sa@multi@numpages{\arabic{sapage}}}% + } \sa@convertfalse \fi \ifsa@convert @@ -794,8 +833,8 @@ }{% \def\filemodbefore{}% }}}}% - \edef\@tempa{\jobname} - \edef\@tempb{\sa@convert@subjobname} + \edef\@tempa{\jobname}% + \edef\@tempb{\sa@convert@subjobname}% \@onelevel@sanitize\@tempa \@onelevel@sanitize\@tempb \@tempswafalse @@ -809,6 +848,34 @@ -jobname \sa@convert@quote\sa@convert@subjobname\sa@convert@quote\space \sa@convert@quote\string\expandafter\string\def\string\csname\space sa@internal@run\string\endcsname{1}\string\input{\sa@convert@mainfile}\sa@convert@quote}% + \begingroup + \gdef\sa@multi@numpages{1}% + \IfFileExists{\sa@convert@subjobname.aux}{% + \globaldefs=\m@ne + \@@input\sa@convert@subjobname.aux\relax + \globaldefs=\z@ + \xdef\sa@multi@numpages{\sa@multi@numpages}% + }{}% + \endgroup + \setcounter{sapage}{\sa@multi@numpages}% + \addtocounter{sapage}\sa@convert@pageoffset + \ifnum\c@sapage=\z@ + \def\sa@multi@pagemark{}% + \edef\sa@lastoutfile{\outfile}% + \else + \@tempcnta\z@ + \loop\ifnum\value{sapage}>0 + \advance\@tempcnta\@ne + \divide\c@sapage by 10\relax + \repeat + \edef\sa@multi@pagemark{-\percent0\the\@tempcnta d}% + \begingroup + \setcounter{sapage}{\sa@multi@numpages}% + \addtocounter{sapage}\sa@convert@pageoffset + \def\sa@multi@pagemark{-\arabic{sapage}}% + \xdef\sa@lastoutfile{\outfile}% + \endgroup + \fi \if@tempswa \edef\infile@filemodafter{\csname pdffilemoddate\endcsname{\infile}}% \ifx\infile@filemodbefore\infile@filemodafter @@ -821,34 +888,18 @@ \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}}% + \IfFileExists{\sa@lastoutfile}{% + \edef\filemodafter{\csname pdffilemoddate\endcsname{\sa@lastoutfile}}% \ifx\filemodbefore\filemodafter \expandafter\ifx\csname pdffilemoddate\endcsname\relax\else \sa@convert@failuremsg{standalone}{#1}{}% \fi \else - \typeout{Class standalone:^^JOutput written on \outfile.}% + \typeout{Class standalone:^^JOutput written on \sa@lastoutfile.}% \fi - \else + }{% \sa@convert@failuremsg{standalone}{#1}{}% - \fi + }% } \let\subjobname\sa@convert@subjobname \let\mainfile\sa@convert@mainfile |