texlive[47110] Master/texmf-dist: standalone (25mar18)

commits+karl at tug.org commits+karl at tug.org
Sun Mar 25 23:25:52 CEST 2018


Revision: 47110
          http://tug.org/svn/texlive?view=revision&revision=47110
Author:   karl
Date:     2018-03-25 23:25:52 +0200 (Sun, 25 Mar 2018)
Log Message:
-----------
standalone (25mar18)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/standalone/README
    trunk/Master/texmf-dist/doc/latex/standalone/standalone.pdf
    trunk/Master/texmf-dist/source/latex/standalone/standalone.dtx
    trunk/Master/texmf-dist/tex/latex/standalone/standalone.cfg
    trunk/Master/texmf-dist/tex/latex/standalone/standalone.cls
    trunk/Master/texmf-dist/tex/latex/standalone/standalone.sty

Modified: trunk/Master/texmf-dist/doc/latex/standalone/README
===================================================================
--- trunk/Master/texmf-dist/doc/latex/standalone/README	2018-03-25 21:25:41 UTC (rev 47109)
+++ trunk/Master/texmf-dist/doc/latex/standalone/README	2018-03-25 21:25:52 UTC (rev 47110)
@@ -1,6 +1,6 @@
 LaTeX class and package 'standalone'
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Copyright (c) 2010-2012 by Martin Scharrer <martin at scharrer-online.de>
+Copyright (c) 2010-2018 by Martin Scharrer <martin at scharrer-online.de>
 Repository: http://bitbucket.org/martin_scharrer/standalone
 
 Allows TeX pictures or other TeX code in sub-files to be compiled standalone

Modified: trunk/Master/texmf-dist/doc/latex/standalone/standalone.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/source/latex/standalone/standalone.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/standalone/standalone.dtx	2018-03-25 21:25:41 UTC (rev 47109)
+++ trunk/Master/texmf-dist/source/latex/standalone/standalone.dtx	2018-03-25 21:25:52 UTC (rev 47110)
@@ -1,6 +1,6 @@
 % \iffalse meta-comment
 %<=*COPYRIGHT>
-%% Copyright (C) 2011-2012 by Martin Scharrer <martin at scharrer-online.de>
+%% Copyright (C) 2011-2017 by Martin Scharrer <martin at scharrer-online.de>
 %% ---------------------------------------------------------------------------
 %% This work may be distributed and/or modified under the
 %% conditions of the LaTeX Project Public License, either version 1.3
@@ -26,10 +26,10 @@
 \NeedsTeXFormat{LaTeX2e}
 \ProvidesFile{standalone.dtx}[%
 %<=*DATE>
-    2015/07/15
+    2018/03/24
 %<=/DATE>
 %<=*VERSION>
-    v1.2
+    v1.3
 %<=/VERSION>
     DTX file of the standalone bundle]
 \documentclass[a4paper,11pt]{ydoc}
@@ -89,6 +89,7 @@
 % manual.}
 % \changes{v1.1b}{2012/09/15}{Fixed issue with 'subpreambles' for Beamer documents.}
 % \changes{v1.2}{2012/12/31}{Fixed build issue with MiKTeX due to incorrect quoting character.}
+% \changes{v1.3}{2018/03/24}{Several fixes for new driver and LuaTeX versions. Other minor fixes in bundle and manual.}
 %
 % \GetFileInfo{\jobname.dtx}
 %
@@ -115,7 +116,7 @@
 % }%
 % \fi
 % \author{Martin Scharrer}
-% \email{martin at scharrer.me}
+% \email{martin at scharrer-online.de}
 % \repository{https://bitbucket.org/martin_scharrer/standalone}
 % \maketitle
 %
@@ -133,13 +134,24 @@
 % \tableofcontents
 % \end{multicols}
 %
+% \section{Online Resources and Help}
+% This bundle is released on the comprehensive \TeX\ archive network (CTAN) under \url{https://ctan.org/pkg/standalone}.
+% Any modern \LaTeX\ distribution should pick it from there automatically, though. CTAN now allows votes and comments on packages and such feedback is very welcome.
+%
+% The source code of this bundle is hosted on Bitbucket as Mercurial repository under \url{https://bitbucket.org/martin_scharrer/standalone/}.
+% The ticket system there should be used to report bugs or request new features: \url{https://bitbucket.org/martin_scharrer/standalone/issues/new}.
+%
+% User which need help with should search for an existing solution on the site TeX.Stackexchange.com: \url{https://tex.stackexchange.com/questions/tagged/standalone}
+% or post a new question: \url{https://tex.stackexchange.com/questions/ask?tags=standalone}.
+% The bundle author is an active user on TeX.SE but other users might help as well.
+%
 % \section{Installation}
-% This package is part of the two main \LaTeX\ distributions \emph{TeX Live} and \emph{MikTeX} and can be easily installed
+% This bundle is part of the two main \LaTeX\ distributions \emph{TeX Live} and \emph{MikTeX} and can be easily installed
 % with their package managers. It is also provided as TDS ZIP file on CTAN which can be used for a manual install.
 % Other packages are also required as described in \autoref{sec:dep}.
 %
 % \subsection{Installation with TeX Live}
-% Using a normal TeX Live the package is easily installed using the package manager \texttt{tlmgr}.
+% Using a normal TeX Live the bundle is easily installed using the package manager \texttt{tlmgr}.
 % The command \texttt{tlmgr install \csname @package\endcsname} will install it and \texttt{tlmgr update \csname
 % @package\endcsname} can be used to update it.
 %
@@ -148,11 +160,11 @@
 % regular package updates.
 %
 % \subsection{Installation with MikTeX}
-% The package can be easily installed using the MikTeX package manager as described by
+% The bundle can be easily installed using the MikTeX package manager as described by
 % \url{http://docs.miktex.org/manual/pkgmgt.html}. The MikTeX package name is identical to the normal package name.
 %
 % \subsection{Manual Installation from CTAN}
-% The package is also available on the Comprehensive TeX Archive Network (CTAN), both as the DTX/INS files and as TDS
+% The bundle is also available on the Comprehensive TeX Archive Network (CTAN), both as the DTX/INS files and as TDS
 % ZIP file, which can be used for a manual install. A manual install is only required if the used distribution does not
 % include the (required version of the) package.
 %
@@ -182,7 +194,7 @@
 %
 % \subsection{Dependencies}\label{sec:dep}
 % The \cls{standalone} class and package require the \pkg{xkeyval} package.
-% The packages \pkg{ifpdf}, \pkg{ifluatex} and \pkg{ifxetex} are loaded if available, otherwise some fall-back code is used.
+% The packages \pkg{ifpdf}, \pkg{ifluatex}, \pkg{ifxetex}, and \pkg{shellesc} are loaded if available, otherwise some fall-back code is used.
 % If enabled the class options \opt{varwidth}, \opt{preview} and \opt{beamer} require the package or class of the same name.
 %
 % The \pkg{standalone} package requires the \pkg{currfile} package (which in turn uses \pkg{filehook}) to track the correct file names of
@@ -361,7 +373,7 @@
 %
 % \DescribeKey{border}'='<length (all sides)>
 % \DescribeKey{border}'='{<length (left/right)>~<length (bottom/top)>}
-% \DescribeKey{border}'='{<length (left)>~<length (right)>~<length (bottom)>~<length (top)>}
+% \DescribeKey{border}'='{<length (left)>~<length (bottom)>~<length (right)>~<length (top)>}
 % This option allows to specify the border used by the \opt{preview} and \opt{crop} options.
 % An alternative name of this option is \opt{margin}.
 % The border can either be given using a single value for all sides, separately for the horizontal and vertical borders or for all sides separately.
@@ -601,6 +613,8 @@
 % the following default settings are used: PNG format, a density of 300dpi, no explicit size and the output file name is given by \Macro\jobname, i.e.\ the name of the \LaTeX\ document.
 % Using the \opt{convert} option with any value other than |false| will enabled it.
 % All normal conversion settings are listed in \autoref{tab:convopt}, while \autoref{tab:advconvopt} lists the more advanced options which e.g.\ can be used to modify the conversion command directly.
+% Note that macros used inside documentclass options must be protected from expansion. This can either be done wrapping the whole argument in an \Macro\unexpanded{..} (requires e-\TeX)
+% or by using \Macro\noexpand in front of any macro.
 %
 % \begin{table}
 % \vspace*{-10ex}%
@@ -639,15 +653,16 @@
 %  \midrule
 %     command  &  Command line used for conversion. & (see |imagemagick|) \\
 %     imagemagick & Sets the convert command to use Image Magick: \newline\bigskip
-%                   \hspace*{-5em}\hbox{\vtop{\hbox{\strut|command={\convertexe\space -density \density\space |\vrule height 2\ht\strutbox width 0pt{}\egroup
-%                                      \hbox\bgroup\strut|         \infile\space \ifx\size\empty\else |\egroup
-%                                      \hbox\bgroup\strut|         -resize \size\fi\space -quality 90 \outfile}|}}\hss} \\
+%                   \hspace*{-5em}\hbox{\vtop{\hbox{\strut|command=\unexpanded{{\convertexe\space -density \density\space |\vrule height 2\ht\strutbox width 0pt{}}%
+%                                      \hbox{\strut|         \infile\space \ifx\size\empty\else |}%
+%                                      \hbox{\strut|         -resize \size\fi\space -quality 90 \outfile}}|}}\hss} \\
 %     convertexe  & Name of the executable of Image Magick. & (see \autoref{sec:convprogs})  \\
 %     ghostscript & Sets the convert command to use Ghostscript: \newline\bigskip
-%                   \hspace*{-5em}\hbox{\vtop{\hbox{\strut|command={\gsexe\space -dSAFER -dBATCH -dNOPAUSE -sDEVICE=\gsdevice\space|\vrule height 2\ht\strutbox width 0pt{}\egroup
-%                                      \hbox\bgroup\strut|         -r\density\space -sOutputFile=\outfile\space \infile}|}}\hss} \\
+%                   \hspace*{-5em}\hbox{\vtop{\hbox{\strut|command=\unexpanded{{\gsexe\space -dSAFER -dBATCH -dNOPAUSE|\vrule height 2\ht\strutbox width 0pt{}}%
+%                                      \hbox{\strut|         -sDEVICE=\gsdevice\space -r\density\space|}%
+%                                      \hbox{\strut|         -sOutputFile=\outfile\space \infile}}|}}\hss} \\
 %     gsexe       & Name of the executable of Ghostscript. & (see \autoref{sec:convprogs})  \\
-%     precommand  & Command to be executed before the actual conversion command.  & {\tabular[t]{@{}l@{}}|dvips \jobname| (DVI/PS),\\empty (PDF)\endtabular} \\
+%     precommand  & Command to be executed before the actual conversion command.  & {\tabular[t]{@{}l@{}}|dvips \subjobname| (DVI/PS),\\empty (PDF)\endtabular} \\
 %     gsdevice    & The output device to be used for ghostscript. Already set up for PNG and JPG output. & \parbox[t]{15em}{Uses known device if defined for output format, otherwise the output format itself.}\\
 %     onfailure   & Sets if an type of `message' which should be triggered on conversion failure:  |error|, |warning|, |info| or |ignore|. & |warning| \\
 %  \bottomrule
@@ -819,7 +834,7 @@
 % With only the \opt{subpreambles} option set, the sub-preambles are simple read and executed unchanged. This includes the risk of option clashes if one package is loaded with different
 % options inside the sub-preambles and/or the main preamble. This is avoided by the \opt{sort} option, which accumulates all packages loaded by all sub-files together with their options.
 % The options are then marked to be loaded by the package using \LaTeX{}s \cs{PassOptionsToPackage} macro. The packages are loaded at the end of the preamble using the \cs{AtBeginDocument} hook.
-% This allows the user to load the same packages with own options in the main file, after the |subversion| package is loaded, without any option clashes.
+% This allows the user to load the same packages with own options in the main file, after the |standalone| package is loaded, without any option clashes.
 %
 % \DescribeKey{print}'=true|false'
 % While the \opt{sort} option is giving already good results, problems with the order of packages can still occur. Some packages provide, redefine or patch the same macros, so that they must be loaded in
@@ -1228,6 +1243,17 @@
 % Define if-switches for TeX formats.
 % This loads the corresponding packages if available, but falls back to some own code if they are not installed.
 %    \begin{macrocode}
+\expandafter\ifx\csname ShellEscape\endcsname\relax
+    \IfFileExists{shellesc.sty}{
+        \RequirePackage{shellesc}
+        \@ifpackagelater{shellesc}{2016/04/29}{
+        }{
+            \protected\def\ShellEscape{\immediate\write18 }
+        }
+    }{
+        \protected\def\ShellEscape{\immediate\write18 }
+    }
+\fi
 \expandafter\ifx\csname ifluatex\endcsname\relax
     \IfFileExists{ifluatex.sty}{\@firstoftwo}{\@secondoftwo}{%
         \RequirePackage{ifluatex}
@@ -1809,7 +1835,7 @@
 % \begin{key}{standalone.cls/convert}{imagemagick}
 %    \begin{macrocode}
 \sa at convertoption{imagemagick}[]{%
-    \def\sa at convert@command{\convertexe\space -density \density\space \infile\space \ifx\size\empty\else -resize \size\fi\space -quality 90 \outfile}%
+    \def\sa at convert@command{\convertexe\space -density \density\space -units PixelsPerInch \infile\space \ifx\size\empty\else -resize \size\fi\space -quality 90 \outfile}%
     \let\sa at convert@pageoffset\m at ne
 }
 %    \end{macrocode}
@@ -1865,7 +1891,7 @@
 \else
     \sa at convertvar{latex}{latex}
     \sa at convertvar{inext}{.ps}
-    \sa at convertvar{precommand}{dvips \jobname.dvi}
+    \sa at convertvar{precommand}{dvips \subjobname.dvi}
     \setkeys{standalone.cls/convert}{ghostscript}
 \fi\fi\fi
 %    \end{macrocode}
@@ -2383,8 +2409,21 @@
   \relax
     \def\sa at placebox{%
         \newpage
-        \global\pdfpagewidth=\wd\sa at box
-        \global\pdfpageheight=\ht\sa at box
+        \ifluatex
+          \ifnum\luatexversion<85
+            % LuaLaTeX < 0.85 does define the PDF-specific globals.
+            \global\pdfpagewidth=\wd\sa at box
+            \global\pdfpageheight=\ht\sa at box
+          \else
+            % LuaLaTeX >= 0.85 doesn't define the PDF-specific globals.
+            \global\pagewidth=\wd\sa at box
+            \global\pageheight=\ht\sa at box
+          \fi
+        \else
+          % Not LuaLaTeX at all, so still need this.
+          \global\pdfpagewidth=\wd\sa at box
+          \global\pdfpageheight=\ht\sa at box
+        \fi
         \global\paperwidth=\wd\sa at box
         \global\paperheight=\ht\sa at box
         \global\hsize=\wd\sa at box
@@ -2458,10 +2497,14 @@
 %    \begin{macrocode}
 \def\sa at papersize{%
     \global\let\sa at papersize\relax
-    \special{papersize=\the\paperwidth,\the\paperheight}%
     \global\sa at yoffset=\paperheight
-    \special{ps::%
-        \@percentchar\@percentchar HiResBoundingBox: 0 0 \the\paperwidth\space\the\paperheight^^J%
+    \global\setbox\@begindvibox\vbox{%
+        \special{papersize=\the\paperwidth,\the\paperheight}%
+        \special{ps::%
+            \@percentchar\@percentchar HiResBoundingBox: 0 0 \the\paperwidth\space\the\paperheight^^J%
+        }%
+        \unvbox\@begindvibox
+        \special{papersize=\the\paperwidth,\the\paperheight}%
     }%
 }
 %    \end{macrocode}
@@ -2536,7 +2579,7 @@
 %    \begin{macrocode}
 \expandafter\ifx\csname sa at internal@run\endcsname\relax\else
     \AtEndDocument{%
-        \immediate\write\@mainaux{\gdef\noexpand\sa at multi@numpages{\arabic{sapage}}}%
+        \immediate\write\@mainaux{\noexpand\@gobbletwo\noexpand\sa at multi@setnumpages{\arabic{sapage}}}%
     }
     \sa at convertfalse
 \fi
@@ -2578,20 +2621,31 @@
     \else
         \global\let\sa at convert@stop\relax
     \fi
-    \immediate\write18{\sa at convert@latex\space\sa at convert@latexoptions\space
+    \ShellEscape{\sa at convert@latex\space\sa at convert@latexoptions\space
         -jobname \sa at convert@quote\sa at convert@subjobname\sa at convert@quote\space
         \sa at convert@quote\string\expandafter\string\def\string\csname\space
         sa at internal@run\string\endcsname{1}\string\input{\sa at convert@mainfile}\sa at convert@quote}%
 %
     \begingroup
-    \gdef\sa at multi@numpages{1}%
-    \IfFileExists{\sa at convert@subjobname.aux}{%
-        \globaldefs=\m at ne
-        \@@input\sa at convert@subjobname.aux\relax
-        \globaldefs=\z@
-        \xdef\sa at multi@numpages{\sa at multi@numpages}%
-    }{}%
+    \IfFileExists{\sa at convert@subjobname.aux}{\@tempswatrue}{\@tempswafalse}%
+    \if at tempswa
+      \newread\sa at read
+      \def\@tempa##1\sa at multi@setnumpages##2##3\@nnil{%
+        \def\@tempc{##2}%
+        \ifx\@tempc\@nnil\else
+          \gdef\sa at multi@numpages{##2}%
+        \fi
+      }%
+      \endlinechar=\m at ne
+      \immediate\openin\sa at read=\sa at convert@subjobname.aux\relax
+      \loop\unless\ifeof\sa at read
+        \read\sa at read to\@tempb
+        \expandafter\@tempa\@tempb\sa at multi@setnumpages\@nil\@empty\@nnil
+      \repeat
+      \immediate\closein\sa at read
+    \fi
     \endgroup
+%
     \setcounter{sapage}{\sa at multi@numpages}%
     \addtocounter{sapage}\sa at convert@pageoffset
     \ifnum\c at sapage=\z@
@@ -2622,9 +2676,9 @@
 %    \begin{macrocode}
     \edef\sa at convert@precommand{\sa at convert@precommand}%
     \ifx\sa at convert@precommand\@empty\else
-        \immediate\write18{\sa at convert@precommand}%
+        \ShellEscape{\sa at convert@precommand}%
     \fi
-    \immediate\write18{\sa at convert@command}%
+    \ShellEscape{\sa at convert@command}%
     \@tempswafalse
     \IfFileExists{\sa at lastoutfile}{%
         \edef\filemodafter{\csname pdffilemoddate\endcsname{\sa at lastoutfile}}%
@@ -2665,7 +2719,22 @@
 %    \begin{macrocode}
 \ifcase0%
     \expandafter\ifx\csname pdfshellescape\endcsname\relax
-    \ifeof18 \else 3\fi
+    \ifcase
+      \ifx\pdfshellescape\@undefined
+        \ifx\shellescape\@undefined
+          \ifx\directlua\@undefined
+            \z@
+          \else
+            \directlua{%
+              tex.sprint((status.shell_escape or os.execute()) .. " ")}
+          \fi
+        \else
+          \shellescape
+        \fi
+      \else
+        \pdfshellescape
+      \fi
+    \else 3\fi
     \else\the\pdfshellescape\fi
 \relax% 0
     \sa at convert@failuremsg
@@ -2801,6 +2870,17 @@
 % Define if-switches for TeX formats.
 % This loads the corresponding packages if available, but falls back to some own code if they are not installed.
 %    \begin{macrocode}
+\expandafter\ifx\csname ShellEscape\endcsname\relax
+    \IfFileExists{shellesc.sty}{
+        \RequirePackage{shellesc}
+        \@ifpackagelater{shellesc}{2016/04/29}{
+        }{
+            \protected\def\ShellEscape{\immediate\write18 }
+        }
+    }{
+        \protected\def\ShellEscape{\immediate\write18 }
+    }
+\fi
 \expandafter\ifx\csname ifluatex\endcsname\relax
     \IfFileExists{ifluatex.sty}{
         \RequirePackage{ifluatex}
@@ -3638,10 +3718,13 @@
 % Process |.sta| file from last run. All changes must be made by own macros which define the value globally.
 % Therefore the input is wrapped in a group. Some spaces or special line endings could process typeset content,
 % which causes errors inside the preamble. To be on the save side the input `content' is stored in a temp box.
+% The normal catcode of the `@' character is restored because comparing the previous subpreamble with the current one
+% would fail otherwise if the |standalone| package is loaded while |\makeatletter| is active.
 %    \begin{macrocode}
 \begingroup
   \setbox\@tempboxa\hbox{%
-  \InputIfFileExists{\jobname.sta}{}{\PackageInfo{standalone}{STA file not found!}{}{}}%
+    \makeatother
+    \InputIfFileExists{\jobname.sta}{}{\PackageInfo{standalone}{STA file not found!}{}{}}%
   }%
 \endgroup
 %    \end{macrocode}
@@ -4023,6 +4106,9 @@
                 \advance\sa at internal\m at ne
                 \ifnum\sa at internal=0
                     \endsa at boxit
+                    \ifx\sa at requestedpage\@empty
+\let\sa at requestedpage\sa at allpages
+    \fi
                     \ifx\sa at requestedpage\sa at allpages
                         \usebox\sa at box
                     \else
@@ -4268,16 +4354,7 @@
             \expandafter\endgroup
             \expandafter\@tempa\expandafter{\sa at subfile@options}%
             \sa at atendofclass
-            \ifpdf
-                \ifx\GPT at page\@empty\else
-                    \let\sa at requestedpage\GPT at page
-                \fi
-            \else
-            \ifxetex
-                \ifx\Gin at XeTeX@page\@empty\else
-                    \let\sa at requestedpage\Gin at XeTeX@page
-                \fi
-            \fi\fi
+    \let\sa at requestedpage\Gin at page
             \sa at pagenum\z@
             \sa at beginbox
 % Determinate required size files (normal classes or KOMA Script).
@@ -4480,7 +4557,21 @@
 % The state of the shell escape is checked.
 %    \begin{macrocode}
 \def\sa at buildgraphic#1{%
-    \ifeof18
+    \ifcase
+      \ifx\pdfshellescape\@undefined
+        \ifx\shellescape\@undefined
+          \ifx\directlua\@undefined
+            \z@
+          \else
+            \directlua{%
+              tex.sprint((status.shell_escape or os.execute()) .. " ")}
+          \fi
+        \else
+          \shellescape
+        \fi
+      \else
+        \pdfshellescape
+      \fi
         \PackageError{standalone}{Shell escape needed to create graphic! Use the '-shell-escape' option.}{}%
     \else
         \begingroup
@@ -4492,9 +4583,9 @@
         \let\buildjobname\sa at build@jobname
         \sa at setquote
         \let\quote\sa at build@quote
-        \immediate\write18{\sa at build@command}%
+        \ShellEscape{\sa at build@command}%
         \ifx\sa at build@postcommand\@empty\else
-            \immediate\write18{\sa at build@postcommand}%
+            \ShellEscape{\sa at build@postcommand}%
         \fi
         \IfFileExists{\outfile}{%
             \edef\filemodafter{\csname pdffilemoddate\endcsname{\outfile}}%
@@ -4591,7 +4682,10 @@
 \standaloneconfig{crop}
 
 %% Option which 'preview' should be loaded with
+%% (will be ignored outside preamble)
+\expandafter\ifx\csname @notprerr\endcsname\PassOptionsToPackage\else
 \PassOptionsToPackage{active,tightpage}{preview}%
+\fi
 
 %% Enable 'preview' option by default:
 %%\standaloneconfig{preview}

Modified: trunk/Master/texmf-dist/tex/latex/standalone/standalone.cfg
===================================================================
--- trunk/Master/texmf-dist/tex/latex/standalone/standalone.cfg	2018-03-25 21:25:41 UTC (rev 47109)
+++ trunk/Master/texmf-dist/tex/latex/standalone/standalone.cfg	2018-03-25 21:25:52 UTC (rev 47110)
@@ -1,7 +1,7 @@
 \NeedsTeXFormat{LaTeX2e}
 \ProvidesFile{standalone.cfg}[%
-    2015/07/15
-    v1.2
+    2018/03/24
+    v1.3
     Default configuration file for 'standalone' class]%
 %% Enabled the "varwidth" option if the "varwidth" package is available:
 %%\IfFileExists{varwidth.sty}{%
@@ -12,7 +12,10 @@
 \standaloneconfig{crop}
 
 %% Option which 'preview' should be loaded with
+%% (will be ignored outside preamble)
+\expandafter\ifx\csname @notprerr\endcsname\PassOptionsToPackage\else
 \PassOptionsToPackage{active,tightpage}{preview}%
+\fi
 
 %% Enable 'preview' option by default:
 %%\standaloneconfig{preview}

Modified: trunk/Master/texmf-dist/tex/latex/standalone/standalone.cls
===================================================================
--- trunk/Master/texmf-dist/tex/latex/standalone/standalone.cls	2018-03-25 21:25:41 UTC (rev 47109)
+++ trunk/Master/texmf-dist/tex/latex/standalone/standalone.cls	2018-03-25 21:25:52 UTC (rev 47110)
@@ -1,4 +1,4 @@
-%% Copyright (C) 2011-2012 by Martin Scharrer <martin at scharrer-online.de>
+%% Copyright (C) 2011-2017 by Martin Scharrer <martin at scharrer-online.de>
 %% ---------------------------------------------------------------------------
 %% This work may be distributed and/or modified under the
 %% conditions of the LaTeX Project Public License, either version 1.3
@@ -18,8 +18,8 @@
 %%
 \NeedsTeXFormat{LaTeX2e}
 \ProvidesClass{standalone}[%
-    2015/07/15
-    v1.2
+    2018/03/24
+    v1.3
     Class to compile TeX sub-files standalone]
 \newif\ifstandalone
 \standalonetrue
@@ -60,6 +60,17 @@
         \default at bp\sa at border@top{#4}%
     \fi\fi
 }%
+\expandafter\ifx\csname ShellEscape\endcsname\relax
+    \IfFileExists{shellesc.sty}{
+        \RequirePackage{shellesc}
+        \@ifpackagelater{shellesc}{2016/04/29}{
+        }{
+            \protected\def\ShellEscape{\immediate\write18 }
+        }
+    }{
+        \protected\def\ShellEscape{\immediate\write18 }
+    }
+\fi
 \expandafter\ifx\csname ifluatex\endcsname\relax
     \IfFileExists{ifluatex.sty}{\@firstoftwo}{\@secondoftwo}{%
         \RequirePackage{ifluatex}
@@ -389,7 +400,7 @@
     \sa at convertvar{outext}{.svg}
 }
 \sa at convertoption{imagemagick}[]{%
-    \def\sa at convert@command{\convertexe\space -density \density\space \infile\space \ifx\size\empty\else -resize \size\fi\space -quality 90 \outfile}%
+    \def\sa at convert@command{\convertexe\space -density \density\space -units PixelsPerInch \infile\space \ifx\size\empty\else -resize \size\fi\space -quality 90 \outfile}%
     \let\sa at convert@pageoffset\m at ne
 }
 \sa at convertoption{ghostscript}[]{%
@@ -436,7 +447,7 @@
 \else
     \sa at convertvar{latex}{latex}
     \sa at convertvar{inext}{.ps}
-    \sa at convertvar{precommand}{dvips \jobname.dvi}
+    \sa at convertvar{precommand}{dvips \subjobname.dvi}
     \setkeys{standalone.cls/convert}{ghostscript}
 \fi\fi\fi
 \begingroup
@@ -711,8 +722,21 @@
   \relax
     \def\sa at placebox{%
         \newpage
-        \global\pdfpagewidth=\wd\sa at box
-        \global\pdfpageheight=\ht\sa at box
+        \ifluatex
+          \ifnum\luatexversion<85
+            % LuaLaTeX < 0.85 does define the PDF-specific globals.
+            \global\pdfpagewidth=\wd\sa at box
+            \global\pdfpageheight=\ht\sa at box
+          \else
+            % LuaLaTeX >= 0.85 doesn't define the PDF-specific globals.
+            \global\pagewidth=\wd\sa at box
+            \global\pageheight=\ht\sa at box
+          \fi
+        \else
+          % Not LuaLaTeX at all, so still need this.
+          \global\pdfpagewidth=\wd\sa at box
+          \global\pdfpageheight=\ht\sa at box
+        \fi
         \global\paperwidth=\wd\sa at box
         \global\paperheight=\ht\sa at box
         \global\hsize=\wd\sa at box
@@ -768,10 +792,14 @@
 }
 \def\sa at papersize{%
     \global\let\sa at papersize\relax
-    \special{papersize=\the\paperwidth,\the\paperheight}%
     \global\sa at yoffset=\paperheight
-    \special{ps::%
-        \@percentchar\@percentchar HiResBoundingBox: 0 0 \the\paperwidth\space\the\paperheight^^J%
+    \global\setbox\@begindvibox\vbox{%
+        \special{papersize=\the\paperwidth,\the\paperheight}%
+        \special{ps::%
+            \@percentchar\@percentchar HiResBoundingBox: 0 0 \the\paperwidth\space\the\paperheight^^J%
+        }%
+        \unvbox\@begindvibox
+        \special{papersize=\the\paperwidth,\the\paperheight}%
     }%
 }
 \newlength\sa at yoffset
@@ -810,7 +838,7 @@
 \fi
 \expandafter\ifx\csname sa at internal@run\endcsname\relax\else
     \AtEndDocument{%
-        \immediate\write\@mainaux{\gdef\noexpand\sa at multi@numpages{\arabic{sapage}}}%
+        \immediate\write\@mainaux{\noexpand\@gobbletwo\noexpand\sa at multi@setnumpages{\arabic{sapage}}}%
     }
     \sa at convertfalse
 \fi
@@ -844,18 +872,28 @@
     \else
         \global\let\sa at convert@stop\relax
     \fi
-    \immediate\write18{\sa at convert@latex\space\sa at convert@latexoptions\space
+    \ShellEscape{\sa at convert@latex\space\sa at convert@latexoptions\space
         -jobname \sa at convert@quote\sa at convert@subjobname\sa at convert@quote\space
         \sa at convert@quote\string\expandafter\string\def\string\csname\space
         sa at internal@run\string\endcsname{1}\string\input{\sa at convert@mainfile}\sa at convert@quote}%
     \begingroup
-    \gdef\sa at multi@numpages{1}%
-    \IfFileExists{\sa at convert@subjobname.aux}{%
-        \globaldefs=\m at ne
-        \@@input\sa at convert@subjobname.aux\relax
-        \globaldefs=\z@
-        \xdef\sa at multi@numpages{\sa at multi@numpages}%
-    }{}%
+    \IfFileExists{\sa at convert@subjobname.aux}{\@tempswatrue}{\@tempswafalse}%
+    \if at tempswa
+      \newread\sa at read
+      \def\@tempa##1\sa at multi@setnumpages##2##3\@nnil{%
+        \def\@tempc{##2}%
+        \ifx\@tempc\@nnil\else
+          \gdef\sa at multi@numpages{##2}%
+        \fi
+      }%
+      \endlinechar=\m at ne
+      \immediate\openin\sa at read=\sa at convert@subjobname.aux\relax
+      \loop\unless\ifeof\sa at read
+        \read\sa at read to\@tempb
+        \expandafter\@tempa\@tempb\sa at multi@setnumpages\@nil\@empty\@nnil
+      \repeat
+      \immediate\closein\sa at read
+    \fi
     \endgroup
     \setcounter{sapage}{\sa at multi@numpages}%
     \addtocounter{sapage}\sa at convert@pageoffset
@@ -884,9 +922,9 @@
     \fi
     \edef\sa at convert@precommand{\sa at convert@precommand}%
     \ifx\sa at convert@precommand\@empty\else
-        \immediate\write18{\sa at convert@precommand}%
+        \ShellEscape{\sa at convert@precommand}%
     \fi
-    \immediate\write18{\sa at convert@command}%
+    \ShellEscape{\sa at convert@command}%
     \@tempswafalse
     \IfFileExists{\sa at lastoutfile}{%
         \edef\filemodafter{\csname pdffilemoddate\endcsname{\sa at lastoutfile}}%
@@ -918,7 +956,22 @@
 \let\quote\sa at convert@quote
 \ifcase0%
     \expandafter\ifx\csname pdfshellescape\endcsname\relax
-    \ifeof18 \else 3\fi
+    \ifcase
+      \ifx\pdfshellescape\@undefined
+        \ifx\shellescape\@undefined
+          \ifx\directlua\@undefined
+            \z@
+          \else
+            \directlua{%
+              tex.sprint((status.shell_escape or os.execute()) .. " ")}
+          \fi
+        \else
+          \shellescape
+        \fi
+      \else
+        \pdfshellescape
+      \fi
+    \else 3\fi
     \else\the\pdfshellescape\fi
 \relax% 0
     \sa at convert@failuremsg

Modified: trunk/Master/texmf-dist/tex/latex/standalone/standalone.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/standalone/standalone.sty	2018-03-25 21:25:41 UTC (rev 47109)
+++ trunk/Master/texmf-dist/tex/latex/standalone/standalone.sty	2018-03-25 21:25:52 UTC (rev 47110)
@@ -1,4 +1,4 @@
-%% Copyright (C) 2011-2012 by Martin Scharrer <martin at scharrer-online.de>
+%% Copyright (C) 2011-2017 by Martin Scharrer <martin at scharrer-online.de>
 %% ---------------------------------------------------------------------------
 %% This work may be distributed and/or modified under the
 %% conditions of the LaTeX Project Public License, either version 1.3
@@ -19,8 +19,8 @@
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \NeedsTeXFormat{LaTeX2e}
 \ProvidesPackage{standalone}[%
-    2015/07/15
-    v1.2
+    2018/03/24
+    v1.3
     Package to include TeX sub-files with preambles]
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \@ifundefined{ifstandalone}{%
@@ -37,6 +37,17 @@
 \@ifundefined{IfStandalone}{%
     \let\IfStandalone\@secondoftwo
 }{}
+\expandafter\ifx\csname ShellEscape\endcsname\relax
+    \IfFileExists{shellesc.sty}{
+        \RequirePackage{shellesc}
+        \@ifpackagelater{shellesc}{2016/04/29}{
+        }{
+            \protected\def\ShellEscape{\immediate\write18 }
+        }
+    }{
+        \protected\def\ShellEscape{\immediate\write18 }
+    }
+\fi
 \expandafter\ifx\csname ifluatex\endcsname\relax
     \IfFileExists{ifluatex.sty}{
         \RequirePackage{ifluatex}
@@ -539,7 +550,8 @@
 \else
 \begingroup
   \setbox\@tempboxa\hbox{%
-  \InputIfFileExists{\jobname.sta}{}{\PackageInfo{standalone}{STA file not found!}{}{}}%
+    \makeatother
+    \InputIfFileExists{\jobname.sta}{}{\PackageInfo{standalone}{STA file not found!}{}{}}%
   }%
 \endgroup
 
@@ -773,6 +785,9 @@
                 \advance\sa at internal\m at ne
                 \ifnum\sa at internal=0
                     \endsa at boxit
+                    \ifx\sa at requestedpage\@empty
+\let\sa at requestedpage\sa at allpages
+    \fi
                     \ifx\sa at requestedpage\sa at allpages
                         \usebox\sa at box
                     \else
@@ -937,16 +952,7 @@
             \expandafter\endgroup
             \expandafter\@tempa\expandafter{\sa at subfile@options}%
             \sa at atendofclass
-            \ifpdf
-                \ifx\GPT at page\@empty\else
-                    \let\sa at requestedpage\GPT at page
-                \fi
-            \else
-            \ifxetex
-                \ifx\Gin at XeTeX@page\@empty\else
-                    \let\sa at requestedpage\Gin at XeTeX@page
-                \fi
-            \fi\fi
+    \let\sa at requestedpage\Gin at page
             \sa at pagenum\z@
             \sa at beginbox
             \@ifundefined{KOMAClassName}{%
@@ -1087,7 +1093,21 @@
     \fi
 }
 \def\sa at buildgraphic#1{%
-    \ifeof18
+    \ifcase
+      \ifx\pdfshellescape\@undefined
+        \ifx\shellescape\@undefined
+          \ifx\directlua\@undefined
+            \z@
+          \else
+            \directlua{%
+              tex.sprint((status.shell_escape or os.execute()) .. " ")}
+          \fi
+        \else
+          \shellescape
+        \fi
+      \else
+        \pdfshellescape
+      \fi
         \PackageError{standalone}{Shell escape needed to create graphic! Use the '-shell-escape' option.}{}%
     \else
         \begingroup
@@ -1099,9 +1119,9 @@
         \let\buildjobname\sa at build@jobname
         \sa at setquote
         \let\quote\sa at build@quote
-        \immediate\write18{\sa at build@command}%
+        \ShellEscape{\sa at build@command}%
         \ifx\sa at build@postcommand\@empty\else
-            \immediate\write18{\sa at build@postcommand}%
+            \ShellEscape{\sa at build@postcommand}%
         \fi
         \IfFileExists{\outfile}{%
             \edef\filemodafter{\csname pdffilemoddate\endcsname{\outfile}}%



More information about the tex-live-commits mailing list