summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/grfpaste
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/grfpaste
Initial commit
Diffstat (limited to 'macros/latex/contrib/grfpaste')
-rw-r--r--macros/latex/contrib/grfpaste/doc/grfpaste.pdfbin0 -> 395204 bytes
-rw-r--r--macros/latex/contrib/grfpaste/doc/grfpaste.tex394
-rw-r--r--macros/latex/contrib/grfpaste/dvipaste.txt301
-rw-r--r--macros/latex/contrib/grfpaste/grfp1.tex14
-rw-r--r--macros/latex/contrib/grfpaste/grfp2.tex42
-rw-r--r--macros/latex/contrib/grfpaste/grfp3.tex23
-rw-r--r--macros/latex/contrib/grfpaste/grfpaste.sty238
7 files changed, 1012 insertions, 0 deletions
diff --git a/macros/latex/contrib/grfpaste/doc/grfpaste.pdf b/macros/latex/contrib/grfpaste/doc/grfpaste.pdf
new file mode 100644
index 0000000000..e02ad36768
--- /dev/null
+++ b/macros/latex/contrib/grfpaste/doc/grfpaste.pdf
Binary files differ
diff --git a/macros/latex/contrib/grfpaste/doc/grfpaste.tex b/macros/latex/contrib/grfpaste/doc/grfpaste.tex
new file mode 100644
index 0000000000..070ddb2b1d
--- /dev/null
+++ b/macros/latex/contrib/grfpaste/doc/grfpaste.tex
@@ -0,0 +1,394 @@
+\documentclass[numbers=noenddot, pagesize=auto]{scrartcl}
+
+\usepackage{fixltx2e}
+\usepackage{etex}
+\usepackage{etoolbox}
+\usepackage{xspace}
+\usepackage{lmodern}
+\usepackage[T1]{fontenc}
+\usepackage{textcomp}
+\usepackage[svgnames]{xcolor}
+\usepackage{listings}
+\usepackage{microtype}
+\usepackage[unicode=true]{hyperref}
+
+\newcommand*{\pkg}[1]{\textsf{#1}}
+\newcommand*{\cs}[1]{\texttt{\textbackslash#1}}
+\makeatletter
+\newcommand*{\cmd}[1]{\cs{\expandafter\@gobble\string#1}}
+\makeatother
+\newcommand*{\opt}[1]{\texttt{#1}}
+\newcommand*{\meta}[1]{\textlangle\textsl{#1}\textrangle}
+\newcommand*{\marg}[1]{\texttt{\{}\meta{#1}\texttt{\}}}
+
+\renewcommand*{\thesubsection}{\thesection\,\alph{subsection}}
+\renewcommand*{\theenumi}{\alph{enumi}}
+\renewcommand*{\labelenumi}{\theenumi)}
+\addtokomafont{title}{\rmfamily}
+
+% fix bug in listings package, see http://groups.google.de/group/comp.text.tex/browse_thread/thread/b004ec97fd72613a
+\makeatletter
+\preto\lstlisting{\global\@noskipsectrue}
+\makeatother
+
+\lstset{%
+ language=[LaTeX]TeX,%
+ columns=fullflexible,%
+ upquote=true,%
+ numbers=left,%
+ basicstyle=\small\ttfamily,%
+ keywordstyle=\color{Navy},%
+ commentstyle=\color{DimGray},%
+ stringstyle=\color{SeaGreen},%
+ numberstyle=\scriptsize\color{SlateGray}%
+}
+
+
+\title{The \pkg{grfpaste} package\thanks{This manual corresponds to \pkg{grfpaste}~v0.2, dated~1997/07/18.}}
+\subtitle{\LaTeX\ support for \TeX plorators / M. Spivak \texttt{dvipaste} program}
+\author{David Carlisle}
+\date{1997/07/18}
+
+
+\begin{document}
+
+\maketitle
+
+\tableofcontents
+
+\begin{quote}
+ \footnotesize
+ This package can redistributed and/or modified under the terms
+ of the \LaTeX\ Project Public License Distributed from CTAN
+ archives in directory \texttt{macros/latex/base/lppl.txt}; either
+ version~1 of the License, or (at your option) any later version.
+\end{quote}
+
+\noindent
+\texttt{Dvipaste} comes with a plain~\TeX\ based set of macros in a file
+\texttt{dvipaste.tex} that provide an interface to the \texttt{dvipaste} program. That
+file works perfectly well in \LaTeX\ with only minor modifications
+(specifically using \cmd{\@@line} instead of \cmd{\line}, and \cmd{\c@page} instead of
+\cmd{\pageno}). A \texttt{dvipaste.sty} constructed by just such modifications may be
+found distributed with Jean-Pierre Drucbert's `\pkg{export'} package on \textsc{ctan}.
+However I thought that it would be more in the `\LaTeX\ spirit'
+to provide an interface via the existing \LaTeX\ graphics package.
+
+The files produced by this \pkg{grfpaste} package should be fully compatible
+with \texttt{dvi\-paste.tex} or \texttt{dvipaste.sty}. That is, if \textsc{dvi} fragments are
+created using the plain~\TeX\ interface they may be included using
+\cmd{\includegraphics} via this package, and conversely if this package is
+used with the \opt{[write]} or \opt{[writepages]} options to produce a file of \textsc{dvi}
+fragments for including in another file, then the \textsc{dvi} file (and it's
+accompanying `\texttt{.dat}' file of size information) may be included either
+with this package, or via the original \texttt{dvipaste.tex} interface.
+
+Currently the \LaTeX\ interface uses the \pkg{graphicx} package, it would be
+possible to also provide an interface to the more basic \pkg{graphics}
+package, but that is not done here.
+
+The package is used in one of two forms.
+
+
+
+\section{Producing DVI Fragments}
+
+\subsection{Writing out boxes.}
+
+\begin{lstlisting}
+\documentclass{article}
+
+\usepackage[write]{grfpaste}
+
+\begin{document}
+
+\sendout{\parbox[b]{2cm}{one \sf two three \tt four \it five}}
+
+\sendout[abc]{hello}
+
+\sendout{\parbox[t]{2cm}{one \sf two three \tt four \it five}}
+
+\end{document}
+\end{lstlisting}
+%
+If the package is used with the \opt{[write]} option then the document should
+just consist of \cmd{\sendout} commands, the argument of each will be marked
+as a `fragment' that may be pasted into another DVI file by the \texttt{dvipaste}
+program. An auxiliary file with extension \texttt{.dat} will be created which
+contains the size of each of these fragments. Normally the fragments
+will be accessed by their number, starting from~1, but you may
+optionally supply a label, as in `\texttt{abc}' above which allows fragments to
+be referenced more easily. The above example forms the example
+document \texttt{grfp1.tex} in this distribution.
+
+
+\subsection{Writing out whole pages.}
+
+\begin{lstlisting}
+\documentclass{article}
+
+\usepackage[writepages]{grfpaste}
+
+\begin{document}
+...
+\end{document}
+\end{lstlisting}
+%
+If the package is used with the \opt{[writepages]} option then each
+indivdual page will be marked as a `fragment' for later processing by
+\texttt{dvipaste}. The fragments will be numbered consecutively, starting from~%
+1, whatever the value of the page counter. See the example document
+\texttt{grfp2.tex}.
+
+
+
+\section{Using DVI Fragments}
+
+\begin{lstlisting}
+\documentclass{article}
+
+\usepackage{grfpaste}
+
+\begin{document}
+
+aaa\fbox{\includegraphics
+ [num=1,natheight=19,natdepth=2pt,natwidth=57]{grfp1.dvi}}bbb
+
+xxx\fbox{\includegraphics[num=2]{grfp1.dvi}}yyy
+
+xxx\fbox{\includegraphics[ref=abc]{grfp1.dvi}}yyy
+
+Page 3 of grfp2.dvi:
+aaa\fbox{\includegraphics[num=3]{grfp2}}bbb
+
+\end{document}
+\end{lstlisting}
+%
+To use the fragments then load the package with no option (or
+equivalently with the \opt{[include]} option). You may also use any options
+understood by the \pkg{graphicx} package, these will be passed on to \pkg{graphicx}
+which is loaded by this package.
+
+To load the first fragment of a given \textsc{dvi} file you just need
+\cmd{\include\-graphics}\marg{file\-name} or \cmd{\include\-graphics}\texttt{\{}\meta{file\-name}\texttt{.dvi\}}
+(\texttt{.dvi} is added as one of the default extensions by this package)
+
+To access later fragments then you use the new \texttt{num=}\meta{??} key to specify
+the fragment number, as demonstrated above. If there are a lot of
+fragments maintaining the correct number may be inconvenient so you
+may instead use the \texttt{ref=} key to refer to a label previously supplied
+by the \cmd{\sendout} command. Note this label information is added to the
+\texttt{.dat} file in the form of a comment (after \texttt{\%}) and so the \texttt{.dat} file is
+still compatible with \texttt{dvipaste.tex}, but if that is used, then the
+numeric form must be used. Thus the two examples above with \texttt{num=2}
+and \texttt{ref=abc} include the same fragment from the file \texttt{grfp1.dvi}.
+
+Normally the size of the graphic is read from the `\texttt{.dat}' file which is
+the `read file' for the \textsc{dvi} graphic type, in the terminoligy of the
+\pkg{graphics} package documentation. If you have lost the \texttt{.dat} file, or
+wish to override it with altered sizes, you may specify the natural
+size using the \texttt{natheight}, \texttt{natwidth} and \texttt{natdepth} keys. As usual these
+take a dimension but the units may be omitted in which case \texttt{bp} are
+assumed. \texttt{natheight} and \texttt{natwidth} are standard \pkg{graphicx} keys, but
+\texttt{natdepth} is new, as these fragments are \TeX\ boxes, so have height and
+depth, unlike most other graphic formats that may be included, which
+always have zero depth.
+
+The \cmd{\sendout} command defined by the \opt{[write]} option matches that used
+in the plain~\TeX\ support, but the plain~\TeX\ version does not use
+\cmd{\includegraphics} to include the fragment. It defines a command \cmd{\paste}
+to achieve this. In order to help move documents between the two
+versions, a \opt{[defpaste]} option is provided for this package which
+specifies that a compatible \cmd{\paste} command should be defined. It is
+defined to be the equivalent call to \cmd{\includegraphics},
+\verb+\includegraphics[num=#2]{#1}+.
+
+See the example file \texttt{grfp3.tex} to see examples of including \textsc{dvi}
+fragments.
+
+
+
+\section{Putting it all together}
+
+\begin{enumerate}
+\item Produce one or more files of fragments using
+ \LaTeX\ and this package with the \opt{[write]} or \opt{[writepages]} options.
+ (or plain~\TeX\ using \texttt{dvipaste.tex}).
+
+\item \LaTeX\ your master document, including this package and using
+ \cmd{\includegraphics} to include the fragments at the appropriate points.
+
+ At this stage the file will have blank spaces (but if the correct
+ size) at the points where the \textsc{dvi} fragments should appear
+
+\item Run \texttt{dvipaste} on the master \textsc{dvi} file. It will incorporate the
+ fragments and re-write the file.
+
+\item Preview or print the modified \textsc{dvi} file in your usual manner.
+\end{enumerate}
+
+
+
+\section{Running the examples}
+
+\lstset{language=bash}
+
+\begin{itemize}
+\item \texttt{grfp1.tex} is an example of using the \opt{[write]} option
+\item \texttt{grfp2.tex} is an example of using the \opt{[writepages]} option
+\item \texttt{grfp3.tex} is an example of using the \opt{[include]} option
+\end{itemize}
+%
+To process the final document (\texttt{grfp3.dvi}) the following steps need be
+taken.
+%
+\begin{lstlisting}
+latex grfp1
+latex grfp2
+latex grfp2
+latex grfp3
+dvipaste grfp3
+\end{lstlisting}
+%
+Note that \texttt{grfp2} needs to be processed twice to generate a full table of
+contents. After \texttt{grfp3.tex} is processed by \LaTeX\ the \textsc{dvi} file will show
+blank spaces at the points that the fragments are to be included. These
+will be filled in by running \texttt{dvipaste}, after which the \texttt{grfp3.dvi} may be
+processed by your driver in the normal way.
+
+
+
+\section{Compiling \texttt{dvipaste.c}}
+
+\lstset{language=C}
+
+\begin{lstlisting}
+/* config.h for LINUX machines for dvipaste.c (DPC) */
+
+
+#define ANSI
+#undef MICROSOFTC
+#define LITTLENDIAN
+
+/* I guess this is what was meant. */
+/* (dvipaste.c defines strcmp to itself */
+/* leaving stricmp undefined) .*/
+#ifndef MICROSOFTC
+#define strnicmp strncmp
+#define stricmp strcmp
+#endif
+
+#ifdef ANSI
+/* Other things in ANSI C are good, but this is a crock */
+#define READ_BINARY "rb"
+#define WRITE_BINARY "wb"
+#else
+/* The good old simple and logical K&R I/O */
+#define READ_BINARY "r"
+#define WRITE_BINARY "w"
+#endif
+\end{lstlisting}
+%
+When I tried compiling \texttt{dvipaste.c} I got error due to the function
+\texttt{stricmp} being undefined. The file has a circular definition of \texttt{strcmp}
+to itself which looks like a typo, so I corrected that by making
+\texttt{stricmp} an alias for \texttt{strcmp} by altering \texttt{config.h} as above (which also
+sets \texttt{LITTLENDIAN} for Linux. It seems to work for me, but no promises.
+
+The above suggested \texttt{config.h} leaves \texttt{stricmp} meaning the same thing as
+\texttt{strcmp} (string comparison). Jean-Pierre Drucbert points out that
+\texttt{stricmp} is (on systems that it is defined) a case-insensitive
+comparison function, and that rather than the crude substitution above
+one may define it as follows.
+%
+\begin{quote}
+ \texttt{str\{n\}icmp} is not available on all systems. So I got the
+ following code in \texttt{ci.c}~:
+ %
+\begin{lstlisting}
+#include <ctype.h>
+#include "config.h"
+/*
+* str{n}icmp - case-insensitive flavors of strcmp(), strncmp()
+*/
+#ifdef PROTOS
+int stricmp(register char *s1,
+register char *s2)
+#else
+int stricmp(s1, s2)
+register char *s1, *s2;
+#endif
+{
+ register char c1, c2;
+
+ for ( ; (c1 = TOLOWER(*s1)) == (c2 = TOLOWER(*s2)); s1++, s2++)
+ if (c1 == '\0')
+ return 0;
+
+ return c1 - c2;
+}
+
+
+#ifdef PROTOS
+int strnicmp(register char *s1,
+register char *s2,
+int n)
+#else
+int strnicmp(s1, s2, n)
+register char *s1, *s2;
+int n;
+#endif
+{
+ register char c1, c2;
+
+ for ( ; --n >= 0 &&
+ (c1 = TOLOWER(*s1)) == (c2 = TOLOWER(*s2)); s1++, s2++)
+ if (c1 == '\0')
+ return 0;
+
+ return n < 0 ? 0 : c1 - c2;
+}
+\end{lstlisting}
+\end{quote}
+
+By default \texttt{dvipaste.c} has
+%
+\begin{lstlisting}
+#define STRINGSIZE (5124) /* maximum string size */
+\end{lstlisting}
+%
+Jean-Pierre Drucbert commented:
+%
+\begin{quote}
+ it is necessary to increase \texttt{STRINGSIZE} if you paste a lot of \textsc{dvi}
+ pieces (I~increased it from 40592 to 2597888)\@. In practice, do
+ not export more than~\textasciitilde 100 pieces from one file. You can import a
+ lot more into one file. So it is preferable to import from
+ several files if you have more than 100 pieces to import.
+\end{quote}
+
+\end{document}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/macros/latex/contrib/grfpaste/dvipaste.txt b/macros/latex/contrib/grfpaste/dvipaste.txt
new file mode 100644
index 0000000000..181573da95
--- /dev/null
+++ b/macros/latex/contrib/grfpaste/dvipaste.txt
@@ -0,0 +1,301 @@
+
+
+%%% The grfpaste package
+
+%%% LaTeX support for TeXplorators / M. Spivak dvipaste program
+%%% David Carlisle
+
+
+This package can redistributed and/or modified under the terms
+of the LaTeX Project Public License Distributed from CTAN
+archives in directory macros/latex/base/lppl.txt; either
+version 1 of the License, or (at your option) any later version.
+
+Dvipaste comes with a plain TeX based set of macros in a file
+dvipaste.tex that provide an interface to the dvipaste program. That
+file works perfectly well in LaTeX with only minor modifications
+(specifically using \@@line instead of \line, and \c@page instead of
+\pageno). A dvipaste.sty constructed by just such modifications may be
+found distributed with Jean-Pierre Drucbert's `export' package on ctan.
+However I thought that it would be more in the `LaTeX spirit'
+to provide an interface via the existing LaTeX graphics package.
+
+The files produced by this grfpaste package should be fully compatible
+with dvipaste.tex or dvipaste.sty. That is, if dvi fragments are
+created using the plain TeX interface they may be included using
+\includegraphics via this package, and conversely if this package is
+used with the [write] or [writepages] options to produce a file of dvi
+fragments for including in another file, then the dvi file (and it's
+accompanying `.dat' file of size information) may be included either
+with this package, or via the original dvipaste.tex interface.
+
+Currently the LaTeX interface uses the graphicx package, it would be
+possible to also provide an interface to the more basic graphics
+package, but that is not done here.
+
+The package is used in one of two forms.
+
+1 Producing DVI Fragments
+=========================
+
+1a Writing out boxes.
+===========================
+
+ \documentclass{article}
+
+ \usepackage[write]{grfpaste}
+
+ \begin{document}
+
+ \sendout{\parbox[b]{2cm}{one \sf two three \tt four \it five}}
+
+ \sendout[abc]{hello}
+
+ \sendout{\parbox[t]{2cm}{one \sf two three \tt four \it five}}
+
+ \end{document}
+
+
+If the package is used with the [write] option then the document should
+just consist of \sendout commands, the argument of each will be marked
+as a `fragment' that may be pasted into another DVI file by the dvipaste
+program. An auxiliary file with extension .dat will be created which
+contains the size of each of these fragments. Normally the fragments
+will be accessed by their number, starting from 1, but you may
+optionally supply a label, as in `abc' above which allows fragments to
+be referenced more easily. The above example forms the example
+document grfp1.tex in this distribution.
+
+1b Writing out whole pages.
+===========================
+
+ \documentclass{article}
+
+ \usepackage[writepages]{grfpaste}
+
+ \begin{document}
+ ...
+ \end{document}
+
+
+If the package is used with the [writepages] option then each
+indivdual page will be marked as a `fragment' for later processing by
+dvipaste. The fragments will be numbered consecutively, starting from
+1, whatever the value of the page counter. See the example document
+grfp2.tex.
+
+
+
+
+2 Using DVI Fragments
+=========================
+
+
+ \documentclass{article}
+
+ \usepackage{grfpaste}
+
+ \begin{document}
+
+ aaa\fbox{\includegraphics
+ [num=1,natheight=19,natdepth=2pt,natwidth=57]{grfp1.dvi}}bbb
+
+ xxx\fbox{\includegraphics[num=2]{grfp1.dvi}}yyy
+
+ xxx\fbox{\includegraphics[ref=abc]{grfp1.dvi}}yyy
+
+ Page 3 of grfp2.dvi:
+ aaa\fbox{\includegraphics[num=3]{grfp2}}bbb
+
+ \end{document}
+
+To use the fragments then load the package with no option (or
+equivalently with the [include] option). You may also use any options
+understood by the graphicx package, these will be passed on to graphicx
+which is loaded by this package.
+
+To load the first fragment of a given dvi file you just need
+ \includegraphics{filename} or \includegraphics{filename.dvi}
+(.dvi is added as one of the default extensions by this package)
+
+To access later fragments then you use the new num=?? key to specify
+the fragment number, as demonstrated above. If there are a lot of
+fragments maintaining the correct number may be inconvenient so you
+may instead use the ref= key to refer to a label previously supplied
+by the \sendout command. Note this label information is added to the
+.dat file in the form of a comment(after %) and so the .dat file is
+still compatible with dvipaste.tex, but if that is used, then the
+numeric form must be used. Thus the two examples above with num=2
+and ref=abc include the same fragment from the file grfp1.dvi.
+
+
+Normally the size of the graphic is read from the `.dat' file which is
+the `read file' for the dvi graphic type, in the terminoligy of the
+graphics package documentation. If you have lost the .dat file, or
+wish to override it with altered sizes, you may specify the natural
+size using the natheight, natwidth and natdepth keys. As usual these
+take a dimension but the units may be omitted in which case bp are
+assumed. natheight and natwidth are standard graphicx keys, but
+natdepth is new, as these fragments are TeX boxes, so have height and
+depth, unlike most other graphic formats that may be included, which
+always have zero depth.
+
+The \sendout command defined by the [write] option matches that used
+in the plain TeX support, but the plain TeX version does not use
+\includegraphics to include the fragment. It defines a command \paste
+to achieve this. In order to help move documents between the two
+versions, a [defpaste] option is provided for this package which
+specifies that a compatible \paste command should be defined. It is
+defined to be the equivalent call to \includegraphics,
+\includegraphics[num=#2]{#1}.
+
+See the example file grfp3.tex to see examples of including dvi
+fragments.
+
+
+3 Putting it all together
+=========================
+
+a) Produce one or more files of fragments using
+ LaTeX and this package with the [write] or [writepages] options.
+ (or plain TeX using dvipaste.tex).
+
+b) LaTeX your master document, including this package and using
+ \includegraphics to include the fragments at the appropriate points.
+
+ At this stage the file will have blank spaces (but if the correct
+ size) at the points where the dvi fragments should appear
+
+c) Run dvipaste on the master dvi file. It will incorporate the
+ fragments and re-write the file.
+
+d) Preview or print the modified dvi file in your usual manner.
+
+
+4 Running the examples
+=========================
+
+grfp1.tex is an example of using the [write] option
+grfp2.tex is an example of using the [writepages] option
+grfp3.tex is an example of using the [include] option
+
+To process the final document (grfp3.dvi) the following steps need be
+taken.
+
+latex grfp1
+latex grfp2
+latex grfp2
+latex grfp3
+dvipaste grfp3
+
+Note that grfp2 needs to be processed twice to generate a full table of
+contents. After grfp3.tex is processed by LaTeX the dvi file will show
+blank spaces at the points that the fragments are to be included. These
+will be filled in by running dvipaste, after which the grfp3.dvi may be
+processed by your driver in the normal way.
+
+
+5 Compiling dvipaste.c
+======================
+
+ /* config.h for LINUX machines for dvipaste.c (DPC) */
+
+
+ #define ANSI
+ #undef MICROSOFTC
+ #define LITTLENDIAN
+
+ /* I guess this is what was meant. */
+ /* (dvipaste.c defines strcmp to itself */
+ /* leaving stricmp undefined) .*/
+ #ifndef MICROSOFTC
+ #define strnicmp strncmp
+ #define stricmp strcmp
+ #endif
+
+ #ifdef ANSI
+ /* Other things in ANSI C are good, but this is a crock */
+ #define READ_BINARY "rb"
+ #define WRITE_BINARY "wb"
+ #else
+ /* The good old simple and logical K&R I/O */
+ #define READ_BINARY "r"
+ #define WRITE_BINARY "w"
+ #endif
+
+
+When I tried compiling dvipaste.c I got error due to the function
+stricmp being undefined. The file has a circular definition of strcmp
+to itself which looks like a typo, so I corrected that by making
+stricmp an alias for strcmp by altering config.h as above (which also
+sets LITTLENDIAN for Linux. It seems to work for me, but no promises.
+
+The above suggested config.h leaves stricmp meaning the same thing as
+strcmp (string comparison). Jean-Pierre Drucbert points out that
+stricmp is (on systems that it is defined) a case-insensitive
+comparison function, and that rather than the crude substitution above
+one may define it as follows.
+
+ str{n}icmp is not available on all systems. So I got the
+ following code in ci.c :
+
+ #include <ctype.h>
+ #include "config.h"
+ /*
+ * str{n}icmp - case-insensitive flavors of strcmp(), strncmp()
+ */
+ #ifdef PROTOS
+ int stricmp(register char *s1,
+ register char *s2)
+ #else
+ int stricmp(s1, s2)
+ register char *s1, *s2;
+ #endif
+ {
+ register char c1, c2;
+
+ for ( ; (c1 = TOLOWER(*s1)) == (c2 = TOLOWER(*s2)); s1++, s2++)
+ if (c1 == '\0')
+ return 0;
+
+ return c1 - c2;
+ }
+
+
+ #ifdef PROTOS
+ int strnicmp(register char *s1,
+ register char *s2,
+ int n)
+ #else
+ int strnicmp(s1, s2, n)
+ register char *s1, *s2;
+ int n;
+ #endif
+ {
+ register char c1, c2;
+
+ for ( ; --n >= 0 &&
+ (c1 = TOLOWER(*s1)) == (c2 = TOLOWER(*s2)); s1++, s2++)
+ if (c1 == '\0')
+ return 0;
+
+ return n < 0 ? 0 : c1 - c2;
+ }
+
+
+
+
+
+By default dvipaste.c has
+#define STRINGSIZE (5124) /* maximum string size */
+
+Jean-Pierre Drucbert commented:
+
+ it is necessary to increase STRINGSIZE if you paste a lot of dvi
+ pieces (I increased it from 40592 to 2597888). In practice, do
+ not export more than ~100 pieces from one file. You can import a
+ lot more into one file. So it is preferable to import from
+ several files if you have more than 100 pieces to import.
+
+
+
diff --git a/macros/latex/contrib/grfpaste/grfp1.tex b/macros/latex/contrib/grfpaste/grfp1.tex
new file mode 100644
index 0000000000..43ea5e4692
--- /dev/null
+++ b/macros/latex/contrib/grfpaste/grfp1.tex
@@ -0,0 +1,14 @@
+\documentclass{article}
+
+\usepackage[write]{grfpaste}
+
+\begin{document}
+
+\sendout{\parbox[b]{2cm}{one \sf two three \tt four \it five}}
+
+\sendout[abc]{hello}
+
+\sendout{\parbox[t]{2cm}{one \sf two three \tt four \it five}}
+
+\end{document}
+
diff --git a/macros/latex/contrib/grfpaste/grfp2.tex b/macros/latex/contrib/grfpaste/grfp2.tex
new file mode 100644
index 0000000000..4ccc866cba
--- /dev/null
+++ b/macros/latex/contrib/grfpaste/grfp2.tex
@@ -0,0 +1,42 @@
+\documentclass{article}
+
+\setlength\textheight{5cm}
+\setlength\textwidth{5cm}
+\setlength\oddsidemargin{0cm}
+
+\usepackage[writepages]{grfpaste}
+
+\pagestyle{headings}
+
+\def\xa{aa bb cc dd ee }
+\def\xb{\xa\xa\xa\xa\xa\xa\par\xa\xa\xa}
+\begin{document}
+
+\tableofcontents
+
+\section{Intro}
+\xb
+
+\section{More}
+\xb
+
+\begin{table}
+ \begin{tabular}{|ll|}
+aaa&bbb\\
+aaa&bbb\\
+aaa&bbb\\
+ \end{tabular}
+ \caption{test one}
+\end{table}
+\begin{table}
+ \begin{tabular}{|ll|}
+1&2\\
+3&4\\
+5&6\\
+ \end{tabular}
+ \caption{test two}
+\end{table}
+
+\section{Yet more}
+\xb\xb
+\end{document}
diff --git a/macros/latex/contrib/grfpaste/grfp3.tex b/macros/latex/contrib/grfpaste/grfp3.tex
new file mode 100644
index 0000000000..64f82b9e5a
--- /dev/null
+++ b/macros/latex/contrib/grfpaste/grfp3.tex
@@ -0,0 +1,23 @@
+\documentclass{article}
+
+\usepackage{grfpaste}
+\setlength\lineskip{12pt}
+\addtolength\textheight{1in}
+
+\begin{document}
+
+
+First two fragments from \texttt{grfp1.dvi}
+\begin{center}
+ Paste fragment `abc': \fbox{\includegraphics[ref=abc]{grfp1}}\\
+ Paste fragment `1': \fbox{\includegraphics[num=1]{grfp1}}
+\end{center}
+and now four pages lifted from \texttt{grfp2.dvi}
+\begin{center}
+\fbox{\includegraphics[num=1]{grfp2}}
+\fbox{\includegraphics[num=2]{grfp2}}
+\fbox{\includegraphics[num=3]{grfp2}}
+\fbox{\includegraphics[num=4]{grfp2}}
+\end{center}
+
+\end{document}
diff --git a/macros/latex/contrib/grfpaste/grfpaste.sty b/macros/latex/contrib/grfpaste/grfpaste.sty
new file mode 100644
index 0000000000..76a116b3e6
--- /dev/null
+++ b/macros/latex/contrib/grfpaste/grfpaste.sty
@@ -0,0 +1,238 @@
+
+
+%%% LaTeX support for TeXplorators / M. Spivak dvipaste program
+%%% Copyright 1997 David Carlisle
+
+
+% This program can redistributed and/or modified under the terms
+% of the LaTeX Project Public License Distributed from CTAN
+% archives in directory macros/latex/base/lppl.txt; either
+% version 1 of the License, or (at your option) any later version.
+
+%%% Usage notes in the file dvipaste.txt
+
+
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{grfpaste}
+ [1997/07/18 v0.2 dvipaste LaTeX graphics style (DPC)]
+
+% 1997/07/17 v0.1
+% 1997/07/18 v0.2 add ref system.
+
+% To include previously prepared dvi fragments, use
+% \usepackage{grfpaste}
+% and include the graphics with \includegraphics{file.dvi}
+% or \includegraphics[num=5]{file.dvi}
+%
+% To make a file that produces suitable fragments, use
+% \usepackage[write]{grfpaste}
+% and mark each fragment with \sendout{....}
+%
+\DeclareOption{write}{\let\sendout\relax}
+\DeclareOption{writepages}{\let\sendout\relax\let\GP@sendout\@empty}
+\DeclareOption{include}{%
+ \def\sendout#1{\PackageError{grfpaste}{Use write option}{}}}
+\DeclareOption{defpaste}{\def\paste#1#2{\includegraphics[num=#2]{#1}}}
+\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{graphicx}}
+\ExecuteOptions{include}
+\ProcessOptions
+\RequirePackage{graphicx}
+
+\ifx\sendout\relax
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Marking DVI Sections For Inclusion In Other Files
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% Size information will be written in to a file filename.dat
+% which is opened now and closed at the end of the run.
+
+\newwrite\writedata@
+\immediate\openout\writedata@=\jobname.dat
+%\AtEndDocument{\immediate\closeout\writedata@}
+
+% The format of the .dat file is identical to that written by
+% dvipaste.tex, the format of the dvi file is compatible.
+% dvipaste uses a more complicated scheme that uses a custom output
+% routine and then \eject each section, however I can't see why
+% \sendout can not just \shipout the box directly, so that is what
+% this version does.
+
+\def\sendout{\@testopt\GP@sendout{}}
+
+\ifx\GP@sendout\@empty
+
+\def\GP@sendout[#1]#2{\PackageError{grfpaste}{write pages
+ only}{}}
+
+\let\GP@shipout\shipout
+\def\shipout{\global\setbox\xxx}
+\newbox\xxx
+\let\GP@outputpage\@outputpage
+\def\@outputpage{%
+ \GP@outputpage
+ \immediate\write\writedata@
+ {\the\ht\xxx\space\the\dp\xxx\space\the\wd\xxx}%
+ {\let\protect\noexpand
+ \advance\c@page\m@ne
+ \GP@shipout\hbox{%
+ \special{beginpaste:}%
+ \wd\xxx\z@
+ \box\xxx
+ \special{endpaste:}%
+ }%
+ }}
+
+\else
+
+\long\def\GP@sendout[#1]#2{%
+ \sbox\z@{#2}%
+ \immediate\write\writedata@
+ {\the\ht\z@\space\the\dp\z@\space\the\wd\z@
+ \ifx\box#1\box\else\space\@percentchar#1\fi}%
+ \shipout\vbox{%
+ \vskip\ht\z@
+ \special{beginpaste:}%
+ \ht\z@\z@\dp\z@\z@\wd\z@\z@
+ \noindent\box\z@
+ \special{endpaste:}%
+% the original had this rule, but seems not to be needed.
+% \smash{\vrule \@height1sp\@width1sp\@depth\z@}%
+ \@@par
+ \vskip2pc%
+ \hbox{\normalfont File [\jobname], \#\number\c@page}}%
+ \stepcounter{page}}
+
+\fi
+
+\else
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Including DVI Sections Into The Current File
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% Graphics will be able to include dvi file segments, reading size
+% info from .dat files (compatible with dvipast.tex for plain tex)
+
+\DeclareGraphicsRule{.dvi}{dvi}{.dat}{}
+
+% Add .dvi to the default list of extensions.
+
+\g@addto@macro\Gin@extensions{,.dvi}
+
+
+% dvipaste allows multiple dvi fragments to be included from the
+% same file. Add a new key num= (defaulting to 1) which says
+% which bit to include. Maintaining numbers if you have a lot of
+% fragments is inconvenient so may use symbolic references
+% instead of number.
+% ref=xxx refers to a fragment marked with the label xxx by use
+% of an optional argument \sendout[xxx]{......} to \sendout.
+% If \sendout is used with such an optional argument
+% the fragment may be included either by number or by label.
+% (The numeric form must be used if the fragment is included using
+% dvipaste.tex's \paste command.)
+
+
+\define@key{Gin}{num}{\def\Gin@num{#1}}
+\define@key{Gin}{ref}{\def\Gin@ref{#1 }}
+\setkeys{Gin}{num=1,ref=}
+
+% Unlike other graphics formats, which only have natural height and
+% width, dvipaste fragments are TeX boxes, with depth as well.
+% add a new key to set the depth (for cases where you don't want to
+% use a .dat file).
+
+\define@key{Gin}{natdepth}{%
+ \Gin@defaultbp\@tempaa{#1}%
+ \Gin@nat@depth\@tempaa bp\relax}
+
+% Ah. Don't look too carefully. The internal command \Gin@setfile
+% in the kernel of the graphics package was not expecting this, and
+% explicitly sets the depth of the graphic box to zero, so patch that
+% to make it set it to the new \Gin@req@depth macro.
+%
+% pulls apart the macro at \dp\z@\z@ and then puts it all back together
+% again.
+
+\def\@tempa#1\dp\z@\z@#2!{%
+ \def\Gin@setfile##1##2##3{%
+ #1%
+ \dp\z@\Gin@req@depth
+ #2}}
+\expandafter\@tempa\Gin@setfile{#1}{#2}{#3}!
+
+% Scaling is not currently supported, so natural depth and
+% required depth are the same.
+
+\def\Gin@req@depth{\Gin@nat@depth}
+
+\newdimen\Gin@nat@depth
+
+
+% For each new file type the graphics package needs two functions.
+% \Gread@<type> defines how to read the size information.
+% \Ginclude@type defines how to set the actual box and specials.
+% These functions are pretty similar to the code in dvipaste.tex
+
+% as in the dvipaste.tex version, the size information for
+% all the fragments in a single dvi file is saved in a macro
+% so the file only needs to be read once.
+
+\def\Gread@dvi#1{%
+ \expandafter\let\expandafter\@tempb\csname Gread@#1\endcsname
+ \ifx\@tempb\relax
+ \let\@tempb\@empty
+ \let\do\relax
+ \immediate\openin\@inputcheck#1 %
+ \catcode`\%9\relax
+ \ifeof\@inputcheck
+ \@latex@error{File `#1' not found}\@ehc
+ \else
+ \Gread@true
+ \loop
+ \read\@inputcheck to\@tempa
+ \ifeof\@inputcheck
+ \Gread@false
+ \else
+ \xdef\@tempb{\@tempb\do\@tempa\relax}%
+ \fi
+ \ifGread@
+ \repeat
+ \immediate\closein\@inputcheck
+ \fi
+ \global\expandafter\let\csname Gread@#1\endcsname\@tempb
+ \fi
+%
+% Temporarily set \do to count up to the required fragment number
+% and then grab the size info. Then execute the list (in \@tempb).
+ \count@\z@
+ \Gread@false
+ \def\do##1 ##2 ##3 ##4\relax{%
+ \advance\count@\@ne
+ \def\@tempa{##4}%
+ \ifx\@tempa\Gin@ref
+ \edef\Gin@num{\the\count@}%
+ \fi
+ \ifnum\Gin@num=\count@
+ \Gread@true
+ \def\Gin@llx{0}%
+ \let\Gin@lly\Gin@llx
+ \Gin@defaultbp\Gin@urx{##3}%
+ \Gin@defaultbp\Gin@ury{##1}%
+ \Gin@nat@depth##2\relax
+ \fi}%
+ \@tempb
+ \let\do\noexpand}
+
+\def\Ginclude@dvi#1{%
+ \ifGread@
+ \dimen@\Gin@nat@height
+ \advance\dimen@\Gin@nat@depth
+ \hbox{\special{dvipaste: \Gin@base\space\Gin@num}%
+ \lower\Gin@nat@depth\vbox to\dimen@{\hbox to\Gin@nat@width{}\vfil}}%
+ \else
+ \Gin@nosize{\Gin@base[\Gin@num]}%
+ \fi}
+
+
+\fi
+