diff options
Diffstat (limited to 'Master/texmf-dist/source')
-rw-r--r-- | Master/texmf-dist/source/latex/standalone/standalone.dtx | 314 |
1 files changed, 251 insertions, 63 deletions
diff --git a/Master/texmf-dist/source/latex/standalone/standalone.dtx b/Master/texmf-dist/source/latex/standalone/standalone.dtx index 4d42ed07be5..194eed9e9eb 100644 --- a/Master/texmf-dist/source/latex/standalone/standalone.dtx +++ b/Master/texmf-dist/source/latex/standalone/standalone.dtx @@ -26,10 +26,10 @@ \NeedsTeXFormat{LaTeX2e} \ProvidesFile{standalone.dtx}[% %<=*DATE> - 2012/09/15 + 2015/07/15 %<=/DATE> %<=*VERSION> - v1.1b + v1.2 %<=/VERSION> DTX file of the standalone bundle] \documentclass[a4paper,11pt]{ydoc} @@ -46,6 +46,13 @@ \OnlyDescription \lstset{numbers=none,columns=fullflexible} \def\Eurl#1{\edef\temp{{#1}}\expandafter\url\temp} +\IfFileExists{metalogo.sty}{% +\usepackage{metalogo}% +}% +{% +\providecommand{\XeLaTeX}{Xe\TeX} +\providecommand{\XeLaTeX}{Xe\LaTeX} +} \begin{document} \DocInput{\jobname.dtx} \PrintChanges @@ -54,7 +61,7 @@ %</driver> % \fi % -% \CheckSum{3606} +% \CheckSum{3781} % % \CharacterTable % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z @@ -81,6 +88,7 @@ % \changes{v1.1a}{2012/05/20}{Failed conversion now always creates a normal output file. Some requested changes in the % 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.} % % \GetFileInfo{\jobname.dtx} % @@ -213,8 +221,9 @@ % % A \cls{standalone} class is also provided to minimise the extra preamble code needed in this files. % It's usage is optional, but simplifies and standardises how picture files are compiled standalone. -% The class uses by default the \pkg{preview} package to create an output file which only contains the picture with no extra -% margins, page numbers or anything else. A configuration file \file{standalone.cfg} read by the class allows the user to adjust settings and macros easily +% The class uses by default the \opt{crop} option to create an output file which only contains the picture with no extra +% margins, page numbers or anything else. +% A configuration file \file{standalone.cfg} read by the class allows the user to adjust settings and macros easily % on a per directory base. % % \subsection{Quick instructions} @@ -233,7 +242,7 @@ % \subsection{Version update and backwards compatibility} % The default behaviour of v1.x of the \cls{standalone} class is slightly different as the one of v0.x, but should result in the same output for the majority of standalone files. % In previous versions the \opt{preview} option was enabled by default, but since v1.0 the new, similar \opt{crop} option is now used. -% This change should improve several use-cases, like avoiding the creation of a paragraph due to a trailing empty line and issues with TikZ patterns under XeLaTeX. +% This change should improve several use-cases, like avoiding the creation of a paragraph due to a trailing empty line and issues with TikZ patterns under \XeLaTeX. % However, paragraph breaks are now ignored by default, which should be no issue at all for picture and similar environments which are the main target of the \cls{standalone} class. % Additionally, the default border has been changed from the \pkg{preview} default of 0.50001bp to no border (0pt). % Both of these settings can be changed back to the old default by adding \Macro\standaloneconfig{preview,border=0.50001bp} in the configuration file @@ -342,7 +351,7 @@ % \DescribeKey{preview}'=true|false' % If enabled this option loads the \pkg{preview} package with the \opt{tightpage} option % and wraps the content into a \env{preview} environment. This crops the content to its natural size plus a specified border. -% Issues with the \pkg{preview} options and TikZ shadings under XeLaTeX have been reported. In this cases the \opt{crop} option should be used instead. +% Issues with the \pkg{preview} options and TikZ shadings under \XeLaTeX have been reported. In this cases the \opt{crop} option should be used instead. % Note that this option was enabled by default for versions before v1.0, but since then \opt{crop} is enabled by % default. % @@ -381,6 +390,23 @@ % It should be noted that which \opt{preview} such material is always ignored while not affecting local settings. % Therefore the \opt{ignorrest} option can be seen as a compatibility setting to make \opt{crop} act more like \opt{preview}, if this is required by the user. % +% +% \DescribeKey{multido}'=true|false' +% Often the \pkg{multido} package with its \Macro\multido macro is used to produce several iterations of a diagram. +% Usually every iteration should be placed on a seperate page. This option simplifies this task be changing +% \Macro\multido to automatically wrap the content (3rd argument) in a \opt{multi} environment. +% This option will only work if the \Macro\multido macro is on the top level and not part of an environment like \env{pspicture}. +% +% The \opt{ignorerest} option is supported by \opt{multido} because special care is taken to not ignore the +% \Macro\multido macros. +% +% The nesting of \Macro\multido macros is supported and only the outer one will produce pages while the inner ones are +% acting normally. The same is true for \Macro\multido inside any \opt{multi} environment. +% +% This option sets the option \opt{multi}|=samultido|, loads the \pkg{multido} package and redefines its internal macro +% \Macro\multido@. This is done to also support the other macros \Macro\mmultido, \Macro\Multido and \Macro\MMultido. +% +% % \DescribeKey{varwidth}'=true|false' % \DescribeKey{varwidth}'='<width> % A trailing empty line between the content and \Macro\end{document}\relax will normally create a paragraph which is \Macro\linewidth wide. @@ -844,7 +870,7 @@ % Sets the mode for \Macro\includestandalone. Valid values are `|tex|' (use source file, default), % `|image|' (use existing image file produced by the source file), `\verb+image|tex+' (use image if available, source otherwise), % `|build|' (build image from source, then use it), `|buildmissing|' (only build image if it does not exist) -% and `|buildnew|' (only build image if source file is newer). See \autoref{sec:pkgmacros} for more details. +% and `|buildnew|' (only build image if source file is newer; doesn't work with \XeLaTeX). See \autoref{sec:pkgmacros} for more details. % See also \autoref{sec:build} for further details. % % \DescribeKey{obeyclassoptions}'=true|false' @@ -892,7 +918,7 @@ % This macro can either include the source code in the same way as \Macro\input\relax (\Key{mode}'=tex'), include the output file (PDF, EPS) using \Macro\includegraphics\relax % (\Key{mode}'=image'), try first the output file and use the source file if it is available (\Key{mode}'=image|tex'), % build the output file from the source file either always (\Key{mode}'=build'), only if the image files does not exist (\Key{mode}'=buildmissing') -% or only if the source file is newer (\Key{mode}'=buildnew'). +% or only if the source file is newer (\Key{mode}'=buildnew', which doesn't work on \XeLaTeX\ because some pdf\TeX\ macros are required for this). % See also the \autoref{sec:build} for further details. % % The \meta{file} argument must be the file name of the standalone source file \emph{without} the extension. The macro accepts the same \meta{options} as \Macro\includegraphics as well @@ -942,8 +968,9 @@ % \multicolumn{1}{l}{Build setting} & Description & Default value \\ % \midrule % latex & \LaTeX\ compiler to be used & Same as main compiler \\ -% latexoptions & Command line options for compiler & \scriptsize\showbuildvar{latexoptions} \\ +% latexoptions & Command line options for compiler & \tiny\showbuildvar{latexoptions} \\ % jobname & Jobname for build compiler run & \scriptsize\showbuildvar{jobname} \\ +% quote & Character to be used to quote file names & \verb|'| for Linux\,\&\,Mac OS X, \verb|"| for Windows \\ % command & Full build shell command & \scriptsize\showbuildvar{command} \\ % postcommand & Command executed after main command, to produce final output file & \scriptsize\texttt{dvips -o '\textbackslash file.eps' '\textbackslash file.dvi'} \normalsize (DVI mode only)\\ % \bottomrule\noalign{\smallskip} @@ -1258,6 +1285,7 @@ \newif\ifsa@preview \newif\ifsa@crop \newif\ifsa@multi +\newif\ifsa@multido \newif\ifsa@varwidth \newif\ifsa@ignorerest \newif\ifsa@ignoreempty @@ -1404,8 +1432,21 @@ % \end{key} % % +% \begin{key}{standalone.cls}{multido} +% Boolean to control if the \Macro\multido macro from the \pkg{multido} package should be +% loaded and redefined to create a separate page per iteration automatically. +% \begin{macrocode} +\sa@clsoption{multido}[true]{% + \sa@boolean{multido}{#1}% + \ifsa@multido + \setkeys{standalone.cls}{multi=samultido}% + \fi +} +% \end{macrocode} +% \end{key} +% +% % \begin{key}{standalone.cls}{math} -% Boolean to control if multiple pages are used. % \begin{macrocode} \sa@clsoption{math}[true]{% \sa@boolean{math}{#1}% @@ -1769,6 +1810,7 @@ % \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}% + \let\sa@convert@pageoffset\m@ne } % \end{macrocode} % \end{key} @@ -1777,6 +1819,7 @@ % \begin{macrocode} \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@ } % \end{macrocode} % \end{key} @@ -1792,7 +1835,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 @@ -1888,6 +1932,10 @@ \newcount\sa@internal % \end{macrocode} % +% Counter for total number of pages/\opt{multi} environments. +% \begin{macrocode} +\newcounter{sapage} +% \end{macrocode} % % \begin{environment}{standalone} % The \env{standalone} environment is defined by default to be without effect. @@ -1933,6 +1981,77 @@ } % \end{macrocode} % +% +% Loads the class given by the |class| option with the rest of the options. +% \begin{macrocode} +\expandafter\expandafter\expandafter\LoadClass +\expandafter\expandafter\expandafter[% +\expandafter\@classoptionslist +\expandafter]\expandafter{\sa@class} +% \end{macrocode} +% +% +% +% \subsubsection{Ignorerest Option} +% +% \begin{macro}{\sa@startignore} +% Starts to box everything if \opt{ignorerest} option is set to true. +% Afterwards the box is discarded so that the content is ignored. +% \begin{macrocode} +\ifsa@ignorerest + \def\sa@startignore{\sa@boxit} +\else + \let\sa@startignore\relax +\fi +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\sa@stopignore} +% Closes the ignore box if \opt{ignorerest} option is set to true. +% \begin{macrocode} +\ifsa@ignorerest + \def\sa@stopignore{\endsa@boxit} +\else + \let\sa@stopignore\relax +\fi +% \end{macrocode} +% \end{macro} +% +% +% \subsubsection{Multido Option} +% +% \begin{macrocode} +\ifsa@multido +\RequirePackage{multido} +% \end{macrocode} +% +% \begin{macro}{\multido@} +% Redefine the internal macro of \Macro\multido and friends to produce +% a seperate page for every iteration. This only affects the first level of \Macro\multido, +% i.e. nesting is supported. The definition is compatible with the \opt{ignorerest} option. +% \begin{macrocode} +\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 +} +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +\fi +% \end{macrocode} +% +% % Set correct quoting character for conversion option if none was set. % \begin{macrocode} \ifsa@convert @@ -1974,15 +2093,6 @@ % \end{macrocode} % % -% Loads the class given by the |class| option with the rest of the options. -% \begin{macrocode} -\expandafter\expandafter\expandafter\LoadClass -\expandafter\expandafter\expandafter[% -\expandafter\@classoptionslist -\expandafter]\expandafter{\sa@class} -% \end{macrocode} -% -% % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % \subsubsection{Varwidth Option} % @@ -2048,6 +2158,7 @@ \fi \expandafter\def\csname #1\endcsname{% \ifnum\sa@internal=0 + \addtocounter{sapage}\@ne \preview \sa@varwidth \fi @@ -2120,6 +2231,7 @@ % \end{macro} % % +% % \begin{environment}{standalone} % Redefine the \env{standalone} environment to box the content if \opt{multi} is off, % in order to use the whole content as single page. If \opt{multi} and \opt{ignorerest} are on @@ -2128,17 +2240,13 @@ % \begin{macrocode} \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 @@ -2163,6 +2271,7 @@ \fi \expandafter\def\csname #1\endcsname{% \ifnum\sa@internal=0 + \addtocounter{sapage}\@ne \edef\@tempa{\endgroup \noexpand\endsa@boxit \begingroup @@ -2193,6 +2302,7 @@ \fi \expandafter\def\csname #1\endcsname{% \ifnum\sa@internal=0 + \addtocounter{sapage}\@ne \sa@boxit \fi \advance\sa@internal\@ne @@ -2425,6 +2535,9 @@ % \subsubsection{Conversion code} % \begin{macrocode} \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 @@ -2454,8 +2567,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 @@ -2469,6 +2582,36 @@ -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 @@ -2483,34 +2626,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 + }% } % \end{macrocode} % \end{macro} @@ -2675,48 +2802,48 @@ % This loads the corresponding packages if available, but falls back to some own code if they are not installed. % \begin{macrocode} \expandafter\ifx\csname ifluatex\endcsname\relax - \IfFileExists{ifluatex.sty}{\@firstoftwo}{\@secondoftwo}{% + \IfFileExists{ifluatex.sty}{ \RequirePackage{ifluatex} }{ \begingroup \expandafter\ifx\csname directlua\endcsname\relax \endgroup - \expandafter\let\csname ifluatex\expandafter\endcsname\csname iffalse\endcsname + \global\expandafter\let\csname ifluatex\expandafter\endcsname\csname iffalse\endcsname \else \endgroup - \expandafter\let\csname ifluatex\expandafter\endcsname\csname iftrue\endcsname + \global\expandafter\let\csname ifluatex\expandafter\endcsname\csname iftrue\endcsname \fi } \fi \expandafter\ifx\csname ifpdf\endcsname\relax - \IfFileExists{ifpdf.sty}{\@firstoftwo}{\@secondoftwo}{% + \IfFileExists{ifpdf.sty}{ \RequirePackage{ifpdf} }{ \begingroup \expandafter\ifx\csname pdfoutput\endcsname\relax \endgroup - \expandafter\let\csname ifpdf\expandafter\endcsname\csname iffalse\endcsname + \global\expandafter\let\csname ifpdf\expandafter\endcsname\csname iffalse\endcsname \else \endgroup \ifnum\pdfoutput<1 - \expandafter\let\csname ifpdf\expandafter\endcsname\csname iffalse\endcsname + \global\expandafter\let\csname ifpdf\expandafter\endcsname\csname iffalse\endcsname \else - \expandafter\let\csname ifpdf\expandafter\endcsname\csname iftrue\endcsname + \global\expandafter\let\csname ifpdf\expandafter\endcsname\csname iftrue\endcsname \fi \fi } \fi \expandafter\ifx\csname ifxetex\endcsname\relax - \IfFileExists{ifxetex.sty}{\@firstoftwo}{\@secondoftwo}{% + \IfFileExists{ifxetex.sty}{ \RequirePackage{ifxetex} }{ \begingroup \expandafter\ifx\csname XeTeXrevision\endcsname\relax \endgroup - \expandafter\let\csname ifxetex\expandafter\endcsname\csname iffalse\endcsname + \global\expandafter\let\csname ifxetex\expandafter\endcsname\csname iffalse\endcsname \else \endgroup - \expandafter\let\csname ifxetex\expandafter\endcsname\csname iftrue\endcsname + \global\expandafter\let\csname ifxetex\expandafter\endcsname\csname iftrue\endcsname \fi } \fi @@ -2933,6 +3060,14 @@ % \end{macrocode} % \end{key} % +% \begin{key}{standalone.sty}{build} +% \begin{macrocode} +\sa@pkgoption{build}[]{% + \setkeys{standalone.sty/build}{#1}% +} +% \end{macrocode} +% \end{key} +% % \begin{macro}{\sa@buildvar}[2]{name}{initial value} % Wrapper to define \opt{build} variables. % \begin{macrocode} @@ -2959,10 +3094,18 @@ % \end{key} % % +% \begin{key}{standalone.sty/build}{quote} +% \begin{macrocode} +\sa@buildvar{quote}{} +\let\sa@build@quote\relax +% \end{macrocode} +% \end{key} +% +% % \begin{key}{standalone.sty/build}{latexoptions} % \begin{macrocode} \sa@buildvar{latexoptions}{% - -interaction=batchmode -shell-escape -jobname '\buildjobname' + -interaction=batchmode -shell-escape -jobname \quote\buildjobname\quote } % \end{macrocode} % \end{key} @@ -2994,7 +3137,7 @@ \else \def\sa@graphicext{.eps} \def\sa@build@latex{latex} - \def\sa@build@postcommand{dvips -o '\file.eps' '\file.dvi'} + \def\sa@build@postcommand{dvips -o \quote\file.eps\quote\space \quote\file.dvi\quote} \fi\fi % \end{macrocode} % @@ -3003,6 +3146,49 @@ \disable@keys{standalone.sty}{subpreambles,print,sort} % \end{macrocode} % +% Set correct quoting character for build option if none was set. +% \begin{macrocode} +\def\sa@setquote{% + \ifx\sa@build@quote\relax + \expandafter\ifx\csname sa@convert@quote\endcsname\relax + \begingroup + \@tempswafalse +% \end{macrocode} +% If \Macro\pdftexbanner is not defined (XeLaTeX) the distribution can not +% be determined and double quotes are set to ensure proper operation under MiKTeX. +% \begin{macrocode} + \expandafter\ifx\csname pdftexbanner\endcsname\relax + \@tempswatrue + \else +% \end{macrocode} +% Test if there is a `|MiKTeX|' in \Macro\pdftexbanner. +% \begin{macrocode} + \def\MiKTeX{MiKTeX} + \@onelevel@sanitize\MiKTeX + \expandafter\def\expandafter\testmiktex\expandafter##\expandafter1\MiKTeX##2\relax{% + \ifx\empty##2\empty + \@tempswafalse + \else + \@tempswatrue + \fi + } + \expandafter\expandafter + \expandafter\testmiktex\expandafter\pdftexbanner\MiKTeX\relax\relax + \fi + \expandafter + \endgroup + \if@tempswa + \def\sa@build@quote{"} + \else + \def\sa@build@quote{'} + \fi + \else + \let\sa@build@quote\sa@convert@quote + \fi + \fi +} +% \end{macrocode} +% % In non-sorted print mode comments are preserved by default. % \begin{macrocode} \ifsa@printsubpreambles @@ -4280,7 +4466,7 @@ }% {% \PackageInfo{standalone}% - {#3.tex file newer then #2}% + {generated file #2 newer then source file #3.tex}% \includegraphics[#1]{#2}% }% \fi @@ -4304,6 +4490,8 @@ \let\latex\sa@build@latex \let\latexoptions\sa@build@latexoptions \let\buildjobname\sa@build@jobname + \sa@setquote + \let\quote\sa@build@quote \immediate\write18{\sa@build@command}% \ifx\sa@build@postcommand\@empty\else \immediate\write18{\sa@build@postcommand}% |