summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/standalone/standalone.dtx
blob: 70401808f37dda17e7de42bdfc2f1d29293dd1bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
% \iffalse meta-comment
%
% Copyright (c) 2010 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.3c
% of this license or (at your option) any later version.
% The latest version of this license is in
%
%   http://www.latex-project.org/lppl.txt
%
% and version 1.3c or later is part of all distributions of LaTeX
% version 2008/05/04 or later.
%
% This work has the LPPL maintenance status `maintained'.
%
% 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.
%
% $Id: standalone.dtx 1714 2010-03-22 14:44:37Z martin $
% \fi
%
% \iffalse
%<cls|sty|cfg|tex>% $Id: standalone.dtx 1714 2010-03-22 14:44:37Z martin $
%<cls|sty>\NeedsTeXFormat{LaTeX2e}
%<cls>\ProvidesClass{standalone}   [2010/03/22 v0.2 Class to compile TeX sub-files standalone]
%<sty>\ProvidesPackage{standalone} [2010/03/22 v0.2 Package to include TeX sub-files which use the 'standalone' class]
%<tex>\ProvidesFile{standalone.tex}[2010/03/22 v0.2 Provides if-switch to show if file is compiled standalone]%
%<cfg>\ProvidesFile{standalone.cfg}[2010/03/22 v0.2 Default configuration file for 'standalone' class and package]%
%<*driver>
\NeedsTeXFormat{LaTeX2e}
\ProvidesFile{standalone.dtx}[2010/03/22 v0.2 DTX File for 'standalone' cls/sty/tex/cfg files]
\documentclass{ltxdoc}
\usepackage{ifpdf}
\usepackage{listings}
\IfFileExists{hypdoc.sty}{%
\usepackage{hypdoc}
}{%
\usepackage{hyperref}
}

\EnableCrossrefs
\CodelineIndex
\RecordChanges
%\OnlyDescription
\providecommand{\env}[1]{\texttt{#1}}
\begin{document}
  \DocInput{\jobname.dtx}
  \PrintChanges
  \newpage\PrintIndex
\end{document}
%</driver>
% \fi
%
% \CheckSum{242}
%
% \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
%   Lower-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
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   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.}
%
% \GetFileInfo{\jobname.dtx}
%
% \DoNotIndex{\newcommand,\newenvironment,\def,\edef,\xdef,\DeclareRobustCommand}
% \DoNotIndex{\expandafter,\if,\else,\fi,\ifnum,\ifx,\let,\global,\long}
% \DoNotIndex{\newcounter,\newcount,\message,\meaning,\noexpand,\relax,\value}
% \DoNotIndex{\setcounter,\addtocounter,\advance,\afterassignment,\AtEndOfPackage}
% \DoNotIndex{\ProvidesPackage,\providecommand,\RequirePackage,\empty,\begin,\end}
% \DoNotIndex{\begingroup,\bgroup,\egroup,\endgroup,\csname,\endcsname,\@tempa,\@tempb}
% \DoNotIndex{\ignorespaces,\lccode,\sffamily,\@gobble,\@ifundefined,\@for,\or}
% \DoNotIndex{\@firstoftwo,\@ifnextchar,\@namedef,\@nameuse,\@secondoftwo}
% \DoNotIndex{\@temptokena,\toks@,\BODY,\do,\g@addto@macro,\lowercase,\uppercase,\the}
% \DoNotIndex{\aftergroup,\CurrentOption,\DeclareBoolOption,\DeclareDefaultOption,\DeclareStringOption,\DeclareVoidOption}
% \DoNotIndex{\endinput,\endpreview,\input,\LoadClass,\newif,\PassOptionsToPackage,\preview,\ProcessKeyvalOptions}
% \DoNotIndex{\renewcommand,\renewenvironment,\setbeamertemplate,\SetupKeyvalOptions,\space,\unskip,\usepackage}
%
% \ifpdf
% \hypersetup{%
%   pdfauthor   = {Martin Scharrer <martin@scharrer-online.de>},
%   pdftitle    = {The standalone class and package},
%   pdfsubject  = {Documentation of LaTeX class and package 'standalone'},
%   pdfkeywords = {standalone, LaTeX, TeX}
% }%
% \fi
% \clearpage
% \null
% \vspace*{-2em}
% \begin{center}
%   {\LARGE\sffamily The \emph{standalone} Class and Package\\[\medskipamount]}
%   {\large Martin Scharrer \\[\medskipamount]\normalsize 
%   \url{martin@scharrer-online.de}\\[.8ex]
%   \url{http://www.ctan.org/pkg/standalone/}\\[\bigskipamount]}
%   {\large Version \fileversion\ -- \filedate}\\
% \end{center}
% \vspace{1.2em}%
%
% \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, 
% 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.
%
% While it is possible to write a small `main' file for each picture file, this method is a little cumbersome and clutters
% 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.
%
% 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 
% on a per directory base.
%
% \subsection*{Similar Packages}
% The |docmute| package by T.M.\ Trzeciak is written with the same function as the |standalone| package. However, no special class file or 
% configuration file is provided.
%
% \section{Usage}
% \subsection{Quick instructions}
% Load the |standalone| \emph{package} and all packages needed by all the sub-files in the main document and include your picture or other sub-files using |\input| as normal.
% In the sub-files use the |standalone| \emph{class} using the normal \cs{documentclass} and load all packages needed for the particular 
% file. Finally wrap the actual file content 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 
% 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.
%
% \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
% 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.
%
% All other used options are passed to the loaded class.
%
% \subsection{Package Options}
% At the moment the |standalone| package does not provide any options.
%
% \subsection{Environments and Macros}
%
% \DescribeEnv{standalone}
% The \env{standalone} environment is 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.
% 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 
% 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.
%
% \def\lstlistingname{Example}
% \begin{lstlisting}[language={[latex]tex},gobble=4,frame=lines,caption={Use of \emph{standalone} class.}]
%   % A sub-file (e.g. picture) using the 'standalone' class:
%   % Use 'standalone' as document class:
%   \documentclass{standalone}
%
%   % Load packages needed for this TeX file:
%   \usepackage{tikz}
%
%   % Surround TeX code with 'document' environment as usually:
%   \begin{document}
%   % Add your TeX code, e.g. a picture:
%   \begin{tikzpicture}
%     \draw (0,0) rectangle (2,1) node [midway] {Example};
%   \end{tikzpicture}
%   \end{document}
% \end{lstlisting}
%
% \begin{lstlisting}[language={[latex]tex},gobble=4,frame=lines,caption={Effective code if compiled standalone.}]
%   \documentclass{article}
%
%   \newenvironment{standalone}{\begin{preview}}{\end{preview}}
%   \input{standalone.cfg}
%   % which by defaults loads: \PassOptionsToPackage{active,tightpage}{preview}
%   \usepackage{preview}
%
%   \usepackage{tikz}
%
%   \begin{document}
%   \begin{standalone}
%   \begin{tikzpicture}
%     \draw (0,0) rectangle (2,1) node [midway] {Example};
%   \end{tikzpicture}
%   \end{standalone}
%   \end{document}
% \end{lstlisting}
%
% \begin{lstlisting}[language={[latex]tex},gobble=4,frame=lines,caption={Effective code if included in a main document.}]
%   \begingroup
%   \begin{tikzpicture}
%     \draw (0,0) rectangle (2,1) node [midway] {Example};
%   \end{tikzpicture}
%   \endgroup
%   \endinput
% \end{lstlisting}
%
%
% \subsection{Usage of the package}
% \begin{lstlisting}[language={[latex]tex},gobble=4,frame=lines,caption={Use of \emph{standalone} package.}]
%   % Main file
%   % Real document class:
%   \documentclass{article}
%
%   % Use the 'standalone' package:
%   \usepackage{standalone}
%
%   % Load all packages needed for all sub-files:
%   \usepackage{tikz}
%
%   % Inside the real 'document' environment read the sub-file with '\input'
%   \begin{document}
%   % ...
%   \begin{figure}
%     \input{subfile}
%     \caption{A subfile}
%   \end{figure}
%   % ...
%   \end{document}
% \end{lstlisting}
%
%
% \subsection{Support for Beamer Presentations}\label{sec:beamer}
% Presentation can be written in \LaTeX\ using the |beamer| class. Each presentation frame is wrapped in a |frame| environment. Overlay effects
% can be added using special macros. This effects result in multiple pages per frame. Pictures with such overlay effects can not be
% compiled standalone using the normal settings. Instead the |standalone| class must load the |beamer| class and wrap the content also in
% a |frame| environment while skipping the |preview| environment. To activate this settings load the |standalone| class with the |beamer| option.
% Because the |frame| environment is quite special (it normally collects all it's content and calls the \cs{frame}) and must also support
% verbatim content it is not easily possible to redefined the |document| environment to include |frame|. Also |frame| accepts options which |document| doesn't.
% Therefore a second environment called |standaloneframe| is used in the beamer picture files. It will be equal to |frame| in standalone mode, but
% without effect otherwise.
%
% \DescribeMacro{\ifstandalonebeamer}
% This if switch is only true if the class is compiled with the |beamer| option. The package sets it to false.
% It can be used to place beamer specific options in the configuration files, which should be skipped for non-beamer standalone files.
%
% \begin{lstlisting}[language={[latex]tex},gobble=4,frame=lines,caption={Use of \emph{standalone} class.}]
%   % Use of 'standalone' class with a beamer overlay:
%   \documentclass[beamer]{standalone}
%
%   % Load packages needed for this TeX file:
%   \usepackage{tikz}
%
%   % Surround TeX code with 'document' environment as usually:
%   \begin{document}
%   \begin{standaloneframe}[options, e.g. 'fragile' for verbatim content]
%    % Add your TeX code:
%     \only<1>{ One }%
%     \only<2>{ Two }%
%   \end{standaloneframe}
%   \end{document}
% \end{lstlisting}
%
% \begin{lstlisting}[language={[latex]tex},gobble=4,frame=lines,caption={Effective beamer code if compiled standalone.}]
%   \documentclass{beamer}
%
%   \input{standalone.cfg}
%
%   \usepackage{tikz}
%
%   \begin{document}
%   \begin{frame}[your options]
%     \only<1>{ One }%
%     \only<2>{ Two }%
%   \end{frame}
%   \end{document}
% \end{lstlisting}
%
% \begin{lstlisting}[language={[latex]tex},gobble=4,frame=lines,caption={Effective code if included in a beamer presentation.}]
%   \begingroup
%     \only<1>{ One }%
%     \only<2>{ Two }%
%   \endgroup
%   \endinput
% \end{lstlisting}
%
% \subsection{\texttt{standalone.tex}}
% \begin{lstlisting}[language={[latex]tex},gobble=4,frame=lines,caption={Usage of 'standalone.tex'.}]
%   \input{standalone} % use before any '\documentclass'
%   \ifstandalone
%     % Used only if compiled standalone
%   \fi
% \end{lstlisting}
%
% \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|) 
% 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|.
%
% \StopEventually{}
% \clearpage
%
% \section{Implementation}
%
% \subsection{The Package File}
% \iffalse
%<*sty>
% \fi
%    \begin{macrocode}
\expandafter\newif\csname ifstandalone\endcsname
\standalonefalse
%    \end{macrocode}
%    \begin{macrocode}
\@ifundefined{ifstandalonebeamer}{%
\expandafter\newif\csname ifstandalonebeamer\endcsname
\standalonebeamerfalse
}{}%
%    \end{macrocode}
%
% \begin{macro}{\sa@documentclass}
%    \begin{macrocode}
\newcommand{\sa@documentclass}[2][]{%
  \let\document\sa@document
  \expandafter\sa@@documentclass
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\sa@@documentclass}
%    \begin{macrocode}
\def\sa@@documentclass{%
  \begingroup\def\sa@gobbleto{document}\sa@gobble
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\sa@gobble}
%    \begin{macrocode}
\long\def\sa@gobble#1\begin#2{%
  \def\@tempa{#2}%
  \ifx\@tempa\sa@gobbleto
    \def\next{\expandafter\endgroup\expandafter\begin\expandafter{\sa@gobbleto}}%
  \else
    \def\next{\sa@gobble}%
  \fi
  \next
}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
\@ifundefined{standalone}
  {\newenvironment{standalone}[1][]{}{}}
  {}
%    \end{macrocode}
%
% Gobbles all arguments: |<...>[<...>][...]{...}{...}|. Please note that the last two |{ }| arguments are also optional.
%    \begin{macrocode}
\@ifundefined{standaloneframe}
  {\@ifundefined{beamer@newenv}
    {\newenvironment{standaloneframe}[1][]{%
      \@ifnextchar[%]
        {\sa@framegobbleopt}{\sa@framegobbleargs}}{}%
    }
    {\newenvironment<>{standaloneframe}[1][]{%
      \@ifnextchar[%]
        {\sa@framegobbleopt}{\sa@framegobbleargs}}{}%
    }
   \def\sa@framegobbleopt[#1]{\sa@framegobbleargs}
   \def\sa@framegobbleargs{%
     \@ifnextchar\bgroup
       {\sa@framegobbleargs@}%
       {}%
   }
   \def\sa@framegobbleargs@#1{%
    \@ifnextchar\bgroup
      {\@gobble}%
      {}%
   }
  }
  {}
%    \end{macrocode}
%
% \begin{macro}{\sa@orig@document}
%    \begin{macrocode}
\let\sa@orig@document\document
% \end{macro}
%
% \begin{macro}{\sa@orig@enddocument}
%    \begin{macrocode}
\let\sa@orig@enddocument\enddocument
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\document}
%    \begin{macrocode}
\def\document{%
  \sa@orig@document
  \let\documentclass\sa@documentclass
  \ignorespaces
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\sa@document}
%    \begin{macrocode}
\def\sa@document{%
  \let\enddocument\sa@enddocument
  \sa@atbegindocument
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\sa@enddocument}
%    \begin{macrocode}
\def\sa@enddocument{%
  \sa@atenddocument
  \aftergroup\sa@@enddocument
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\sa@atbegindocument}
%    \begin{macrocode}
\def\sa@atbegindocument{%
  \ignorespaces
}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\sa@atenddocument}
%    \begin{macrocode}
\def\sa@atenddocument{%
  \unskip
}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\sa@@enddocument}
%    \begin{macrocode}
\def\sa@@enddocument{%
  %\let\document\sa@orig@document
  \let\enddocument\sa@orig@enddocument
  \endinput
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\sa@processpreamble}
%    \begin{macrocode}
\def\sa@processpreamble{%
  \renewcommand\usepackage[2][]{%
    \message{^^J%
      INFO: Sub-file requires the following package(s):^^J
      \space\space[##1]{##2}^^J%
    }%
  }%
  \let\RequirePackage\usepackage
}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
%%\def\sa@@documentclass{\sa@processpreamble}
%    \end{macrocode}
%
% \iffalse
%</sty>
% \fi
%
% \subsection{The Class File}
% \iffalse
%<*cls>
% \fi
%    \begin{macrocode}
\def\sa@classoptionslist{}
\RequirePackage{kvoptions}
\SetupKeyvalOptions{prefix=sa@}
\DeclareBoolOption[true]{preview}
%    \end{macrocode}
%
% \begin{environment}{standalone}
% The \env{standalone} environment is defined by default to be without effect.
% The \cs{endstandalone} macro is set to |\relax|, so a redefinition with
% \cs{renewenvironment} can be detected later.
%    \begin{macrocode}
\let\standalone\empty
\let\endstandalone\relax
%    \end{macrocode}
% \end{environment}
%
% \begin{macro}{\sa@cls@document}
% \begin{macro}{\sa@cls@enddocument}
%    \begin{macrocode}
\def\sa@cls@document{\standalone}
\def\sa@cls@enddocument{\endstandalone}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% The |beamer| option defines the \env{standalone} environment as a replacement
% of \env{frame}.
%    \begin{macrocode}
\newif\ifstandalonebeamer
\DeclareVoidOption{beamer}{%
  \def\sa@class{beamer}%
  \sa@previewfalse
  \standalonebeamertrue
  \newenvironment{standaloneframe}{%
    \@ifnextchar<%
      {\@standaloneframe}%
      {\@@standaloneframe{}}%
  }{\end{frame}}%
  \def\@standaloneframe<##1>{%
      \@@standaloneframe{<##1>}%
  }
  \def\@@standaloneframe##1{%
    \@ifnextchar[%]
      {\@@@standaloneframe{##1}}%
      {\@@@standaloneframe{##1}[]}%
  }%
  \def\@@@standaloneframe##1[{%
    \@ifnextchar<%
      {\@@@@standaloneframe{##1}[}%
      {\@@@@@@standaloneframe{##1}[}%
  }%
  \def\@@@@standaloneframe##1[##2]{%
    \@ifnextchar[%]
      {\@@@@@standaloneframe{##1}{##2}}%
      {\begin{frame}##1[##2][environment=standaloneframe]}%
  }%
  \def\@@@@@standaloneframe##1##2[##3]{%
      \begin{frame}##1[##2][environment=standaloneframe,##3]%
  }%
  \def\@@@@@@standaloneframe##1[##2]{%
      \begin{frame}##1[environment=standaloneframe,##2]%
  }%
}
%    \end{macrocode}
%
%    \begin{macrocode}
\DeclareStringOption[article]{class}
\DeclareDefaultOption{%
  \xdef\sa@classoptionslist{\sa@classoptionslist,\CurrentOption}%
}
\ProcessKeyvalOptions*\relax
%    \end{macrocode}
%
%    \begin{macrocode}
\let\@classoptionslist\sa@classoptionslist
\xdef\@tempa{[\sa@classoptionslist]{\sa@class}}
\expandafter\LoadClass\@tempa
%    \end{macrocode}
%
%    \begin{macrocode}
\input{standalone.cfg}
%    \end{macrocode}
%
% \subsubsection*{Preview Code}
% The \env{standalone} environment is redefined to use the |preview| environment as
% long it was not redefined in the configuration file.
%    \begin{macrocode}
\ifsa@preview
  \@ifundefined{endstandalone}{%
    \renewenvironment{standalone}
      {\preview   }
      {\endpreview}
  }{}%
  \RequirePackage{preview}
\fi
%    \end{macrocode}
%
%    \begin{macrocode}
\RequirePackage{standalone}[2010/03/21]
\standalonetrue
%    \end{macrocode}
%
% \begin{macro}{\document}
%    \begin{macrocode}
\def\document{%
  \sa@orig@document
  \let\documentclass\sa@documentclass
  \sa@cls@document
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\enddocument}
%    \begin{macrocode}
\def\enddocument{%
  \sa@cls@enddocument
  \sa@orig@enddocument
}
%    \end{macrocode}
% \end{macro}
%
% \iffalse
%</cls>
% \fi
%
% \subsection{Simple TeX File}
% \iffalse
%<*tex>
% \fi
%    \begin{macrocode}
\expandafter\ifx\csname ifstandalone\endcsname\relax
%    \end{macrocode}
%    \begin{macrocode}
\expandafter\newif\csname ifstandalone\endcsname
%    \end{macrocode}
%    \begin{macrocode}
\expandafter\ifx\csname @twoclasseserror\endcsname\documentclass
\else
  \standalonetrue
\fi
%    \end{macrocode}
%    \begin{macrocode}
\fi
%    \end{macrocode}
% \iffalse
%</tex>
% \fi
%
% \subsection{Config File}
% Default content of the configuration file. Users can place there own
% |standalone.cfg| in their |texmf| directory or in the local document directory
% to define their own settings as described above. To load the default config file
% from a user config file use |\input{standalone/standalone.cfg}|.
% \iffalse
%<*cfg>
% \fi
%    \begin{macrocode}
\PassOptionsToPackage{active,tightpage}{preview}%

\ifstandalonebeamer
  \setbeamertemplate{navigation symbols}{}
\fi
%    \end{macrocode}
% \iffalse
%</cfg>
% \fi
%
% \iffalse
%<cfg>% vim: ft=tex
% \fi
% \Finale
% \endinput