📄 preview.dtx.svn-base
字号:
\@currlist \@elt{255}% \let\@elt\relax \xdef\@freelist{\@currlist\@freelist}% \global\let\@currlist\@empty \deadcycles\z@}% \end{macrocode}% \begin{macro}{\pr@typeinfos}% Then we have some document info that style files might want to% output.% \begin{macrocode}\def\pr@typeinfos{\typeout{Preview: Fontsize \f@size pt}% \ifnum\mag=\@m\else\typeout{Preview: Magnification \number\mag}\fi \ifx\pdfoutput\@undefined \else \ifx\pdfoutput\relax \else \ifnum\pdfoutput>\z@ \typeout{Preview: PDFoutput 1}% \fi \fi \fi}\AtBeginDocument{\pr@typeinfos}% \end{macrocode}% \end{macro}% And at the end we load the default configuration file, so that it% may override settings from this package:% \begin{macrocode}\pr@loadcfg{prdefault}%</active>%</style>% \end{macrocode}%% \section{The option files}% \subsection{The \texttt{auctex} option}% The AUC\TeX\ option will cause error messages to spew. We want them% on the terminal, but we don't want \LaTeX\ to stop its automated% run. We delay \cmd{\nonstopmode} in case the user has any% pseudo-interactive folderol like reading in of file names in his% preamble. Because we are so good-hearted, we will not break this as% long as the document has not started, but after that we need the% error message mechanism operative.%% The |\nofiles| command here tries to avoid clobbering input files% used for references and similar. It will come too late if you call% the package with \cmd{\AtBeginDocument}, so you'll need to issue% |\nofiles| yourself in that case. Previously, this was done% unconditionally in the main style file, but since we don't know what% the package may be used for, this was inappropriate.%% So here is the contents of the |prauctex.def| file:% \begin{macrocode}%<auctex>\ifPreview\else\expandafter\endinput\fi%<auctex>\nofiles%<auctex>\preview@delay{\nonstopmode}% \end{macrocode}% Ok, here comes creative error message formatting. It turns out a% sizable portion of the runtime is spent in I/O. Making the error% messages short is an advantage. It is not possible to convince% \TeX\ to make shorter error messages than this: \TeX\ always wants% to include context. This is about the shortest \ae sthetic one we% can muster.% \begin{macrocode}%<auctex>\begingroup%<auctex>\lccode`\~=`\-%<auctex>\lccode`\{=`\<%<auctex>\lccode`\}=`\>%<auctex>\lowercase{\endgroup%<auctex> \def\pr@msgi{{~}}}%<auctex>\def\pr@msgii{Preview:%<auctex> Snippet \number\pr@snippet\space}%<auctex>\begingroup%<auctex>\catcode`\-=13%<auctex>\catcode`\<=13%<auctex>\@firstofone{\endgroup%<auctex>\def\pr@msg#1{{%%<auctex> \let<\pr@msgi%<auctex> \def-{\pr@msgii#1}%%<auctex> \errhelp{Not a real error.}%%<auctex> \errmessage<}}}%<auctex>\g@addto@macro\pr@ship@start{\pr@msg{started}}%<auctex>\g@addto@macro\pr@ship@end{\pr@msg{ended.%%<auctex> (\number\ht\pr@box+\number\dp\pr@box x\number\wd\pr@box)}}% \end{macrocode}% This looks pretty baffling, but it produces something short and% semi-graphical, namely |<-><->|. That is a macro |<| that expands% into |<->|, where |<| and |>| are the braces around an% \cmd{\errmessage} argument and |-| is a macro expanding to the full% text of the error message. Cough cough. You did not really want to% know, did you?%% Since over/underfull boxes are about the messiest things to parse,% we disable them by setting the appropriate badness limits and making% the variables point to junk. We also disable other stuff. While we% set \cmd{\showboxbreadth} and \cmd{\showboxdepth} to indicate as% little diagnostic output as possible, we keep them operative, so% that the user retains the option of debugging using this stuff. The% other variables concerning the generation of warnings and% daignostics, however, are more often set by commonly employed% packages and macros such as \cmd{\sloppy}. So we kill them off for% good.% \begin{macrocode}%<auctex>\hbadness=\maxdimen%<auctex>\newcount\hbadness%<auctex>\vbadness=\maxdimen%<auctex>\let\vbadness=\hbadness%<auctex>\hfuzz=\maxdimen%<auctex>\newdimen\hfuzz%<auctex>\vfuzz=\maxdimen%<auctex>\let\vfuzz=\hfuzz%<auctex>\showboxdepth=-1%<auctex>\showboxbreadth=-1% \end{macrocode}% Ok, now we load a possible configuration file.% \begin{macrocode}%<auctex>\pr@loadcfg{prauctex}% \end{macrocode}% And here we cater for several frequently used commands in% |prauctex.cfg|:% \begin{macrocode}%<auccfg>\PreviewMacro*[[][#1{}]\footnote%<auccfg>\PreviewMacro*[?[{@{[]}}{}][#1]\item%<auccfg>\PreviewMacro*\emph%<auccfg>\PreviewMacro*\textrm%<auccfg>\PreviewMacro*\textit%<auccfg>\PreviewMacro*\textsc%<auccfg>\PreviewMacro*\textsf%<auccfg>\PreviewMacro*\textsl%<auccfg>\PreviewMacro*\texttt%<auccfg>\PreviewMacro*\textcolor%<auccfg>\PreviewMacro*\mbox%<auccfg>\PreviewMacro*[][#1{}]\author%<auccfg>\PreviewMacro*[][#1{}]\title%<auccfg>\PreviewMacro*\and%<auccfg>\PreviewMacro*\thanks%<auccfg>\PreviewMacro*[][#1{}]\caption%<auccfg>\preview@delay{\@ifundefined{pr@\string\@startsection}{%%<auccfg> \PreviewMacro*[!!!!!!*][#1{}]\@startsection}{}}%<auccfg>\PreviewMacro*\index% \end{macrocode}%% \subsection{The \texttt{lyx} option}% The following is the option providing LyX with info for its preview% implementation.% \begin{macrocode}%<lyx>\ifPreview\else\expandafter\endinput\fi%<lyx>\pr@loadcfg{prlyx}%<lyx>\g@addto@macro\pr@ship@end{\typeout{Preview:%<lyx> Snippet \number\pr@snippet\space%<lyx> \number\ht\pr@box\space \number\dp\pr@box \space\number\wd\pr@box}}% \end{macrocode}%% \subsection{The \texttt{counters} option}% This outputs a checkpoint. We do this by saving all counter% registers in backup macros starting with |\pr@c@| in their name. A% checkpoint first writes out all changed counters (previously% unchecked counters are not written out unless different from zero),% then saves all involved counter values. \LaTeX\ tracks its counters% in the global variable \cmd{\cl@ckpt}.% \begin{macrocode}%<counters>\ifPreview\else\expandafter\endinput\fi%<counters>\def\pr@eltprint#1{\expandafter\@gobble\ifnum\value{#1}=0%%<counters> \csname pr@c@#1\endcsname\else\relax%<counters> \space{#1}{\arabic{#1}}\fi}%<counters>\def\pr@eltdef#1{\expandafter\xdef%<counters> \csname pr@c@#1\endcsname{\arabic{#1}}}%<counters>\def\pr@ckpt#1{{\let\@elt\pr@eltprint\edef\next{\cl@@ckpt}%%<counters> \ifx\next\@empty\else\typeout{Preview: Counters\next#1}%%<counters> \let\@elt\pr@eltdef\cl@@ckpt\fi}}%<counters>\g@addto@macro\pr@ship@start{\pr@ckpt:}%<counters>\g@addto@macro\pr@ship@end{\pr@ckpt.}% \end{macrocode}%% \subsection{Debugging options}% Those are for debugging the operation of |preview|, and thus are% mostly of interest for people that want to use |preview| for their% own purposes. Since debugging output is potentially confusing to% the error message parsing from AUC\TeX, you should not turn on% |\tracingonline| or switch from |\nonstopmode| unless you are% certain your package will never be used with \previewlatex.%% \paragraph{The \texttt{showbox} option} will generate diagnostic% output for every produced box. It does not delay the resetting of% the |\showboxbreadth| and |\showboxdepth| parameters so that you can% still change them after the loading of the package. It does,% however, move them to the end of the package loading, so that they% will not be affected by the |auctex| option.% \begin{macrocode}%<showbox>\ifPreview\else\expandafter\endinput\fi%<showbox>\AtEndOfPackage{%%<showbox> \showboxbreadth\maxdimen%<showbox> \showboxdepth\maxdimen}%<showbox>\g@addto@macro\pr@ship@end{\showbox\pr@box}% \end{macrocode}%% \paragraph{The \texttt{tracingall} option} is for the really heavy% diagnostic stuff. For the reasons mentioned above, we do not want% to change the setting of the interaction mode, nor of the% |tracingonline| flag. If the user wants them different, he should% set them outside of the preview boxes.% \begin{macrocode}%<tracingall>\ifPreview\else\expandafter\endinput\fi%<tracingall>\pr@addto@front\pr@ship@start{\let\tracingonline\count@%<tracingall> \let\errorstopmode\@empty\tracingall}% \end{macrocode}%% \subsection{Supporting conversions}% It is not uncommon to want to use the results of |preview| as% images. One possibility is to generate a flurry of EPS files with% \begin{quote}% |dvips -E -i -Ppdf -o| \meta{outputfile}|.000| \meta{inputfile}% \end{quote}% However, in case those are to be processed further into graphic% image files by Ghostscript, this process is inefficient. One cannot% use Ghostscript in a single run for generating the files, however,% since one needs to set the page size (or full size pages will be% produced). The |tightpage| option will set the page dimensions at% the start of each PostScript page so that the output will be sized% appropriately. That way, a single pass of Dvips followed by a% single pass of Ghostscript will be sufficient for generating all% images.%% You will have to specify the output driver to be used, either% |dvips| or |pdftex|.%% \begin{macro}{\PreviewBorder}% \begin{macro}{\PreviewBbAdjust}% We start this off with the user tunable parameters which get% defined even in the case of an inactive package, so that% redefinitions and assignments to them will always work:% \begin{macrocode}%<tightpage>\ifx\PreviewBorder\@undefined%<tightpage> \newdimen\PreviewBorder%<tightpage> \PreviewBorder=0.50001bp%<tightpage>\fi%<tightpage>\ifx\PreviewBbAdjust\@undefined%<tightpage> \def\PreviewBbAdjust{-\PreviewBorder -\PreviewBorder%<tightpage> \PreviewBorder \PreviewBorder}%<tightpage>\fi% \end{macrocode}% \end{macro}% \end{macro}% Here is stuff used for parsing this:% \begin{macrocode}%<tightpage>\ifPreview\else\expandafter\endinput\fi%<tightpage>\def\pr@nextbb{\edef\next{\next\space\number\dimen@}%%<tightpage> \expandafter\xdef\csname pr@bb@%%<tightpage> \romannumeral\count@\endcsname{\the\dimen@}%%<tightpage> \advance\count@\@ne\ifnum\count@<5%<tightpage> \afterassignment\pr@nextbb\dimen@=\fi}% \end{macrocode}% And here is the stuff that we fudge into our hook. Of course, we% have to do it in a box, and we start this box off with our special.% There is one small consideration here: it might come before any% |\AtBeginDvi| stuff containing header specials. It turns out Dvips% rearranges this amicably: header code specials get transferred to% the appropriate header section, anyhow, so this ensures that we come% right after the bop section. We insert the 7~numbers here: the% 4~bounding box adjustments, and the 3~\TeX\ box dimensions. In case% the box adjustments have changed since the last time, we write them% out to the console.% \begin{macrocode}%<tightpage>\ifnum\pr@graphicstype=\z@%<tightpage> \ifcase \ifx\pdfoutput\@undefined \@ne\fi%<tightpage> \ifx\pdfoutput\relax \@ne\fi%<tightpage> \ifnum\pdfoutput>\z@ \tw@\fi \@ne \or%<tightpage> \ExecuteOptions{dvips}\relax \or%<tightpage> \ExecuteOptions{pdftex}\relax\fi\fi%<tightpage>\global\let\pr@bbadjust\@empty%<tightpage>\pr@addto@front\pr@ship@end{\begingroup%<tightpage> \let\next\@gobble%<tightpage> \count@\@ne\afterassignment\pr@nextbb%<tightpage> \dimen@\PreviewBbAdjust%<tightpage> \ifx\pr@bbadjust\next%<tightpage> \else \global\let\pr@bbadjust\next%<tightpage> \typeout{Preview: Tightpage \pr@bbadjust}%%<tightpage> \fi\endgroup}%<tightpage>\ifcase\pr@graphicstype%<tightpage>\or%<tightpage> \g@addto@macro\pr@ship@end{\setbox\pr@box\hbox{%%<tightpage> \special{ps::\pr@bbadjust\space%<tightpage> \number\ifdim\ht\pr@box>\z@ \ht\pr@box%<tightpage> \else \z@%<tightpage> \fi \space%<tightpage> \number\ifdim\dp\pr@box>\z@ \dp\pr@box%<tightpage> \else \z@%<tightpage> \fi \space%<tightpage> \number\ifdim\wd\pr@box>\z@ \wd\pr@box%<tightpage> \else \z@%<tightpage> \fi}\box\pr@box}}%<tightpage>\or%<tightpage> \g@addto@macro\pr@ship@end{{\dimen@\ht\pr@box%<tightpage> \ifdim\dimen@<\z@ \dimen@\z@\fi%<tightpage> \advance\dimen@\pr@bb@iv%<tightpage> \dimen@ii=\dimen@%<tightpage> \global\pdfvorigin\dimen@%<tightpage> \dimen@\dp\pr@box%<tightpage> \ifdim\dimen@<\z@ \dimen@\z@\fi%<tightpage> \advance\dimen@-\pr@bb@ii%<tightpage> \advance\dimen@\dimen@ii%<tightpage> \global\pdfpageheight\dimen@%<tightpage> \dimen@\wd\pr@box%<tightpage> \ifdim\dimen@<\z@ \dimen@=\z@\fi%<tightpage> \advance\dimen@-\pr@bb@i%<tightpage> \advance\dimen@\pr@bb@iii%<tightpage> \global\pdfpagewidth\dimen@%<tightpage> \global\pdfhorigin-\pr@bb@i}}%<tightpage>\fi% \end{macrocode}% Ok, here comes the beef. First we fish
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -