summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/standalone/standalone.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/latex/standalone/standalone.dtx')
-rw-r--r--Master/texmf-dist/source/latex/standalone/standalone.dtx194
1 files changed, 144 insertions, 50 deletions
diff --git a/Master/texmf-dist/source/latex/standalone/standalone.dtx b/Master/texmf-dist/source/latex/standalone/standalone.dtx
index 194eed9e9eb..30884fd6d9a 100644
--- a/Master/texmf-dist/source/latex/standalone/standalone.dtx
+++ b/Master/texmf-dist/source/latex/standalone/standalone.dtx
@@ -1,6 +1,6 @@
% \iffalse meta-comment
%<=*COPYRIGHT>
-%% Copyright (C) 2011-2012 by Martin Scharrer <martin@scharrer-online.de>
+%% Copyright (C) 2011-2017 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.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@scharrer.me}
+% \email{martin@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@convertoption{imagemagick}[]{%
- \def\sa@convert@command{\convertexe\space -density \density\space \infile\space \ifx\size\empty\else -resize \size\fi\space -quality 90 \outfile}%
+ \def\sa@convert@command{\convertexe\space -density \density\space -units PixelsPerInch \infile\space \ifx\size\empty\else -resize \size\fi\space -quality 90 \outfile}%
\let\sa@convert@pageoffset\m@ne
}
% \end{macrocode}
@@ -1865,7 +1891,7 @@
\else
\sa@convertvar{latex}{latex}
\sa@convertvar{inext}{.ps}
- \sa@convertvar{precommand}{dvips \jobname.dvi}
+ \sa@convertvar{precommand}{dvips \subjobname.dvi}
\setkeys{standalone.cls/convert}{ghostscript}
\fi\fi\fi
% \end{macrocode}
@@ -2383,8 +2409,21 @@
\relax
\def\sa@placebox{%
\newpage
- \global\pdfpagewidth=\wd\sa@box
- \global\pdfpageheight=\ht\sa@box
+ \ifluatex
+ \ifnum\luatexversion<85
+ % LuaLaTeX < 0.85 does define the PDF-specific globals.
+ \global\pdfpagewidth=\wd\sa@box
+ \global\pdfpageheight=\ht\sa@box
+ \else
+ % LuaLaTeX >= 0.85 doesn't define the PDF-specific globals.
+ \global\pagewidth=\wd\sa@box
+ \global\pageheight=\ht\sa@box
+ \fi
+ \else
+ % Not LuaLaTeX at all, so still need this.
+ \global\pdfpagewidth=\wd\sa@box
+ \global\pdfpageheight=\ht\sa@box
+ \fi
\global\paperwidth=\wd\sa@box
\global\paperheight=\ht\sa@box
\global\hsize=\wd\sa@box
@@ -2458,10 +2497,14 @@
% \begin{macrocode}
\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%
+ \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@internal@run\endcsname\relax\else
\AtEndDocument{%
- \immediate\write\@mainaux{\gdef\noexpand\sa@multi@numpages{\arabic{sapage}}}%
+ \immediate\write\@mainaux{\noexpand\@gobbletwo\noexpand\sa@multi@setnumpages{\arabic{sapage}}}%
}
\sa@convertfalse
\fi
@@ -2578,20 +2621,31 @@
\else
\global\let\sa@convert@stop\relax
\fi
- \immediate\write18{\sa@convert@latex\space\sa@convert@latexoptions\space
+ \ShellEscape{\sa@convert@latex\space\sa@convert@latexoptions\space
-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}%
- }{}%
+ \IfFileExists{\sa@convert@subjobname.aux}{\@tempswatrue}{\@tempswafalse}%
+ \if@tempswa
+ \newread\sa@read
+ \def\@tempa##1\sa@multi@setnumpages##2##3\@nnil{%
+ \def\@tempc{##2}%
+ \ifx\@tempc\@nnil\else
+ \gdef\sa@multi@numpages{##2}%
+ \fi
+ }%
+ \endlinechar=\m@ne
+ \immediate\openin\sa@read=\sa@convert@subjobname.aux\relax
+ \loop\unless\ifeof\sa@read
+ \read\sa@read to\@tempb
+ \expandafter\@tempa\@tempb\sa@multi@setnumpages\@nil\@empty\@nnil
+ \repeat
+ \immediate\closein\sa@read
+ \fi
\endgroup
+%
\setcounter{sapage}{\sa@multi@numpages}%
\addtocounter{sapage}\sa@convert@pageoffset
\ifnum\c@sapage=\z@
@@ -2622,9 +2676,9 @@
% \begin{macrocode}
\edef\sa@convert@precommand{\sa@convert@precommand}%
\ifx\sa@convert@precommand\@empty\else
- \immediate\write18{\sa@convert@precommand}%
+ \ShellEscape{\sa@convert@precommand}%
\fi
- \immediate\write18{\sa@convert@command}%
+ \ShellEscape{\sa@convert@command}%
\@tempswafalse
\IfFileExists{\sa@lastoutfile}{%
\edef\filemodafter{\csname pdffilemoddate\endcsname{\sa@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@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@internal\m@ne
\ifnum\sa@internal=0
\endsa@boxit
+ \ifx\sa@requestedpage\@empty
+\let\sa@requestedpage\sa@allpages
+ \fi
\ifx\sa@requestedpage\sa@allpages
\usebox\sa@box
\else
@@ -4268,16 +4354,7 @@
\expandafter\endgroup
\expandafter\@tempa\expandafter{\sa@subfile@options}%
\sa@atendofclass
- \ifpdf
- \ifx\GPT@page\@empty\else
- \let\sa@requestedpage\GPT@page
- \fi
- \else
- \ifxetex
- \ifx\Gin@XeTeX@page\@empty\else
- \let\sa@requestedpage\Gin@XeTeX@page
- \fi
- \fi\fi
+ \let\sa@requestedpage\Gin@page
\sa@pagenum\z@
\sa@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@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@build@jobname
\sa@setquote
\let\quote\sa@build@quote
- \immediate\write18{\sa@build@command}%
+ \ShellEscape{\sa@build@command}%
\ifx\sa@build@postcommand\@empty\else
- \immediate\write18{\sa@build@postcommand}%
+ \ShellEscape{\sa@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}