diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/standalone/standalone.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/standalone/standalone.dtx | 339 |
1 files changed, 249 insertions, 90 deletions
diff --git a/Master/texmf-dist/source/latex/standalone/standalone.dtx b/Master/texmf-dist/source/latex/standalone/standalone.dtx index 17098bdb05d..41496f58f5f 100644 --- a/Master/texmf-dist/source/latex/standalone/standalone.dtx +++ b/Master/texmf-dist/source/latex/standalone/standalone.dtx @@ -18,38 +18,34 @@ % 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. +% and the derived files standalone.cls, standalone.sty, standalone.tex and +% standalone.cfg. % -% $Id: standalone.dtx 1772 2010-03-27 13:50:59Z martin $ +% $Id: standalone.dtx 2194 2011-02-28 19:26:29Z martin $ % \fi % % \iffalse -%<cls|sty|cfg|tex>% $Id: standalone.dtx 1772 2010-03-27 13:50:59Z martin $ +%<cls|sty|cfg|tex>% $Id: standalone.dtx 2194 2011-02-28 19:26:29Z martin $ %<cls|sty>\NeedsTeXFormat{LaTeX2e} -%<cls>\ProvidesClass{standalone} [2010/03/27 v0.3a Class to compile TeX sub-files standalone] -%<sty>\ProvidesPackage{standalone} [2010/03/27 v0.3a Package to include TeX sub-files with preambles] -%<tex>\ProvidesFile{standalone.tex}[2010/03/27 v0.3a Provides if-switch to show if file is compiled standalone]% -%<cfg>\ProvidesFile{standalone.cfg}[2010/03/27 v0.3a Default configuration file for 'standalone' class]% +%<cls>\ProvidesClass{standalone} [2010/02/28 v0.4 Class to compile TeX sub-files standalone] +%<sty>\ProvidesPackage{standalone} [2010/02/28 v0.4 Package to include TeX sub-files with preambles] +%<tex>\ProvidesFile{standalone.tex}[2010/02/28 v0.4 Provides if-switch to show if file is compiled standalone]% +%<cfg>\ProvidesFile{standalone.cfg}[2010/02/28 v0.4 Default configuration file for 'standalone' class]% %<*driver> \NeedsTeXFormat{LaTeX2e} -\ProvidesFile{standalone.dtx}[2010/03/27 v0.3a DTX File for 'standalone' cls/sty/tex/cfg files] -\documentclass{ltxdoc} +\ProvidesFile{standalone.dtx}[2011/02/28 v0.4 DTX File for 'standalone' cls/sty/tex/cfg files] +\documentclass{scrartcl} +\usepackage{ydoc} \usepackage{ifpdf} \usepackage{listings} -\IfFileExists{hypdoc.sty}{% -\usepackage{hypdoc} -}{% \usepackage{hyperref} -} -\def\optpar#1{\marginpar{\hfill\opt{#1}}} -\def\opt#1{{\sffamily#1}} +\def\optpar#1{\marginpar{\raggedright\opt{#1}}} \EnableCrossrefs \CodelineIndex \RecordChanges %\OnlyDescription -\providecommand{\env}[1]{\texttt{#1}} \begin{document} \DocInput{\jobname.dtx} \PrintChanges @@ -58,7 +54,7 @@ %</driver> % \fi % -% \CheckSum{1111} +% \CheckSum{1298} % % \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 @@ -76,11 +72,11 @@ % Grave accent \` Left brace \{ Vertical bar \| % Right brace \} Tilde \~} % -% % \changes{v0.1}{2010/03/21}{First released version} % \changes{v0.2}{2010/03/22}{Added support for beamer style settings in the config file using \cs{ifstandalonebeamer}. Updated documentation.} % \changes{v0.3}{2010/03/26}{Added package options to automatically copy sub-preamble code to the main preamble.} % \changes{v0.3a}{2010/03/27}{Fixed bug related to line endings in \texttt{.sta} file. Listed sub-files now have \texttt{.tex} as default extension.} +% \changes{v0.4}{2011/02/28}{Added option 'border' for easy adjustments of the preview border.} % % \GetFileInfo{\jobname.dtx} % @@ -111,7 +107,7 @@ % \vspace*{-2em} % \begin{center} % {\LARGE\sffamily The \emph{standalone} Class and Package\\[\medskipamount]} -% {\large Martin Scharrer \\[\medskipamount]\normalsize +% {\large Martin Scharrer \\[\medskipamount]\normalsize % \url{martin@scharrer-online.de}\\[.8ex] % \url{http://www.ctan.org/pkg/standalone/}\\[\bigskipamount]} % {\large Version \fileversion\ -- \filedate}\\ @@ -120,8 +116,8 @@ % % \section{Introduction} % Larger \LaTeX{} documents can be split into multiple \TeX\ files which are then included in a main document with \cs{include} -% for e.g.\ chapter files or \cs{input} for e.g.\ \TeX-coded pictures. Keeping pictures in their own sub-files improves readability -% of the main file and simplifies the sharing of them between different documents. However, during the, sometimes lengthly, +% for e.g.\ chapter files or \cs{input} for e.g.\ \TeX-coded pictures. Keeping pictures in their own sub-files improves readability +% of the main file and simplifies the sharing of them between different documents. However, during the, sometimes lengthly, % drawing/coding process it has benefits to be able to compile the pictures on their own. The compile process is much quicker and % the resulting document only holds the picture which avoids constant page turning and zooming. % @@ -129,13 +125,13 @@ % the directories with a lot of extra files. A second method is to place the `main' components, i.e. a preamble, directly into the % picture files and make the main document ignore this code sections. % -% The package |standalone| can be used in the main document to skip all extra preambles in included files. The main file must load all packages +% The package |standalone| can be used in the main document to skip all extra preambles in included files. The main file must load all packages % and settings required by the sub-files. Several package options are provided to collect the preambles of the sub-files automatically and execute them from the main file. % % A |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 |preview| package to create an output file which only contains the picture with no extra -% margins, page numbers or anything else. A configuration file |standalone.cfg| read by the class allows the user to adjust settings and macros easily +% margins, page numbers or anything else. A configuration file |standalone.cfg| read by the class allows the user to adjust settings and macros easily % on a per directory base. % % \subsection*{Similar Packages} @@ -146,22 +142,27 @@ % \subsection{Quick instructions} % Load the |standalone| \emph{package} very early in the main document. Also all packages needed by all the sub-files must be loaded by the main document. % Include your picture or other sub-files using |\input| or a similar macro as normal. -% In the sub-files use the |standalone| \emph{class} with a normal \cs{documentclass} and load all packages needed for the particular +% In the sub-files use the |standalone| \emph{class} with a normal \cs{documentclass} and load all packages needed for the particular % file. Finally wrap the actual content of the sub-file in a |document| environment. % % When the sub-file is compiled on its own the |\documentclass| and |document| environment will be active as normal. The main file, however, -% will skip everything from the |\documentclass| till the |\begin{document}|. The (now fake) |document| environment is redefined to be a simple +% will skip everything from the |\documentclass| till the |\begin{document}|. The (now fake) |document| environment is redefined to be a simple % TeX-group. Any code after the |\end{document}| will be ignored. The real |document| environment of the main file will be unaffected and will work as normal. % % Instead of transferring the packages required by each sub-file manually to the main document preamble, this task can be automatised using % the options listed in section~\ref{sec:pkgoptions} % % \subsection{Class Options} -% The |standalone| class will load a real document class. By default this is |article|. The document class normally has not much -% influence on sub-files like pictures, especially when the |preview| package is active. However, the used class can be adjusted by the user +% The |standalone| class will load a real document class.\optpar{class} By default this is |article|. The document class normally has not much +% influence on sub-files like pictures, especially when the \pkg{preview} package is active. However, the used class can be adjusted by the user % with the |class=|\meta{class name} option. % -% A special |beamer| option is provided to handle beamer frames and overlays correctly. See section~\ref{sec:beamer} for more information. +% The boolean \opt{preview}\optpar{preview} option can be used to disable the use of the \pkg{review} package. The default is |preview=true|. The package is not loaded if |preview=false| is set. +% The preview border can be set using the \opt{border}\optpar{border} option. This border will be added to the file content. +% The usage is either \MacroArgs'border='{<left>~<lower>~<right>~<upper>}, \MacroArgs'border='{<left/right>~<lower/upper>} or \MacroArgs'border='<all sides>. +% The default unit is |bp| (big points) which is the unit used by the PostScript and PDF formats. If |preview=false| is set this option will be ignored. +% +% A special \opt{beamer}\optpar{beamer} option is provided to handle beamer frames and overlays correctly. See section~\ref{sec:beamer} for more information. % % All other used options are passed to the loaded class. % @@ -182,14 +183,14 @@ % If such issues occur they can hardly be handled in an automatic way. Instead the sub-preambles must be carefully merged into the main preamble. % The option \opt{print}\optpar{print} was created to simplify this otherwise cumbersome task. % It concatenated all sub-preambles into a single file named `\meta{main tex file name}|.stp|' (for \emph{st}andalone, \emph{p}rint). Each preamble is commented with its original file name. -% Please note that |.sta| file mentioned above, while quite similar, holds additional macros and might not be easily user readable or editable. +% Please note that |.sta| file mentioned above, while quite similar, holds additional macros and might not be easily user readable or editable. % After the file was generated it can be easily pasted into the main file preamble using a text editor. % % When the \opt{print} option is enabled the normal |.sta| file is not generated or loaded. Because this will cause most likely some errors related to packages not loaded, all sub-file bodies will be skipped. % A warning is printed for each sub-file to remind the user about this fact. The \opt{print} option is only indented to by used when required to get a list of sub-preambles. After including this list in the main file the option % must be removed to compile the main file normally. % -% Finally if both the \opt{print} and \opt{sort}\optpar{print, sort} options are enabled, a `sorted' list of sub-preambles is printed into the |.stp| file. In this `sorted print' mode all |\usepackage| macros (and similar macros like +% Finally if both the \opt{print} and \opt{sort}\optpar{print}\optpar{sort} options are enabled, a `sorted' list of sub-preambles is printed into the |.stp| file. In this `sorted print' mode all |\usepackage| macros (and similar macros like % |\usepgflibrary|, |\usetikzlibrary| and |\usetikztiminglibrary| from the |pgf|, |tikz| and |tikz-timing| packages, respectively) are removed from the rest of the sub-preamble code. % A list of packages (and libraries) without duplicates is printed at the begin of the |.stp| file (using |\usepackage|, of course). Every option provided by any sub-file for a package is added, again without duplicates. % If specific package date was requested in a sub-file it is also added. If multiple dates are requested for one package, the most recent (i.e.\ the ``highest one'', not the last processed) is used. @@ -201,7 +202,7 @@ % The macro \cs{onlyifstandalone}\marg{code} (see below) was created because of this two reasons. Its argument braces hide the content from the scanner. % It is then also completely removed from the printed sub-preamble code. % -% The complementary options \opt{comments}/\opt{nocomments}\optpar{comments/nocomments} select if the |.stp| file should also include the comments of the sub-preambles. +% The complementary options \opt{comments}/\opt{nocomments}\optpar{comments}\optpar{nocomments} select if the |.stp| file should also include the comments of the sub-preambles. % Comments are included by default in the non-sorting print mode (\opt{print} without \opt{sort} option), but can cause `wrong' results during the `sorting' process and are therefore removed by default in this mode. % The reason for this can be explained as follows. % In order to transfer the comments from the sub-files to the |.stp| file \TeX\ must be instructed to handle them as normal input and not discard them. @@ -212,38 +213,47 @@ % \subsection{Dependencies} % The |standalone| class requires the |kvoptions| package (Oberdiek bundle) and the |preview| package. Both should be available in a standard \LaTeX\ installation. % The |beamer| option of course requires the |beamer| bundle to be installed. -% The |standalone| package does not require other packages, but can take advantage from the |fink| package (\emph{Fi}le \emph{N}ame \emph{K}eeper), +% The |standalone| package does not require other packages, but can take advantage from the |fink| package (\emph{Fi}le \emph{N}ame \emph{K}eeper), % to access the filenames of the sub-files. For this the |fink| package must be loaded before |standalone|. Without it a file name macro defined by \LaTeX\ itself % is used instead which should do also fine, but is reset at every |\input| macro. Placing this macro before |\documentclass| without marking % it with |\csname standaloneignore\endcsname| will then lead to wrong file names inside the |.sta| and |.stp| files. % % \subsection{Environments and Macros} % -% \DescribeEnv{standalone} -% The \env{standalone} environment is wrapped around the content of each sub-file when compiled standalone. +% \DescribeEnv[<sub-file content>]{standalone} +% The \env{standalone} environment is automatically wrapped around the content of each sub-file when compiled standalone. % By default it only contains a \env{preview} environment as long the class is not called with the |preview=false| option. % It can be redefined in the configuration file if required. % When compiled as part of a main document the \env{standalone} environment does nothing (apart of being a \TeX\ group). % -% \DescribeEnv{standaloneframe} -% The \env{standaloneframe} environment is only defined when the class is called with the |beamer| option and acts as a replacement -% of the \env{frame} environment of beamer when compiled standalone. All optional arguments of \env{frame} are supported. +% \begin{DescribeEnv}{standaloneframe} +% !\color{optional}\colorlet{meta}{metaoptional}! +% <<overlay specification>>'[<'<default overlay spec>'>]' +% !\\\hspace*{7em}! +% !\color{optional}\colorlet{meta}{metaoptional}! +% [<options>]{<optional frame title>}{<optional frame subtitle>} +% \relax\MacroArgs<code with beamer overlays> +% \end{DescribeEnv} +% The \env{standaloneframe} environment must be used in sub-file holding beamer overlay code. +% It is only defined when the class is called with the |beamer| option and acts as a replacement +% of the \env{frame} environment of beamer when compiled standalone. +% All optional arguments of \env{frame} are supported but most might not be useful for normal sub-files. % When compiled as part of a main document it does nothing except of gobbling its arguments. % % \bigskip % \DescribeMacro{\ifstandalone} -% Both the class and the package provide the if-switch \cs{ifstandalone}, which can be used to only include code if the file is +% Both the class and the package provide the if-switch \cs{ifstandalone}, which can be used to only include code if the file is % compiled standalone. The switch is set to \cs{iftrue} by the class and to \cs{iffalse} by the package. % % The additional file |standalone.tex| also defines this switch by checking if \cs{documentclass} was already used. It can be included % with |\input{standalone}| and is intended for specialised files which do not use the |standalone| class. % % \DescribeMacro{\ifstandalonebeamer} -% Both the class and the package provide the if-switch \cs{ifstandalonebeamer}, which can be used to only include code if the file is +% Both the class and the package provide the if-switch \cs{ifstandalonebeamer}, which can be used to only include code if the file is % compiled standalone with the |beamer| class option set. % The switch is set to \cs{iftrue} by the class when loaded with the |beamer| option and always to \cs{iffalse} by the package. % -% \DescribeMacro{\onlyifstandalone}\hspace*{-\parindent}\hspace*{-\marginparsep}\marg{code}\hspace*{\parindent} +% \DescribeMacro{\onlyifstandalone}{<code>} % This is the macro version of the |\ifstandalone| if-switch. It executes \meta{code} only in |standalone| mode. As mentioned in section~\ref{sec:pkgoptions} % it can also be used to hide |\usepackage| and similar macros from the extraction scanner of the |sort| option. The macro and its argument is not printed into the |.stp| file. % @@ -252,7 +262,7 @@ % Because the main document will only skip code between |\documentclass| and |\begin{document}| this code will be executed by it. % In order to avoid this the macro \cs{standaloneignore} can be used at the very beginning of a sub-file to skip over this code. % However it must be written as |\csname standaloneignore\endcsname| to avoid a `Undefined control sequence' error when compiled standalone. -% After all the class is not loaded at this point, therefore no |standalone| macros are yet defined. +% After all the class is not loaded at this point, therefore no |standalone| macros are yet defined. % The |\csname|\ldots|\endcsname| construct will simple make it equal to |\relax| in this case. % % Please note that all code before |\documentclass| is not processed by any of the \opt{subpreamble} options but always simply removed. @@ -419,7 +429,7 @@ % \end{minipage} % % \subsection{Usage with \texttt{svn-multi} keywords}\label{sec:svnmulti} -% If the version control package \texttt{svn-multi} is used, the keyword macros (|\svnid| or |\svnidlong|) +% If the version control package \texttt{svn-multi} is used, the keyword macros (|\svnid| or |\svnidlong|) % need to be placed after the |\begin{document}| to be taken into account by the main document. % The \texttt{svn-multi} package must be loaded by the sub-file preamble to avoid compile errors in standalone mode. % Alternative, if the keywords are not required in this mode, they can be surrounded by |\ifstandalone\else|\dots|\fi|. @@ -504,6 +514,24 @@ \DeclareOption{nocomments}{% \def\sa@percent{}% } +\DeclareOption{mode=none}{% + \let\sa@mode\relax +} +\DeclareOption{mode=pdf|tex}{% + \def\sa@mode{0}% +} +\DeclareOption{mode=tex}{% + \def\sa@mode{1}% +} +\DeclareOption{mode=pdf}{% + \def\sa@mode{2}% +} +\DeclareOption{mode=build}{% + \def\sa@mode{3}% +} +\DeclareOption{mode=buildnew}{% + \def\sa@mode{4}% +} \ProcessOptions*\relax % \end{macrocode} % @@ -520,7 +548,7 @@ % % \begin{macro}{\sa@filepath} % File name macro. If the |fink| package is loaded the macros \cs{finkdir} (with leading `|./|' removed) and \cs{finkpath} is used, otherwise the \LaTeX\ macro -% \cs{@filef@und} (with trailing space removed and with '.tex' added if it has no file extension). +% \cs{@filef@und} (with trailing space removed and with '.tex' added if it has no file extension). % The latter causes issues if |\input| etc. was used before |\documentclass| in sub-files. % \begin{macrocode} \@ifundefined{finkpath}{% @@ -771,44 +799,16 @@ \@ifundefined{sa@pkgdate@\pkg}% {\global\@namedef{sa@pkgdate@\pkg}{#3}}% {% - \begingroup - \edef\@tempa{{\csname sa@pkgdate@\pkg\endcsname}{#3}}% - \expandafter\sa@getlargerdate\@tempa - \expandafter\xdef\csname sa@pkgdate@\pkg\endcsname{\sa@thedate}% - \endgroup + \ifnum\expandafter\expandafter + \expandafter\sa@@getdate\csname sa@pkgdate@\pkg\endcsname//00\relax<\sa@@getdate#3//00\relax + \global\@namedef{sa@pkgdate@\pkg}{#3}% + \fi }% \fi }% \sa@gobbleeol\sa@removepackages^^J% } -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\sa@getlargerdate} -% Takes two package dates and returns the larger one as \cs{sa@thedate}. -% \begin{macrocode} -\def\sa@getlargerdate#1#2{% - \sa@@getdate#1\relax\relax0/0/0\relax\empty\relax - \let\sa@datea\sa@date - \sa@@getdate#2\relax\relax0/0/0\relax\empty\relax - \ifdim\sa@datea pt>\sa@date pt - \def\sa@thedate{#1}% - \else - \def\sa@thedate{#2}% - \fi -} -\def\sa@@getdate#1/#2/#3\relax{% - \@ifnextchar\relax - {% - \def\sa@date{#1.#2#3}% - \sa@@rmdate - }% - {% - \def\sa@date{0}% - \sa@@rmdate - }% -} -\def\sa@@rmdate#1\empty\relax{} +\def\sa@@getdate#1/#2/#3#4#5\relax{#1#2#3#4} % \end{macrocode} % \end{macro} % @@ -955,7 +955,7 @@ % \begin{environment}{standalonepreambles} % This environment simply adds a group and sets the endline character to a printed newline and the argument character % |#| as a normal character. The first suppresses |\par|'s in the stored sub-preambles while preserving newlines. The latter -% is required to permit macro arguments in the preambles. Otherwise a |#| is doubled to |##| causing compile errors when the +% is required to permit macro arguments in the preambles. Otherwise a |#| is doubled to |##| causing compile errors when the % sub-preambles are used. % The |.sta| file is closed after this environment. % \begin{macrocode} @@ -973,7 +973,7 @@ % % \begin{environment}{subpreambles} % This environment rereads the sub-preambles from the |.sta| files and stores it globally under the name -% ``\cs{prevsubpreamble@}\meta{file name}''. If sorting is enabled the sub-preambles are also scanned for +% ``\cs{prevsubpreamble@}\meta{file name}''. If sorting is enabled the sub-preambles are also scanned for % loaded packages. % \begin{macrocode} \long\gdef\subpreamble#1#2\endsubpreamble{% @@ -1007,7 +1007,7 @@ % \begin{macro}{\AtBeginDocument} % At begin of the document the |.sta| file is read again. This time the sub-preamble macros are executed as normal. -% The |standalone| macros are defined to be without effect. If `sorting' is enabled \cs{usepackage} is temporarily +% The |standalone| macros are defined to be without effect. If `sorting' is enabled \cs{usepackage} is temporarily % redefined to ignore any given options, which where already passed (\cs{PassOptionsToPackage}) beforehand. % \begin{macrocode} \AtBeginDocument{% @@ -1065,6 +1065,14 @@ % \end{macrocode} % \end{macro} % +% \begin{macro}{\sa@gobbleline} +% Gobbles the rest of the input line. This is required when skipping the body of a file to also skip +% everything on the same line after |\begin{document}|. +% \begin{macrocode} +\def\sa@gobbleline#1^^J{}% +% \end{macrocode} +% \end{macro} +% % \begin{macro}{\standaloneignore} % \changes{v0.3}{2010/03/26}{New macro} % This macro must only be used in a sub-file before a |\documentclass|. It gobbles everything up to this macro @@ -1157,9 +1165,10 @@ \def\next{% \endgroup \PackageWarning{standalone}{Running 'standalone' package in sub-preamble print mode. All body content of file `\sa@filepath' is ignored!}{}{}% - \null + \hbox to 1pt{\vbox to 1pt{}}% \endinput - } + %\sa@gobbleline + }% \else \expandafter \ifx @@ -1174,10 +1183,11 @@ \PackageWarning{standalone}{Sub-preamble of file '\sa@filepath' has changed. Content will be ignored. Please rerun LaTeX!}{}{}% \immediate\write\@mainaux{% \@percentchar\space standalone package info: Rerun LaTeX! - } - \null + }% + \hbox to 1pt{\vbox to 1pt{}}% \endinput - } + %\sa@gobbleline + }% \fi \fi \else @@ -1260,7 +1270,7 @@ % \end{macro} % % \begin{macro}{\sa@document} -% This is the |\begin{document}| of the sub files. It does nothing except of +% This is the |\begin{document}| of the sub files. It does nothing except of % redefining |\end{document}| and calling our own |atbegindocument| hook. % \begin{macrocode} \def\sa@document{% @@ -1271,7 +1281,7 @@ % \end{macro} % % \begin{macro}{\sa@enddocument} -% This is the |\end{document}| of the sub files. It does nothing except of +% This is the |\end{document}| of the sub files. It does nothing except of % calling our own |atenddocument| hook and then the `after end document' handler. % \begin{macrocode} \def\sa@enddocument{% @@ -1282,7 +1292,7 @@ % \end{macro} % % \begin{macro}{\sa@@enddocument} -% This is a `after end document' handler for the sub-files. It restores macros and +% This is a `after end document' handler for the sub-files. It restores macros and % ends the input of the file. % \begin{macrocode} \def\sa@@enddocument{% @@ -1356,12 +1366,18 @@ \SetupKeyvalOptions{prefix=sa@} % \end{macrocode} % -% Use of |preview| package is optional but enabled by default. +% Use of |preview| package is optional but enabled by default. % This defines the |\ifsa@preview| switch. % \begin{macrocode} \DeclareBoolOption[true]{preview} % \end{macrocode} % +% To set the preview border: +% \begin{macrocode} +\DeclareStringOption{border} +\let\sa@border\relax +% \end{macrocode} +% % Enable beamer support. % \begin{macrocode} \DeclareVoidOption{beamer}{% @@ -1424,6 +1440,27 @@ {\endpreview} }{}% \RequirePackage{preview} +% \end{macrocode} +% Read the preview border values. The default unit is |bp| (PostScript points). +% Allowed are one, two or four values. +% \begin{macrocode} + \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 + }% + \@firstofone{\expandafter\sa@readborder\sa@border} {} {} {} {} \relax + \endgroup + \fi \fi % \end{macrocode} % @@ -1535,12 +1572,134 @@ %</tex> % \fi % +% \iffalse +%<*sty> +% \fi +% \begin{macrocode} +\expandafter\ifx\csname sa@mode\endcsname\relax\else +% \end{macrocode} +% \begin{macro}{\includestandalone} +% \begin{macrocode} +\RequirePackage{gincltex} +\RequirePackage{ifpdf} +\ifpdf + \def\sa@graphicext{.pdf} +\else + \def\sa@graphicext{.eps} +\fi + +\def\sa@comparegranpic#1{% + \begingroup + \let\next\empty + \expandafter\sa@comparegranpic@\pdffilemoddate{#1\sa@graphicext}\relax + \let\sa@picdate\sa@date + \let\sa@pictime\sa@time + \expandafter\sa@comparegranpic@\pdffilemoddate{#1.tex}\relax + \ifnum\sa@date>\sa@picdate\relax + \def\next{\sa@buildgraphic{#1}}% + \else + \ifnum\sa@date=\sa@picdate\relax + \ifnum\sa@time>\sa@pictime\relax + \def\next{\sa@buildgraphic{#1}}% + \fi + \fi + \fi + \expandafter + \endgroup + \next +} + +\begingroup +\@makeother\D +\@makeother: +\global\@namedef{sa@comparegranpic@}D:#1#2#3#4#5#6#7#8#9\relax{% + \def\sa@date{#1#2#3#4#5#6#7#8}% + \sa@comparegranpic@@#9\relax +} +\endgroup + +\def\sa@comparegranpic@@#1#2#3#4#5#6#7\relax{% + \def\sa@time{#1#2#3#4#5#6}% + \def\sa@tz{#7}% +} + +\def\sa@compilecmd{\ifpdf pdf\fi latex --interaction=batchmode \image}% + +\def\sa@buildgraphic#1{% + \ifeof18 + \PackageError{standalone}{Shell escape needed to create graphic!}{}% + \else + \begingroup + \def\image{#1}% + \immediate\write18{\sa@compilecmd}% + \endgroup + \fi +} + +\newcommand*\includestandalone[2][]{% + \begingroup + \edef\@tempa{{#2\sa@graphicext}}% + \expandafter\includestandalone@\@tempa{#2}{#1}% + \endgroup +} + +%% 0 = PDF if exists, TEX otherwise +%% 1 = force TEX +%% 2 = force PDF +%% 3 = build PDF if not exists +%% 4 = build PDF if older than TEX +\def\includestandalone@#1#2#3{% + \ifcase\sa@mode + \relax% 0 + \IfFileExists{#1}% + {\includegraphics[#3]{#1}}% + {\includegraphics[#3]{#2.tex}}% + \or% 1 + \includegraphics[#3]{#2.tex}% + \or% 2 + \includegraphics[#3]{#1}% + \or% 3 + \IfFileExists{#1}% + {\includegraphics[#3]{#1}}% + {\sa@buildgraphic{#2}% + \IfFileExists{#1}% + {\includegraphics[#3]{#1}}% + {\PackageWarning{standalone}% + {Graphic '#1' could not be build.^^J% + Shell escape activated?}% + \includegraphics[#3]{#2.tex}% + }% + }% + \else% 4 + \IfFileExists{#1}% + {\sa@comparegranpic{#2}}% + {\sa@buildgraphic{#2}% + \IfFileExists{#1}% + {\includegraphics[#3]{#1}}% + {\PackageWarning{standalone}% + {Graphic '#1' could not be build.^^J% + Shell escape activated?}% + \includegraphics[#3]{#2.tex}% + }% + }% + \fi +} +% \end{macrocode} +% +% \end{macro} +% \begin{macrocode} +\fi +% \end{macrocode} +% \iffalse +%</sty> +% \fi +% % \subsection{Config File} % Default content of the configuration file. Users can override this by placing an own % |standalone.cfg| file somewhere where \TeX\ can find it (user |texmf| directory or local directory). -% This user file can load the default config file using +% This user file can load the default config file using % using |\InputIfFileExists{standalone/standalone.cfg}{}{}|. -% Be default only the |preview| package option are set and +% Be default only the |preview| package option are set and % the navigation symbols of beamer standalones are disabled. % \iffalse %<*cfg> |