📄 preview.dtx.svn-base
字号:
\PreviewOpen[][\def\dt@ptrue{\m@ne=\m@ne}\noindent#1]\[% \PreviewClose\]% \PreviewEnvironment[][\noindent#1]{eqnarray}% \PreviewEnvironment[][\noindent#1]{eqnarray*}% \PreviewEnvironment{displaymath}%}}% \end{macrocode}%% The |textmath| option. Some folderol in order to define the active% |$|% math mode delimiter. \cmd\pr@textmathcheck is used for checking% whether we have a single |$| or double |$$|.% In the latter case, we enter display math (this sort of display math% is not allowed inside of \LaTeX\ because of inconsistent spacing,% but surprisingly many people use it nevertheless). Strictly% speaking, this is incorrect, since not every% |$$| actually means display math. For example, |\hbox{$$}| will% because of restricted horizontal mode rather yield an empty text% math formula. Since our implementation moved the sequence inside of% a |\vbox|, the interpretation will change. People should just not% enter rubbish like that.% \begin{macrocode}\begingroup\def\next#1#2{% \endgroup \DeclareOption{textmath}{% \PreviewEnvironment{math}% \preview@delay{\ifx#1\@undefined \let#1=$%$ \fi\catcode`\$=\active \ifx\xyreuncatcodes\@undefined\else \makeatother\xyreuncatcodes\makeatletter\fi}% \pr@advise@ship\(\pr@endaftergroup{}% \) \pr@advise@ship#1{\@firstoftwo{\let#1=#2% \futurelet\reserved@a\pr@textmathcheck}}{}}% \def\pr@textmathcheck{\expandafter\pr@endaftergroup \ifx\reserved@a#1{#2#2}\expandafter\@gobbletwo\fi#2}}\lccode`\~=`\$\lowercase{\expandafter\next\expandafter~}% \csname pr@\string$%$ \endcsname%</!active>% \end{macrocode}% \begin{macro}{\pr@endaftergroup}% This justs ends the box after the group opened by |#1| is closed% again.% \begin{macrocode}%<*active>\def\pr@endaftergroup#1{#1\aftergroup\pr@endbox}%</active>% \end{macrocode}% \end{macro}%% The |graphics| option.% \begin{macrocode}%<*!active>\DeclareOption{graphics}{% \PreviewMacro[*[[!]{\includegraphics}%]]}% \end{macrocode}% The |floats| option. The complications here are merely to spare us% bug reports about broken document classes that use |\let| on% |\endfigure| and similar. Notable culprits that have not been% changed in years in spite of reports are |elsart.cls| and% |IEEEtran.cls|. Complain when you are concerned.% \begin{macrocode}\def\pr@floatfix#1#2{\ifx#1#2% \ifx#1\@undefined\else \PackageWarningNoLine{preview}{%Your document class has a bad definition^^Jof \string#1, most likely^^J\string\let\string#1=\string#2^^Jwhich has now been changed to^^J\string\def\string#1{\string#2}^^Jbecause otherwise subsequent changes to \string#2^^J(like done by several packages changing float behaviour)^^Jcan't take effect on \string#1.^^JPlease complain to your document class author}% \def#1{#2}\fi\fi}\begingroup\def\next#1#2{\endgroup \DeclareOption{floats}{% \pr@floatfix\endfigure\end@float \pr@floatfix\endtable\end@float \pr@floatfix#1\end@dblfloat \pr@floatfix#2\end@dblfloat \PreviewSnarfEnvironment[![]{@float}%] \PreviewSnarfEnvironment[![]{@dblfloat}%] }}\expandafter\next\csname endfigure*\expandafter\endcsname \csname endtable*\endcsname% \end{macrocode}% The |sections| option.% \begin{macrocode}\DeclareOption{sections}{% \PreviewMacro[!!!!!!*[!]{\@startsection}%]}% \end{macrocode}% We now interpret any further options as driver files we load. Note% that these driver files are loaded even when |preview| is not% active. The reason is that they might define commands (like% \cmd{\PreviewCommand}) that should be available even in case of an% inactive package. Large parts of the |preview| package will not% have been loaded in this case: you have to cater for that.% \begin{macrocode}\DeclareOption* {\InputIfFileExists{pr\CurrentOption.def}{}{\OptionNotUsed}}% \end{macrocode}%% \subsection{Preview attaching commands}% \begin{macro}{\PreviewMacro}% As explained above. Detect possible |*| and call appropriate% macro.% \begin{macrocode}\def\PreviewMacro{\@ifstar\pr@starmacro\pr@macro}% \end{macrocode}% The version without |*| is now rather straightforward.% \begin{macro}{\pr@macro}% \begin{macro}{\pr@domacro}% \begin{macro}{\pr@macroii}% \begin{macro}{\pr@endmacro}% \begin{macrocode}\long\def\pr@domacro#1#2{% \long\def\next##1{#2}% \pr@callafter\next#1]\pr@endparse}\newcommand\pr@macro[1][]{% \toks@{\pr@domacro{#1}}% \long\edef\next[##1]##2{% \noexpand\pr@advise@ship{##2}{\the\toks@{##1\noexpand\pr@endbox}}{}}% \@ifnextchar[\next\pr@macroii}\def\pr@macroii{\next[##1]}\long\def\pr@endmacro#1{#1\pr@endbox}% \end{macrocode}% \end{macro}% \end{macro}% \end{macro}% \end{macro}% \end{macro}% \begin{macro}{PreviewMacro*}% \begin{macro}{\pr@protect@domacro}% \begin{macro}{\pr@starmacro}% The version with |*| has to parse the arguments, then throw them% away. Some internal macros first, then the interface call.% \begin{macrocode}\long\def\pr@protect@domacro#1#2{\pr@protect{% \long\def\next##1{#2}% \pr@callafter\next#1]\pr@endparse}}\newcommand\pr@starmacro[1][]{\toks@{\pr@protect@domacro{#1}}% \long\edef\next[##1]##2{% \noexpand\pr@advise##2{\the\toks@{##1}}}% \@ifnextchar[\next{\next[]}}% \end{macrocode}% \end{macro}% \end{macro}% \end{macro}% \begin{macro}{\PreviewOpen}% As explained above. Detect possible |*| and call appropriate macro.% \begin{macrocode}\def\PreviewOpen{\@ifstar\pr@starmacro\pr@open}% \end{macrocode}% The version without |*| is now rather straightforward.% \begin{macro}{\pr@open}% \begin{macrocode}\newcommand\pr@open[1][]{% \toks@{\pr@domacro{#1}}% \long\edef\next[##1]##2{% \noexpand\pr@advise##2{\begingroup \noexpand\pr@protect@ship {\the\toks@{\begingroup\aftergroup\noexpand\pr@endbox##1}}% {\endgroup}}}% \@ifnextchar[\next\pr@macroii}% \end{macrocode}% \end{macro}% \end{macro}% \begin{macro}{\PreviewClose}% As explained above. Detect possible |*| and call appropriate% macro.% \begin{macrocode}\def\PreviewClose{\@ifstar\pr@starmacro\pr@close}% \end{macrocode}% The version without |*| is now rather straightforward.% \begin{macro}{\pr@close}% \begin{macrocode}\newcommand\pr@close[1][]{% \toks@{\pr@domacro{#1}}% \long\edef\next[##1]##2{% \noexpand\pr@advise{##2}{\the\toks@{##1\endgroup}}}% \@ifnextchar[\next\pr@macroii}% \end{macrocode}% \end{macro}% \end{macro}% \begin{macro}{\PreviewEnvironment}% Actually, this ignores any syntax argument. But don't tell% anybody. Except for the |*|~variant, it respects (actually% ignores) any argument! Of course, we'll need to deactivate% |\end{|\meta{environment}|}| as well.% \begin{macrocode}\def\PreviewEnvironment{\@ifstar\pr@starenv\pr@env}\newcommand\pr@starenv[1][]{\toks@{\pr@starmacro[{#1}]}% \long\edef\next##1##2{% \the\toks@[{##2}]##1}% \begingroup\pr@starenvii}\newcommand\pr@starenvii[2][]{\endgroup \expandafter\next\csname#2\endcsname{#1}% \expandafter\pr@starmacro\csname end#2\endcsname}\newcommand\pr@env[1][]{% \toks@{\pr@domacro{#1}}% \long\edef\next[##1]##2{% \noexpand\expandafter\noexpand\pr@advise@ship \noexpand\csname##2\noexpand\endcsname{\the\toks@ {\begingroup\aftergroup\noexpand\pr@endbox##1}}{\endgroup}}% \@ifnextchar[\next\pr@macroii %] }% \end{macrocode}% \end{macro}% \begin{macro}{\PreviewSnarfEnvironment}% This is a nuisance since we have to advise \emph{both} the% environment and its end.% \begin{macrocode}\newcommand{\PreviewSnarfEnvironment}[2][]{% \expandafter\pr@advise \csname #2\endcsname{\pr@snarfafter{#1}}% \expandafter\pr@advise \csname end#2\endcsname{\pr@endsnarf}}%</!active>% \end{macrocode}% \end{macro}% \begin{macro}{\pr@snarfafter}% \begin{macro}{\pr@startsnarf}% \begin{macro}{\pr@endsnarf}% Ok, this looks complicated, but we have to start a group in order% to be able to hook \cmd{\pr@endbox} into the game only when% \cmd{\ifpr@outer} has triggered the start. And we need to get our% start messages out before parsing the arguments.% \begin{macrocode}%<*active>\let\pr@endsnarf\relax\long\def\pr@snarfafter#1{\ifpr@outer \pr@ship@start \let\pr@ship@start\relax \let\pr@endsnarf\endgroup \else \let\pr@endsnarf\relax \fi \pr@protect{\pr@callafter\pr@startsnarf#1]\pr@endparse}}\def\pr@startsnarf#1{#1\begingroup \pr@startbox{\begingroup\aftergroup\pr@endbox}{\endgroup}% \ignorespaces}%</active>% \end{macrocode}% \end{macro}% \end{macro}% \end{macro}% \begin{macro}{\pr@ship@start}% \begin{macro}{\pr@ship@end}% The hooks \cmd{\pr@ship@start} and \cmd{\pr@ship@end} can be added% to by option files by the help of the \cmd{\g@addto@macro} command% from \LaTeX, and by the \cmd{\pr@addto@front} command from% |preview.sty| itself. They are called just before starting to% process some preview, and just after it. Here is the policy for% adding to them: \cmd{\pr@ship@start} is called inside of the vbox% |\pr@box| before typeset material gets produced. It is, however,% preceded by a break command that is intended for usage in% \cmd{\vsplit}, so that any following glue might disappear. In% case you want to add any material on the list, you have to precede% it with \cmd{\unpenalty} and have to follow it with \cmd{\break}.% You have make sure that under no circumstances any other legal% breakpoints appear before that, and your material should% contribute no nonzero dimensions to the page. For the policies of% the \cmd{\pr@ship@end} hook, see the description on% page~\pageref{sec:prshipend}.% \begin{macrocode}%<*!active>\let\pr@ship@start\@empty\let\pr@ship@end\@empty% \end{macrocode}% \end{macro}% \end{macro}% \begin{environment}{preview}% \begin{environment}{nopreview}% First we write the definitions of these environments when% |preview| is inactive. We will redefine them if |preview| gets% activated.% \begin{macrocode}\newenvironment{preview}{\ignorespaces}{\ifhmode\unskip\fi}\newenvironment{nopreview}{\ignorespaces}{\ifhmode\unskip\fi}% \end{macrocode}% \end{environment}% \end{environment}%% We now process the options and finish in case we are not active.% \begin{macrocode}\ProcessOptions\relax\ifPreview\else\expandafter\endinput\fi%</!active>% \end{macrocode}% Now for the redefinition of the |preview| and |endpreview|% environments:% \begin{macrocode}%<*active>\renewenvironment{preview}{\begingroup \pr@startbox{\begingroup\aftergroup\pr@endbox}% {\endgroup}% \ignorespaces}% {\ifhmode\unskip\fi\endgroup}\renewenvironment{nopreview}{\pr@outerfalse\ignorespaces}% {\ifhmode\unskip\fi}% \end{macrocode}% Let the output routine throw everything gathered regularly away.% Start with all float boxes, continue with output box, pack% everything afloat from \cmd{\@currlist} back into \cmd{\@freelist}.% \begin{macrocode}\output{\def\@elt#1{\global\setbox#1=\box\voidb@x}%
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -