% \iffalse %% Package `export' to use with LaTeX 2e %% Copyright (C) 1996 Jean-Pierre Drucbert, all rights reserved %% %% You may use and distribute this file freely, provided that %% you don't pretend that you wrote it. % %\NeedsTeXFormat{LaTeX2e}[1996/06/01] %\ProvidesPackage{float} % [1996/09/20 v1.0 Exportation of LaTeX registers (JPFD)] % %<*driver> \documentclass{ltxdoc} \GetFileInfo{export.sty} \def\filedate{1996/09/20} \def\fileversion{v1.0} \usepackage{array} \EnableCrossrefs %\DisableCrossrefs % Say \DisableCrossrefs if index is ready \RecordChanges % Gather update information \CodelineIndex % Index code by line number \title{This package allows the exportation of \LaTeX\ registers, like counters, rigid and rubber lengths.\thanks{This file has version number \fileversion.}} \author{Jean-Pierre Drucbert\\\texttt{drucbert@onecert.fr}}% \date{\filedate} \def\bs{\texttt{\char'134}} \newlength{\clw}\setlength{\clw}{0.39\textwidth} \let\pkg\textsf \begin{document} \maketitle \DocInput{export.dtx} \end{document} % % \fi % % \CheckSum{160} % % \changes{v1.0}{20 Sep 96}{First officially released version.} % % \DoNotIndex{\@Mii,\@Miv,\@cons,\@currlist,\@dblarg,\@dbldeferlist} % \DoNotIndex{\@dblfloat,\@dottedtocline,\@eha,\@Esphack,\@float} % \DoNotIndex{\@floatpenalty,\@ifnextchar,\@ifundefined,\@latexerr} % \DoNotIndex{\@mkboth,\@namedef,\@nameuse,\@parboxrestore,\@spaces} % \DoNotIndex{\@starttoc,\@tempa,\@tempboxa,\@tempdima,\@warning} % \DoNotIndex{\addcontentsline,\addtocounter,\advance,\arabic,\bfseries} % \DoNotIndex{\bgroup,\box,\chapter,\columnwidth,\csname,\def,\dimen,\docdate} % \DoNotIndex{\edef,\egroup,\else,\endcsname,\endinput,\expandafter,\fi} % \DoNotIndex{\filedate,\fileversion,\global,\hbadness,\hbox,\hfil,\hrule} % \DoNotIndex{\hsize,\ht,\if@twocolumn,\ifdim,\iffalse,\ifnum,\iftrue,\ifvbox} % \DoNotIndex{\ifx,\ignorespaces,\intextsep,\kern,\let,\long,\moveleft,\newbox} % \DoNotIndex{\newcommand,\newcounter,\newif,\newsavebox,\noexpand,\normalsize} % \DoNotIndex{\numberline,\PackageError,\PackageWarning,\par,\parindent} % \DoNotIndex{\penalty,\prevdepth,\protect,\refstepcounter,\relax} % \DoNotIndex{\renewcommand,\rmfamily,\section,\setbox,\setcounter,\space} % \DoNotIndex{\textheight,\the,\typeout,\unvbox,\uppercase,\vadjust,\value} % \DoNotIndex{\vbox,\vrule,\vskip,\vspace,\wd,\z@} % % \begin{abstract} % This package\footnote{% % \begin{tabular}[t]{l} % Copyright \copyright\ 1996 by\\ % Jean-Pierre Drucbert\vphantom{bp}\\ % ONERA/CERT GPI\vphantom{bp}\\ % Office National d'\'Etudes et de Recherches A\'erospatiales\vphantom{bp}\\ % Centre d'\'Etudes et de Recherches de Toulouse\vphantom{bp}\\ % Groupe de Prestations Informatiques\vphantom{bp}\\ % Complexe Scientifique de Rangueil\vphantom{bp}\\ % \\ % 2, Avenue \'Edouard Belin\vphantom{bp}\\ % BP 4025 F-31055 TOULOUSE CEDEX\vphantom{bp}\\ % FRANCE\vphantom{bp}\\ % \vphantom{bp}\\ % Email: \texttt{drucbert@onecert.fr}\vphantom{bp}\\ % \end{tabular}} % allows you to export or import the values of various \LaTeX\ % registers like counters and lengths (rigid or rubber). This could be % useful to fabricate ``composite'' documents or to pass some data % from a document to another one. % \end{abstract} % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % \section{The \pkg{export} package} % This package is designed to transmit data of type \meta{counter} or % \meta{length} % from a \LaTeX\ document to another. You must be aware % that this package must be used \emph{with exterme care}. % The passing of data is done via a file. A first document % \emph{exports} the data by invoking the following sequence of commands: % \DescribeMacro{\openexport} % \DescribeMacro{\closeexport} % \DescribeMacro{\Export} % \DescribeMacro{\ExportLength} % \DescribeMacro{\PreciseExportLength} % \begin{quote}\ttfamily % \bs openexport\{\meta{file}\}\\ % \bs Export\{\meta{counter}\}\\ % \bs Export\{\meta{counter}\}\\ % \qquad.\\ % \qquad.\\ % \qquad.\\ % \bs ExportLength\{\meta{length}\}\\ % \bs PreciseExportLength\{\meta{length}\}\\ % \qquad.\\ % \qquad.\\ % \qquad.\\ % \bs closeexport\\ % \end{quote} % where \meta{file} is the file used to carry the data (its name will have % the \texttt{.xpt} % extension, but you must not give it), \meta{counter} % is the name of a \LaTeX\ counter % (i.e. one of the well known counters % \texttt{chapter}, \texttt{section}, \ldots, % \texttt{equation}, etc.), or a counter you have declared by |\newcounter|. % Also, % \meta{length} is the name (\emph{without the backslash}) of a % \LaTeX\ length like % \texttt{parskip} or of a length declared by % |\newlength|. In the ``importing'' document, % we will find a command |\Import{|\meta{file}|}|. The |\ExportLength| % command exports a length expressed in \emph{points} (\texttt{pt}) % which some fractionnal digits (5 is the maximum), while % |\PreciseExportLength| exports the length expressed in % \emph{scaled points} units (\texttt{sp}, 65536~\texttt{sp} make a point), % so it avoids possible rounding errors. % % \DescribeMacro{\ExportPageLayout} % If you want to export \emph{all} the dimensions (lengths) describing the % page layout, just use the |\ExportPageLayout| command. In a standard way, % you should export only that into a given file, which should % be imported in the preamble % of the importing document. This method allows to have two documents with % similar page layouts. % This package is very useful when associated which the \pkg{dvipaste} % package, which allows you to prepare rectangular page pieces and to % ``paste'' these page pieces into your document. % \textbf{Warning:} if a such pasted piece modifies an imported counter % or length, you must take account of that alteration in the document % receiving the pasted piece. % % The \pkg{dvipaste} package is not available from CTAN archives, but % \texttt{dvipaste.tex} is. Get it (and the accompagning files), % copy \texttt{dvipaste.tex} into % \texttt{dvipaste.sty}, then edit \texttt{dvipaste.sty} to replace % |\line| by |\@@line|, and read the documentation of \pkg{dvipaste}: % you will also need the \texttt{dvipaste.c} program. % % A simple example is described in the next pages. % \clearpage % \begin{enumerate} % \item the main document \texttt{a.tex} exports the counters % \texttt{equation} and \texttt{chapter}, via the file \texttt{x.xpt}, % toward the document \texttt{b.tex}. % Adding to that, \texttt{a.tex} imports the labels defined in \texttt{b.tex} % (using the \pkg{xr} package, from David Carlisle). % \begin{quotation}\footnotesize % \unskip\hspace*{-4\parindent}\begin{tabular}{p{\clw}c|cp{\clw}} % \null\hfill\texttt{a.tex}\hfill\null% % &\quad&\quad&\null\hfill\texttt{b.tex}\hfill\null\\\hline % \verb|\documentclass{article}%|&&&\verb|\documentclass{article}%|\\ % \verb|\usepackage%|&&&\verb|\usepackage%|\\ % \verb| {...,export,dvipaste,xr,...}|&&&\verb| {...,export,dvipaste,...}|\\ % \verb|\externaldocument{b}|&&&\\ % \verb|\begin{document}|&&&\verb|\begin{document}|\\ % \null\hfill$\vdots$\hfill$\vdots$\hfill\null% % &&&\null\hfill$\vdots$\hfill$\vdots$\hfill\null\\ % \null\hfill$\vdots$\hfill$\vdots$\hfill\null% % &&&\null\hfill$\vdots$\hfill$\vdots$\hfill\null\\ % \verb|\openexport{x}|&&&\\ % \verb|\Export{equation}|&&&\\ % \verb|\Export{chapter}|&&&\\ % \null\hfill$\vdots$\hfill$\vdots$\hfill\null% % &&&\null\hfill$\vdots$\hfill$\vdots$\hfill\null\\ % \null\hfill$\vdots$\hfill$\vdots$\hfill\null% % &&&\null\hfill$\vdots$\hfill$\vdots$\hfill\null\\ % \verb|\closeexport|&&&\\ % \end{tabular} % % \end{quotation} % % \item The document \texttt{b.tex} imports the data contained in % the file \texttt{x.xpt}, % i.e. the values of the \texttt{equation} and \texttt{chapter} counters. % \begin{quotation}\footnotesize % \unskip\hspace*{-4\parindent}\begin{tabular}{p{\clw}c|cp{\clw}} % \null\hfill\tt a.tex\hfill\null% % &\quad&\quad&\null\hfill\tt b.tex\hfill\null\\\hline % &&&\verb|\Import{x}| % \end{tabular} % % \end{quotation} % % \item the it uses this counter in preparing an equation in a logical box: % \begin{quotation}\footnotesize % \unskip\hspace*{-4\parindent}\begin{tabular}{p{\clw}c|cp{\clw}} % \null\hfill\tt a.tex\hfill\null% % &\quad&\quad&\null\hfill\tt b.tex\hfill\null\\\hline % &&&\verb|\setbox0=\hbox{%|\\ % &&&\verb| \begin{minipage}{\textwidth}|\\ % &&&\verb|\begin{equation}|\\ % &&&\verb|a=b \label{eq-a}|\\ % &&&\verb|\end{equation}|\\ % &&&\verb|\end{minipage}}|\\ % &&&\verb|\sendout{\box0}|\\ % \null\hfill$\vdots$\hfill$\vdots$\hfill\null% % &&&\null\hfill$\vdots$\hfill$\vdots$\hfill\null\\ % \null\hfill$\vdots$\hfill$\vdots$\hfill\null% % &&&\null\hfill$\vdots$\hfill$\vdots$\hfill\null\\ % &&&\verb|\end{document}|\\ % \end{tabular} % % \end{quotation} % % \item The document \texttt{a.tex} ``pastes'' the piece created by % \texttt{b.tex}, then explicitely increments the \texttt{equation} % counter, since the pasted piece contains an unaccounted equation% % \footnote{An other, more general, method would be to ``export back'' % the counter via an other file. This method is used when several % counters are involved.}: % \begin{quotation}\footnotesize % \unskip\hspace*{-4\parindent}\begin{tabular}{p{\clw}c|cp{\clw}} % \null\hfill\tt a.tex\hfill\null% % &\quad&\quad&\null\hfill\tt b.tex\hfill\null\\\hline % \null\hfill$\vdots$\hfill$\vdots$\hfill\null% % &&&\null\hfill$\vdots$\hfill$\vdots$\hfill\null\\ % \null\hfill$\vdots$\hfill$\vdots$\hfill\null% % &&&\null\hfill$\vdots$\hfill$\vdots$\hfill\null\\ % \verb|\noindent\paste{b}{1}|&&&\\ % \verb|\stepcounter{equation}|&&&\\ % \null\hfill$\vdots$\hfill$\vdots$\hfill\null% % &&&\null\hfill$\vdots$\hfill$\vdots$\hfill\null\\ % \null\hfill$\vdots$\hfill$\vdots$\hfill\null% % &&&\null\hfill$\vdots$\hfill$\vdots$\hfill\null\\ % \end{tabular} % % \end{quotation} % \end{enumerate} % % In fact, the following sequence of actions must be performed here: % \begin{quote}\sloppy % \begin{tabular}{lcp{8cm}} % \textbf{latex b}&\qquad&to create the files \texttt{b.dat}, which % contain the dimensions of the pieces to ``paste'' and % \texttt{b.dvi} contains the pieces themselves. But \texttt{b.tex} % will not be able to import anything, because \texttt{x.xpt} has % not yet been created;\\ % \textbf{latex a}&&to create \texttt{x.xpt};\\ % \textbf{latex b}&&to create again \texttt{b.dat} with the right % dimensions and \texttt{b.dvi} containing correct values for % equation numbers, since importation could be done;\\ % \textbf{latex a}&&to take into account the new dimensions in % \texttt{b.dat};\\ % \textbf{dvipaste a}&&to ``paste'' into \texttt{a.dvi} the pieces % coming from \texttt{b.dvi}. % \end{tabular} % \end{quote} % % Note that the \pkg{xr} package, from David Carlisle, allows you % to pass \meta{label} information (i.e. to use |\ref{|\meta{label}|}| % or |\pageref{|\meta{label}|}| when the \meta{label} is % defined by |\label{|\meta{label}|}| in an other \LaTeX\ document. % % \subsection{Figures and Tables} % \DescribeMacro{\xcaptionf} % \DescribeMacro{\xcaptiont} % In the case of a figure or table which is ``pasted'' this way into % a document \emph{with} its caption, this one will not be present in % the list of figures or tables. An easy solution is to use a % |\xcaptionf{|\meta{caption}|}| (or |\xcaptiont{|\meta{caption}|}| % for a table) command. These commands will increment the figure or % table counter. % % \subsection{Inserting several pages} % Sometimes, you wiil need to separately typeset several pages of a % document. To accomplish that, you prepare a second document % containing only the desired pages. This second document % will need, by exemple, some packages not used in the main document % (often because they require too much resources). To get correctly % numbered pages, figures, tables, notes, etc., % in the main document and in the secondary document, you just have to % export the corresponding counters from the main document \emph{before} % the insertion, to import them at the beginning of the secondary document, % to export them again (vi an other file) at the end of the secondary % document, and at least to import them (via this second file) % \emph{after} the insertion into the main document. % % \begin{quotation}\sffamily\noindent % It will certainly be necessary to transmit the page counter, % which is named ``\texttt{page}''. You must then add a % |\clearpage| command \emph{before} the exportation. % This is mandatory only if the exported value must be used to % number the page which follows the exportation. Do not export % the page counter to an auxiliary document in which you are creating % pieces to be ``pasted'' into your document (in such an auxiliary document, % the ``page counter'' is in fact a counter of pieces to be pasted. % \end{quotation} % % The insertion is only logical: you will have to do it manually in % the printed paper sheets, or to use software tools manipulating % \texttt{.dvi} files (e.g. \textbf{dvidvi}, \textbf{dviselect}, % and \textbf{dviconcat}). A serious problem subsists: % if they are sectionning commands and floating elements % (like figures and tables) with captions in the secondary document, % what to do to have a correct table of contents, a correct % list of figures and tables in the main document? % A similar problem arises for the bibliography. You just need to % add, in the main document, at the insertion point, a % command: % \DescribeMacro{\AddInputInAux} % \begin{quote}\tt % \bs AddInputInAux\{\meta{secondary document}.aux\} % \end{quote} % and so the \texttt{.aux} file of the secondary document will be % considered as an auxiliary file (of first or second level) of % the main document. This method has a small drawback: % if you declare the main document as an external document % (as defined by the \pkg{xr} package) of the secondary document % in order to be able to reference labels of the main document (or % of parts of it) from the secondary one, you will have to use the % optionnal argument in the command: % \begin{quote}\ttfamily % \bs externaldocument[\meta{optiannal arg.}]\{\meta{main document}\}\\ % \bs externaldocument[\meta{optionnal arg.}]\{\meta{part % of main document}\} % \end{quote} % else the labels in the main document (or parts of it) would be % considered as defined twice during the processing of the secondary % document. This happens not often, but if you have this problem, the % solution is simple but not evident. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % \StopEventually{\PrintIndex\PrintChanges} % % \clearpage % \section{Implementation} % % \begin{macrocode} %<*package> % \end{macrocode} % % \begin{macro}{\export} % First, we declare the |\export| write channel: % \begin{macrocode} \newwrite\export % \end{macrocode} % \end{macro} % % \begin{macro}{\openexport} % The command |\openexport| announce the beginning of a sequence % of exportations and opens the file which will be used to % carry the data: % \begin{macrocode} \def\openexport#1{% \typeout{^^JExportations into #1.xpt.^^J}% \immediate\openout\export #1.xpt} % \end{macrocode} % \end{macro} % % \begin{macro}{\closeexport} % The command |\closeexport| terminates a sequence of exportations % by closing the file and announcing. Opening and closing are |\immediate|. % \begin{macrocode} \def\closeexport{\immediate\closeout\export% \typeout{^^JEnd of exportations.^^J}} % \end{macrocode} % \end{macro} % % \begin{macro}{\ExportLength} % And now, the exporting commands. To export a length in points, % we just use |\the|\meta and write it as an argument of % a |\setlength| command. This command may be used for rigid % and rubber lengths, because |\the| gives the shrinking and % stretching parts of a rubber length. % \begin{macrocode} \def\ExportLength#1{% \typeout{Exportation of length #1}% \immediate\write\export{\string\setlength{\csname #1\endcsname}% {\the\csname #1\endcsname}}} % \end{macrocode} % \end{macro} % % \begin{macro}{\PreciseExportLength} % But for rigid lengths (for rubber ones, you would lose the % skrinking and stretching parts), you shoud use % |\PreciseExportLength|, which export the length expressed in % scaled points. The trick is to use |\number| in place of |\the|, % and adding \texttt{sp} for units. % \begin{macrocode} \def\PreciseExportLength#1{% \typeout{Precise exportation of length #1}% \immediate\write\export{\string\setlength{\csname#1\endcsname}% {\number\csname #1\endcsname sp}}} % \end{macrocode} % \end{macro} % % \begin{macro}{\Export} % Exporting a counter is rather trivial, using |\@arabic| to get % its value from the internal name of the \LaTeX\ counter. % \begin{macrocode} \def\Export#1{% \typeout{Exportation of counter #1}% \immediate\write\export{\string\setcounter{#1}% {\@arabic\csname c@#1\endcsname}}} % \end{macrocode} % \end{macro} % % \begin{macro}{\Import} % Importing the data is easy: open the file for reading, % read it: the |\setcounter| and |\setlength| commands are % executed, then close it. % \begin{macrocode} \def\Import#1{% \typeout{^^JImportations from #1.xpt^^J}% \InputIfFileExists{#1.xpt}{\relax}{\relax}} % \end{macrocode} % \end{macro} % % \begin{macro}{\xcaptionf} % Now, the two caption commands. They increment the figure or table counter, % then call the internal macro |\@xcaption|. We provide |\xcaption| if you % have other classes of floats. % \begin{macrocode} \def\xcaptionf{\refstepcounter{figure} \@dblarg{\@xcaption{figure}}} % \end{macrocode} % \end{macro} % \begin{macro}{\xcaptiont} % \begin{macrocode} \def\xcaptiont{\refstepcounter{table} \@dblarg{\@xcaption{table}}} % \end{macrocode} % \end{macro} % \begin{macro}{\xcaption} % \begin{macrocode} \def\xcaption#1{\refstepcounter{#1} \@dblarg{\@xcaption{#1}}} % \end{macrocode} % \end{macro} % % % \begin{macro}{\@xcaption} % \begin{macrocode} \long\def\@xcaption#1[#2]#3{\par\addcontentsline{\csname ext@#1\endcsname}{#1}{\protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}}% % ^^A \begingroup % ^^A \@parboxrestore % ^^A \normalsize % ^^A \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par % ^^A \endgroup } % \end{macrocode} % \end{macro} % % \begin{macro}{\iprotected@write} % We need these two internal macros for |\AddInputInAux|. They are % slighty modified copies of similar macros in the \LaTeX\ kernel. % \begin{macrocode} \def\iprotected@write#1#2#3{% \begingroup \let\thepage\relax #2% \let\protect\@unexpandable@protect \edef\reserved@a{\immediate\write#1{#3}}% \reserved@a \endgroup \if@nobreak\ifvmode\nobreak\fi\fi } % \end{macrocode} % \end{macro} % % \begin{macro}{\@inputx} % \begin{macrocode} \def\@inputx#1{{\def\bibcite##1##2{\relax}\@input{#1}}} % \end{macrocode} % \end{macro} % % \begin{macro}{\AddInputInAux} This macro write an |\@inputx| of the given file into the \texttt{.aux} file. % \begin{macrocode} \def\AddInputInAux#1{% \iprotected@write\@auxout {% \let\label\@gobble \let\index\@gobble \let\glossary\@gobble}% {\string\@inputx{#1}% }% }% % \end{macrocode} % \end{macro} % % \begin{macro}{\ExportPageLayout} % This macro is just a list of exportations of the lengths defining the % page layout, because it would be so boring to type all that! % \begin{macrocode} \def\ExportPageLayout{% \PreciseExportLength{hsize} \PreciseExportLength{vsize} \PreciseExportLength{hoffset} \PreciseExportLength{voffset} \PreciseExportLength{linewidth} \PreciseExportLength{columnwidth} \PreciseExportLength{columnsep} \PreciseExportLength{columnseprule} \PreciseExportLength{parindent} \PreciseExportLength{hoffset} \PreciseExportLength{voffset} \PreciseExportLength{oddsidemargin} \PreciseExportLength{evensidemargin} \PreciseExportLength{headheight} \PreciseExportLength{headsep} \PreciseExportLength{textheight} \PreciseExportLength{textwidth} \PreciseExportLength{paperheight} \PreciseExportLength{paperwidth} \PreciseExportLength{marginparsep} \PreciseExportLength{marginparwidth} \PreciseExportLength{marginparpush} \PreciseExportLength{footskip}} \endinput % \end{macrocode} % \end{macro} % \Finale % \end{document} \endinput