summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/export/export.dtx
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/export/export.dtx
Initial commit
Diffstat (limited to 'macros/latex/contrib/export/export.dtx')
-rw-r--r--macros/latex/contrib/export/export.dtx715
1 files changed, 715 insertions, 0 deletions
diff --git a/macros/latex/contrib/export/export.dtx b/macros/latex/contrib/export/export.dtx
new file mode 100644
index 0000000000..ca2d488722
--- /dev/null
+++ b/macros/latex/contrib/export/export.dtx
@@ -0,0 +1,715 @@
+% \iffalse
+%% Package `export' to use with LaTeX 2e
+%% Copyright (C) 1996, 1997, 1998, 1999 Jean-Pierre F. Drucbert, all rights reserved
+%%
+%% You may use and distribute this file freely, provided that
+%% you don't pretend that you wrote it.
+%
+% It may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either version 1.1
+% 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.1 or later is part of all distributions of LaTeX
+% version 1999/06/01 or later.
+%
+%<package>\NeedsTeXFormat{LaTeX2e}[1996/06/01]
+%<package>\ProvidesPackage{export}
+%<package> [2000/10/16 v1.8 Exportation of LaTeX registers (JPFD)]
+%
+%<*driver>
+\documentclass{ltxdoc}
+\GetFileInfo{export.sty}
+\def\filedate{2000/10/16}
+\def\fileversion{v1.8}
+\usepackage{array,multicol}
+\EnableCrossrefs
+%\DisableCrossrefs % Say \DisableCrossrefs if index is ready
+\RecordChanges % Gather update information
+\CodelineIndex % Index code by line number
+\title{The \pkg{export} package}
+\author{Jean-Pierre F. 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}
+%</driver>
+% \fi
+%
+% \CheckSum{271}
+%
+% \changes{v1.0}{20 Sep 96}{First officially released version.}
+% \changes{v1.1}{18 Jul 97}{Corrected two nasty bugs.}
+% \changes{v1.2}{12 Sep 97}{Added exporting of lengths \cs{topmargin}
+% and \cs{topskip}.
+% Added comment on \cs{ExportLength}.}
+% \changes{v1.3}{12 Sep 97, pm}{Typos corrected in documentation, index on 2 columns.}
+% \changes{v1.4}{17 Oct 97}{Added optionnal argument to
+% \cs{openexport} and \cs{Import} to specify a file extension.
+% Added new parameters in \cs{ExportPageLayout}.}
+% \changes{v1.5}{18 Oct 97}{Added \cs{ExportParameter}.
+% Hence improved \cs{ExportPageLayout}. Added \cs{ExportArrayParams}.}
+% \changes{v1.6}{03 Aug 99}{Added LPPL license. Minor corrections.}
+% \changes{v1.7}{03 Sep 99}{Added \cs{ExportMuskip}.}
+% \changes{v1.8}{16 Oct 2000}{Added \cs{ExportIf}.}
+%
+% \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, 1997, 1998, 1999, 2000, 2001 by\\
+% Jean-Pierre F. Drucbert\vphantom{bp}\\
+% ONERA/Centre de Toulouse SRI\vphantom{bp}\\
+% Office National d'\'Etudes et de Recherches A\'erospatiales\vphantom{bp}\\
+% Centre de Toulouse\vphantom{bp}\\
+% Service R\'eseaux et Informatique\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 extreme 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}
+% \DescribeMacro{\ExportMuskip}
+% \DescribeMacro{\ExportParameter}
+% \DescribeMacro{\ExportIf}
+% \begin{multicols}{2}\small
+% \setlength{\columnseprule}{.4pt}
+% \begin{quotation}\ttfamily\noindent
+% \bs openexport[\meta{extension}]\{\meta{file}\}\\
+% \bs Export\{\meta{counter}\}\\
+% \bs Export\{\meta{counter}\}\\
+% \qquad.\\
+% \qquad.\\
+% \qquad.\\
+% \bs ExportLength\{\meta{length}\}\\
+% \bs PreciseExportLength\{\meta{length}\}\\
+% \bs ExportMuskip\{\meta{muskip}\}\\
+% \bs ExportParameter\{\meta{parameter}\}\\
+% \bs ExportIf\{\meta{ifname}\}\\
+% \qquad.\\
+% \qquad.\\
+% \qquad.\\
+% \bs closeexport\\
+% \end{quotation}
+% \end{multicols}
+% \noindent
+% where \meta{file} is the file used to carry the data (its name will have
+% the \texttt{.xpt} extension by default, but you must not give it here;
+% an optionnal argument may be used to specify the extension), \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}|}| or
+% |\Import[|\meta{extension}|]{|\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.
+% David Carlisle has pointed out that using that macro with a
+% \emph{rubber} length as argument would lose the shrinking and
+% stretching parts and that |\ExportLength| does not make
+% any rounding error in fact. You can trust him! Always use
+% |\ExportLength| in case of doubt.
+%
+% |\ExportMuskip| is like |\ExportLength| but for a muskip
+% register. In fact, you could use |\ExportLength| for a
+% muskip register: the two commands are identical, except the
+% message written in the \texttt{.log} file. But you can not
+% use |\PreciseExportLength| with a muskip register: another
+% pretext to not use that superfluous command.
+%
+% |\ExportParameter| allows you to export parameters defined
+% by simple commands, like |\textfraction|. Do not try to export
+% complex things. It would nor work, at best, or crash, at worst.
+%
+% |\ExportIf| allows you to export the state of an ``if''
+% condition, i.e. the command |\ExportIf{foo}| will export the state of
+% |\iffoo|, just by writing |\foofalse| or |\footrue| in the
+% export file.
+% \emph{Note that the \meta{ifname} does not contains
+% the letters if at the beginning, nor the backslash.}
+%
+% \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.
+%
+% \DescribeMacro{\ExportArrayParams}
+% This macro export the dimensions and parameters related to the
+% layout of \texttt{array} and \texttt{tabular} environments.
+%
+% \subsection{An Example of Application}
+% This package is very useful when associated which the \pkg{dvipaste}
+% package\,\footnote{This package is now obsoleted by the nice
+% package \pkg{grfpaste} from David Carlisle, but the same remarks
+% still apply.}, 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.sty} package is now available from CTAN archives,
+% in the same directory than the \pkg{export} package. But you
+% should get from CTAN the whole directory containing
+% \pkg{dvipaste.tex} is. Get it (and the accompagning files),
+% and read the documentation of \pkg{dvipaste}:
+% you will also need the \pkg{dvipaste.c} program.
+% The \pkg{grfpaste} package is also available from CTAN
+% archives; it needs the \pkg{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 will 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 (via 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 counter used to number the
+% 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 usepackage\{xr\}\\
+% \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 trivial.
+%
+% \section{Acknowledgments}
+% I must thanks, once more, David Carlisle for his precious comments,
+% for the \pkg{grfpaste} package, and his great work on the \pkg{xr} package.
+%
+% \section{Problems}
+% \begin{itemize}
+% \item This package is certainly to be used with care; the user
+% must understand its mechanism.
+% \item I did not found a way to determine automatically the type
+% of a \LaTeX\ register. If it is not defined, you get an error.
+% But exporting a register with the wrong type (i.e. a rubber length
+% as a counter) may lead to confusion or loss of data.
+% \item The documentation is written in a very poor english. Do not
+% hesitate to send corrections.
+% \item Do not confuse this \pkg{export} package (and its \cs{Import}
+% command) with the \pkg{import} package (and its \cs{import} command)
+% from Donald Arseneau. The two packages have no relation except
+% similarity of names.
+% \end{itemize}
+%
+% \section{To Do}
+% \begin{itemize}
+% \item Other parameter sets could be exported the same way as the
+% page layout parameters. Ask if you have needs.
+% \item Export other kinds of parameters (strings, macros, etc.).
+% \item Improve the documentation.
+% \end{itemize}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% \StopEventually{\setcounter{IndexColumns}{2}\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}
+\newcommand{\openexport}[2][xpt]{%
+\PackageInfo{export}{\MessageBreak
+Exportations into #2.#1.\MessageBreak}%
+\immediate\openout\export #2.#1}
+% \end{macrocode}
+% The optionnal argument is the extension added to the name of the file.
+% Default: \texttt{xpt}. Using an other extension may be useful for
+% package writers needing more specific names.
+% \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}
+\newcommand{\closeexport}{\immediate\closeout\export%
+ \PackageInfo{export}{\MessageBreak
+ End of exportations.\MessageBreak}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ExportLength}
+% And now, the exporting commands. To export a length in points,
+% we just use |\the|\meta{length} 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}
+\newcommand{\ExportLength}[1]{%
+\PackageInfo{export}{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 could 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}
+\newcommand{\PreciseExportLength}[1]{%
+\PackageInfo{export}{Precise exportation of length #1}%
+\immediate\write\export{\string\setlength{\csname#1\endcsname}%
+ {\number\csname#1\endcsname sp}}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ExportMuskip}
+% To export a muskip in mu-s,
+% we just use |\the|\meta{length} and write it as an argument of
+% a |\setlength| command.
+% \begin{macrocode}
+\newcommand{\ExportMuskip}[1]{%
+\PackageInfo{export}{Exportation of muskip #1}%
+\immediate\write\export{\string\setlength{\csname#1\endcsname}%
+ {\the\csname#1\endcsname}}}
+% \end{macrocode}
+% Note that |\ExportLength| works well with muskips, but
+% |\PreciceExportLength| does nait and gives an error:
+% another reason to not use that superfluous command.
+% \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}
+\newcommand{\Export}[1]{%
+\PackageInfo{export}{Exportation of counter #1}%
+\immediate\write\export{\string\setcounter{#1}%
+ {\@arabic\csname c@#1\endcsname}}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ExportParameter}
+% Exporting a simple parameter is utterly complex: hence
+% contorsions with \cs{expandafter} and \cs{noexpand}.
+% The \cs{providecommand} should avoid errors.
+% \begin{macrocode}
+\newcommand{\ExportParameter}[1]{%
+\PackageInfo{export}{Exportation of parameter #1}%
+\immediate\write\export%
+ {\string\providecommand{\expandafter\noexpand\csname#1\endcsname}%
+ {}}
+\immediate\write\export%
+ {\string\renewcommand{\expandafter\noexpand\csname#1\endcsname}%
+ {\csname#1\endcsname}}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ExportIf}
+% Exporting an ``if'' condition is far from trivial.
+% We need to protect the contition name and to
+% avoid some expansions.
+% \begin{macrocode}
+\newcommand{\ExportIf}[1]{%
+\PackageInfo{export}{Exportation of the if condition ``#1''}
+\expandafter\csname if#1\endcsname
+\immediate\write\export{\expandafter\noexpand\csname #1true\endcsname}
+\else
+\immediate\write\export{\expandafter\noexpand\csname #1false\endcsname}
+\fi}
+% \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}
+\newcommand{\Import}[2][xpt]{%
+\PackageInfo{export}{\MessageBreak
+Importations from #2.#1\MessageBreak}%
+\InputIfFileExists{#2.#1}{\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}
+%
+% This macro write an |\@inputx| of the given file into the \texttt{.aux} file.
+% \begin{macro}{\AddInputInAux}
+% \begin{macrocode}
+\newcommand{\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!
+% It also exports some parameters and counters related to page layout
+% and float management.
+% Note that \cs{mathindent} is exported only if it is defined, i.e. when the
+% \texttt{fleqn} class option is used.
+% \begin{macrocode}
+\newcommand{\ExportPageLayout}{%
+\PackageInfo{export}{\MessageBreak
+Exportation of the PageLayout\MessageBreak}%
+\PreciseExportLength{hsize}
+\PreciseExportLength{vsize}
+\PreciseExportLength{hoffset}
+\PreciseExportLength{voffset}
+\PreciseExportLength{linewidth}
+\PreciseExportLength{columnwidth}
+\PreciseExportLength{columnsep}
+\PreciseExportLength{columnseprule}
+\PreciseExportLength{parindent}
+\ExportLength{parskip}
+\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}
+\PreciseExportLength{topmargin}
+\PreciseExportLength{topskip}
+\PreciseExportLength{jot}
+\@ifundefined{mathindent}{}{\PreciseExportLength{mathindent}}
+\ExportLength{abovedisplayskip}
+\ExportLength{belowdisplayskip}
+\ExportLength{abovedisplayshortskip}
+\ExportLength{belowdisplayshortskip}
+\ExportLength{floatsep}
+\ExportLength{textfloatsep}
+\ExportLength{dblfloatsep}
+\ExportLength{dbltextfloatsep}
+\ExportLength{intextsep}
+\Export{topnumber}
+\Export{dbltopnumber}
+\Export{bottomnumber}
+\Export{totalnumber}
+\PreciseExportLength{footnotesep}
+\ExportParameter{topfraction}
+\ExportParameter{bottomfraction}
+\ExportParameter{textfraction}
+\ExportParameter{floatpagefraction}
+\ExportParameter{dbltopfraction}
+\ExportParameter{dblfloatfraction}
+\ExportLength{baselineskip}
+\ExportLength{normalbaselineskip}
+\ExportParameter{baselinestretch}
+\PackageInfo{export}{\MessageBreak
+End of exportation of the PageLayout\MessageBreak}}%
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ExportArrayParams}
+% This macro is just a list of exportations of the lengths and
+% parameters defining the layout in \texttt{array} and
+% \texttt{tabular} environments.
+% \begin{macrocode}
+\newcommand{\ExportArrayParams}{%
+\PackageInfo{export}{\MessageBreak
+Exportation of the ArrayParams\MessageBreak}%
+\PreciseExportLength{arraycolsep}
+\PreciseExportLength{tabcolsep}
+\PreciseExportLength{arrayrulewidth}
+\PreciseExportLength{doublerulesep}
+\ExportParameter{arraystretch}
+\PackageInfo{export}{\MessageBreak
+End of exportation of the ArrayParams\MessageBreak}}%
+% \end{macrocode}
+% \end{macro}
+% \Finale
+% \end{document}
+\endinput