From 91cb42bff9c7b199df5a79da4622ed072385d2f3 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Tue, 8 Mar 2011 00:13:24 +0000 Subject: gincltex (7mar11) git-svn-id: svn://tug.org/texlive/trunk@21635 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/source/latex/gincltex/Makefile | 77 ++++ Master/texmf-dist/source/latex/gincltex/README | 16 + .../texmf-dist/source/latex/gincltex/gincltex.dtx | 395 +++++++++++++++++++++ .../texmf-dist/source/latex/gincltex/gincltex.ins | 49 +++ 4 files changed, 537 insertions(+) create mode 100644 Master/texmf-dist/source/latex/gincltex/Makefile create mode 100644 Master/texmf-dist/source/latex/gincltex/README create mode 100644 Master/texmf-dist/source/latex/gincltex/gincltex.dtx create mode 100644 Master/texmf-dist/source/latex/gincltex/gincltex.ins (limited to 'Master/texmf-dist/source/latex') diff --git a/Master/texmf-dist/source/latex/gincltex/Makefile b/Master/texmf-dist/source/latex/gincltex/Makefile new file mode 100644 index 00000000000..ea45bae4ef4 --- /dev/null +++ b/Master/texmf-dist/source/latex/gincltex/Makefile @@ -0,0 +1,77 @@ +TEXMF=${HOME}/texmf +INSTALLDIR=${TEXMF}/tex/latex/gincltex +DOCINSTALLDIR=${TEXMF}/doc/latex/gincltex +CP=cp +RMDIR=rm -rf +PDFLATEX=pdflatex -interaction=batchmode +LATEXMK=latexmk -pdf -silent + +PACKEDFILES=gincltex.sty +DOCFILES=gincltex.pdf +SRCFILES=gincltex.dtx gincltex.ins README Makefile + +all: unpack doc + +package: unpack +class: unpack + +${PACKEDFILES}: gincltex.dtx gincltex.ins + yes | pdflatex gincltex.ins + +unpack: ${PACKEDFILES} + +# 'doc' and 'gincltex.pdf' call itself until everything is stable +doc: gincltex.pdf + @${MAKE} --no-print-directory gincltex.pdf + +pdfopt: doc + @-pdfopt gincltex.pdf .temp.pdf && mv .temp.pdf gincltex.pdf + +%.pdf: %.dtx + ${PDFLATEX} $< + -makeindex -s gind.ist -o "$@" "$<" + -makeindex -s gglo.ist -o "$@" "$<" + ${PDFLATEX} $< + ${PDFLATEX} $< + + +clean: + -latexmk -C gincltex.dtx + ${RM} ${PACKEDFILES} *.zip *.log *.aux *.toc *.vrb *.nav *.pdf *.snm *.out *.fdb_latexmk *.glo *.gls *.hd *.sta *.stp + ${RMDIR} tds + +install: unpack doc ${INSTALLDIR} ${DOCINSTALLDIR} + ${CP} ${PACKEDFILES} ${INSTALLDIR} + ${CP} ${DOCFILES} ${DOCINSTALLDIR} + texhash ${TEXMF} + +${INSTALLDIR}: + mkdir -p $@ + +${DOCINSTALLDIR}: + mkdir -p $@ + +ctanify: ${SRCFILES} ${DOCFILES} gincltex.tds.zip + ${RM} gincltex.zip + zip gincltex.zip $^ + unzip -t gincltex.zip + unzip -t gincltex.tds.zip + +zip: gincltex.zip + +tdszip: gincltex.tds.zip + +gincltex.zip: ${SRCFILES} ${DOCFILES} | pdfopt + ${RM} $@ + zip $@ $^ + +gincltex.tds.zip: ${SRCFILES} ${PACKEDFILES} ${DOCFILES} | pdfopt + ${RMDIR} tds + mkdir -p tds/tex/latex/gincltex + mkdir -p tds/doc/latex/gincltex + mkdir -p tds/source/latex/gincltex + ${CP} ${DOCFILES} tds/doc/latex/gincltex + ${CP} ${PACKEDFILES} tds/tex/latex/gincltex + ${CP} ${SRCFILES} tds/source/latex/gincltex + cd tds; zip -r ../$@ . + diff --git a/Master/texmf-dist/source/latex/gincltex/README b/Master/texmf-dist/source/latex/gincltex/README new file mode 100644 index 00000000000..d773575771c --- /dev/null +++ b/Master/texmf-dist/source/latex/gincltex/README @@ -0,0 +1,16 @@ +The gincltex Package +Copyright (C) 2011 -- Martin Scharrer + +Version v0.1 -- 2011/03/06 + +This small package builds on the standard LaTeX packages graphic +and/or graphicx and allows external LaTeX source files to be included like +graphic files, i.e. adds support for the `.tex' extension. + + \includegraphics[]{somefile.tex} + +Some of the lower level operations like clipping and trimming are implemented +using the pgf package which supports both DVI/PS and PDF output. This package +uses a very similar technique than the author's other package adjustbox, but +provides a different interface. + diff --git a/Master/texmf-dist/source/latex/gincltex/gincltex.dtx b/Master/texmf-dist/source/latex/gincltex/gincltex.dtx new file mode 100644 index 00000000000..151d8101e9a --- /dev/null +++ b/Master/texmf-dist/source/latex/gincltex/gincltex.dtx @@ -0,0 +1,395 @@ +% \iffalse meta-comment +% +% Copyright (C) 2009 by Martin Scharrer +% ----------------------------------------------------------------- +% +% This work may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3c +% 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.3c or later is part of all distributions of LaTeX +% version 2008/05/04 or later. +% +% This work has the LPPL maintenance status `maintained'. +% +% The Current Maintainer of this work is Martin Scharrer. +% +% This work consists of the files gincltex.dtx, gincltex.ins +% and the derived file gincltex.sty. +% +% $Id: skeleton.dtx 1057 2009-05-04 11:11:37Z martin $ +% \fi +% +% \iffalse +\RequirePackage{svn-prov} +%\ProvidesPackage{gincltex} +%<*driver> +\ProvidesFile{gincltex.dtx} +% + [2011/03/06 v0.1 Include external LaTeX files like graphics] +%<*driver> +\documentclass{ltxdoc} +\usepackage{gincltex} +\usepackage{hyperref} +\let\pkg\texttt +\EnableCrossrefs +%\CodelineIndex +\RecordChanges +%\OnlyDescription +\begin{document} + \DocInput{\jobname.dtx} + \PrintChanges + %\newpage\PrintIndex +\end{document} +% +% \fi +% +% \CheckSum{233} +% +% \CharacterTable +% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z +% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z +% Digits \0\1\2\3\4\5\6\7\8\9 +% Exclamation \! Double quote \" Hash (number) \# +% Dollar \$ Percent \% Ampersand \& +% Acute accent \' Left paren \( Right paren \) +% Asterisk \* Plus \+ Comma \, +% Minus \- Point \. Solidus \/ +% Colon \: Semicolon \; Less than \< +% Equals \= Greater than \> Question mark \? +% Commercial at \@ Left bracket \[ Backslash \\ +% Right bracket \] Circumflex \^ Underscore \_ +% Grave accent \` Left brace \{ Vertical bar \| +% Right brace \} Tilde \~} +% +% +% \changes{v0.1}{2011/01/23}{Packaged code} +% \changes{v0.1}{2011/03/06}{First release} +% +% \GetFileInfo{\jobname.dtx} +% +% \DoNotIndex{\newcommand,\newenvironment,\def,\edef,\xdef,\let} +% +% \ifpdf +% \hypersetup{% +% pdfauthor = {Martin Scharrer }, +% pdftitle = {The gincltex package}, +% pdfsubject = {Documentation of LaTeX package gincltex}, +% pdfkeywords = {gincltex, include, graphic, source code, LaTeX, TeX} +% }% +% \fi +% \clearpage +% \null +% \vspace*{-2em} +% \begin{center} +% {\LARGE\sffamily The \emph{gincltex} Package\\[\medskipamount]} +% {\large Martin Scharrer \\[\medskipamount]\normalsize +% \url{martin@scharrer-online.de}\\[.8ex] +% \url{http://www.ctan.org/pkg/gincltex/}\\[\bigskipamount]} +% {\large Version \fileversion\ -- \filedate}\\ +% \end{center} +% \vspace{1.2em}% +% +% \begin{abstract} +% This small package builds on the standard \LaTeX{} packages \pkg{graphic} and/or \pkg{graphicx} +% and allows external \LaTeX{} source files to be included like graphic files, i.e. adds support for the `|.tex|' +% extension. +% Some of the lower level operations like clipping and trimming are implemented using the \pkg{pgf} package which supports +% both DVI/PS and PDF output. +% This package uses a very similar technique than the author's other package \pkg{adjustbox}, but provides a different +% interface. +% \\[\medskipamount] +% \textbf{Please note} that this package is new and the implementation might change in future revisions. +% This might cause minor rounding differences in the exact size of the resulting \TeX{} box around the included files. +% \end{abstract} +% +% \section{Introduction} +% This small package builds on the standard \LaTeX{} packages |graphic| and |graphicx| +% and allows external \LaTeX{} source files to be included like graphic files: +% \begin{quote} +% |\includegraphics[]{somefile.tex}| +% \end{quote} +% +% A \LaTeX{} file included this way should result in an identical display as a tightly cropped EPS or PDF image +% of the same file (apart smaller rounding differences). +% Usually such files hold a picture environment like +% |picture|, |pspicture|, |pgfpicture| or |tikzpicture|, which may take advantage +% from the |standalone| class. +% In fact \pkg{gincltex} is used in newer versions of \pkg{standalone} to seamlessly switch between source and image files. +% +% All options of |\includegraphics| described in the manual of |graphic|/|graphicx| (the |grfguide|) +% should be supported. Therefore it is possible to resize, rotate and clip the content +% of the \LaTeX{} source file in the same way as for images. +% +% +% An alternative is the \pkg{adjustbox} package from the same author which allows the same options +% as for |\includegraphics| for arbitrary TeX material: +% \begin{quote} +% |\adjustbox{}{\input{somefile}}| +% \end{quote} +% +% \section{Usage} +% After loading the package the |.tex| extension is supported by |\includegraphics| +% and the macro can be used in its normal form for \LaTeX{} files. +% The content of the file is typeset first inside an |\hbox| (the primitive version of |\mbox|) +% and then modified according to the given macro options. +% Either the \pkg{graphic} or \pkg{graphicx} package must also be loaded by the user. +% This package doe +% +% \subsection{Draft support} +% The package supports the |draft| option of |graphics| which only displays an empty box +% with the file name for all included graphics. +% In this mode the source file should not be processed to reduce compile time. +% However the size of the resulting box from the source file must be know in order +% to reserve the required space. Therefore the \emph{bounding box} information is +% cached for future runs with active |draft| option. The location where the information +% is cached can be controlled with the |bb| option. +% +% \subsection{Package options} +% The place where the bounding box information is cached can be adjusted with the +% |bb| option. By default |bb=aux| is active which stores the bounding box information +% in the |.aux| file. With |bb=file| this information is written in EPS format into +% |.tex.bb| files, e.g. for each source file |name.tex| a file |name.tex.bb| is created. +% +% +% \StopEventually{} +% \iffalse +%<*package> +% \fi +% \section{Implementation} +% \subsection{Package Option} +% At the moment the key=value format is simply hard coded. +% \begin{macrocode} +\newif\if@gincltex@bbfile +\DeclareOption{bb=file}{\@gincltex@bbfiletrue} +\DeclareOption{bb=aux}{\@gincltex@bbfilefalse} +\ProcessOptions*\relax +% \end{macrocode} +% +% \subsection{Requirements} +% The \pkg{graphics} package is required. The \pkg{graphicx} package is also supported and can +% be loaded beforehand or afterwards. +% +% The \pkg{pgf} package is required for the "graphic" manipulations. +% It actually loads \pkg{graphicx} internally. +% \begin{macrocode} +\RequirePackage{graphics} +\RequirePackage{pgf} +% \end{macrocode} +% +% \subsection{Graphics Rule Macros} +% The following macro implement a \emph{graphics rule} for \LaTeX{} source code files. +% +% \begin{macro}{\Gin@rule@.tex} +% This macro declares the graphics rule to the |graphics|/|x| package. +% \begin{macrocode} +\DeclareGraphicsRule{.tex}{tex}{.tex}{} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\gincltex@box} +% A savebox required to transfer material from the `read' macro to the `include' macro. +% Note that |\@tempboxa| is not used here because it might be used otherwise between the +% two macros. +% \begin{macrocode} +\newsavebox\gincltex@box +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\gincltex@input} +% Macro to input the \LaTeX{} source file. +% Because |\includegraphics| can be used inside this file certain internal |graphics| macros +% must be reset to there default value. +% \begin{macrocode} +\def\gincltex@input#1{% + {\let\Gin@ext\relax\input{#1}}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\Ginclude@tex} +% This driver macro is called from the standard |\includegraphics| macro to include the \LaTeX{} source file. +% Some |\includegraphics| options like |angle| are handled by wrapping this macro in the appropriate +% |graphics| macro like |\rotatebox|, but others must be handled here. +% \begin{macrocode} +\def\Ginclude@tex#1{% + \begingroup +% \end{macrocode} +% The content of the source file might have been already saved into the |\gincltex@box| by the |\Gread@tex| macro. +% If not it is saved here. +% \begin{macrocode} + \ifvoid\gincltex@box + \sbox\gincltex@box{{\gincltex@input{#1}}}% + \fi +% \end{macrocode} +% The bounding box points (lower left, upper right) are calculated. It is assumed that the `graphic' baseline starts at the +% lower left point, so |llx=0|. The depth should be |0| as well but to be on the save side it is calculated here. +% The upper right point is given by the box width and height. +% \begin{macrocode} + \def\Gin@llx{0}% + \Gin@defaultbp\Gin@lly{-\dp\gincltex@box}% + \Gin@defaultbp\Gin@urx{\wd\gincltex@box}% + \Gin@defaultbp\Gin@ury{\ht\gincltex@box}% +% \end{macrocode} +% The |height|, |totalheight| and |width| options are already processed and the final requested height and width +% to which the `graphic' should be scaled to are provided. The internal form of the |\resizebox| macro is used for +% this. +% \begin{macrocode} + \Gscale@@box\totalheight{\Gin@req@width}{\Gin@req@height}{% +% \end{macrocode} +% The trimming and clipping operations (|trim|, |viewport| and |clip| options) are handled using a |pgfpicture| from +% the |pgf| package, because it supports both DVI and PDF output. +% \begin{macrocode} + \begin{pgfpicture}% + \pgfkeys{/pgf/.cd,inner sep=0pt,outer sep=0pt}% + \pgfpathmoveto{\pgfqpoint{\Gin@llx bp}{\Gin@lly bp}}% + \pgfpathlineto{\pgfqpoint{\Gin@urx bp}{\Gin@lly bp}}% + \pgfpathlineto{\pgfqpoint{\Gin@urx bp}{\Gin@ury bp}}% + \pgfpathlineto{\pgfqpoint{\Gin@llx bp}{\Gin@ury bp}}% + \pgfpathclose + \expandafter + \pgfusepath\ifGin@clip{clip}\else{use as bounding box}\fi + \pgfnode{rectangle}{base west}{\usebox\gincltex@box}{}{}% + \end{pgfpicture}% +% \end{macrocode} +% \begin{macrocode} + }% + \endgroup +} +% \end{macrocode} +% \end{macro} +% +% The |\Gread@tex| macro is defined in two different ways depending how the bounding box information is preserved. +% This information is required to support the |draft| option of the |graphics| package. +% \begin{macrocode} +\if@gincltex@bbfile +% \end{macrocode} +% Use a |.tex.bb| file to store the bounding box information. The standardised EPS format is used here, so that the +% |\Gread@eps| macro can be used. +% +% An output register is required to write the |.tex.bb| files. Advanced users are allowed to predefine it manually +% in order to save a write register. Note that the writing is done inside the |.aux| file, therefore the |\@mainaux| +% handle could be used here, because it is closed while reading the |.aux| file. +% \begin{macrocode} +\@ifundefined{gincltex@bbout}{\newwrite\gincltex@bbout}{} +% \end{macrocode} +% +% \begin{macro}{\Gread@tex} +% \begin{macrocode} +\def\Gread@tex#1{% + \IfFileExists{#1.bb}% + {% + \edef\Gread@BBox{\@percentchar\@percentchar HiResBoundingBox}% + \Gread@eps{#1.bb}% + }% + {% + \sbox\gincltex@box{{\gincltex@input{#1}}}% + \def\Gin@llx{0}% + \Gin@defaultbp\Gin@lly{-\dp\gincltex@box}% + \Gin@defaultbp\Gin@urx{\wd\gincltex@box}% + \Gin@defaultbp\Gin@ury{\ht\gincltex@box}% + \expandafter\xdef\csname gincltex@bb@#1\endcsname + {{\Gin@llx}{\Gin@lly}{\Gin@urx}{\Gin@ury}}% + \if@filesw + \immediate\write\@auxout{\string\gincltex@bb{#1}% + \csname gincltex@bb@#1\endcsname}% + \fi + }% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\gincltex@bb} +% Write the bounding box information to the |.tex.bb| file. The hi-resolution version is used to be more accurate. +% The code to write the normal version is disabled for now because it is unneeded and requires some non-trivial |pgfmath| calls. +% +% Because this macro is executed inside the |.aux| file, which is read before the begin AND at the end of the document, the macro +% is defined as a no-op first two avoid unnecessary double execution. +% \begin{macrocode} +\def\gincltex@bb#1#2#3#4#5{} +\AtBeginDocument{\let\gincltex@bb\gincltex@@bb} +\def\gincltex@@bb#1#2#3#4#5{% + \begingroup + \immediate\openout\gincltex@bbout=#1.bb\relax + %\pgfmathtruncatemacro\llx{ceil(#2)}% + %\pgfmathtruncatemacro\lly{ceil(#3)}% + %\pgfmathtruncatemacro\urx{ceil(#4)}% + %\pgfmathtruncatemacro\ury{ceil(#5)}% + %\immediate\write\gincltex@bbout{\@percentchar + % \@percentchar BoundingBox: \llx\space\lly\space\urx\space\ury}% + \immediate\write\gincltex@bbout{\@percentchar + \@percentchar HiResBoundingBox: #2 #3 #4 #5}% + \immediate\closeout\gincltex@bbout + \endgroup +} +% \end{macrocode} +% \end{macro} +% +% Storing the bounding box information in the |.aux| file. +% \begin{macrocode} +\else +% \end{macrocode} +% +% \begin{macro}{\Gread@tex@setbb} +% Auxiliary macro to set the bounding box macros. +% \begin{macrocode} +\def\Gread@tex@setbb#1#2#3#4{% + \def\Gin@llx{#1}% + \def\Gin@lly{#2}% + \def\Gin@urx{#3}% + \def\Gin@ury{#4}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\Gread@tex} +% Read the bounding box information. The only way to do this is to actually typeset the source file into a box. +% The box is then reused in the |\Ginclude@tex| macro, so there is no overhead. +% The bounding box information is written into the |.aux| file to avoid processing the source file in |draft| mode. +% However if the corresponding macro is not define yet (e.g.\ |draft| run without |.aux| file) the file must be +% read anyway. +% \begin{macrocode} +\def\Gread@tex#1{% + \ifcase0\ifGin@draft\@ifundefined{gincltex@bb@#1}{0}{1}\fi\relax + \sbox\gincltex@box{{\gincltex@input{#1}}}% + \def\Gin@llx{0}% + \Gin@defaultbp\Gin@lly{-\dp\gincltex@box}% + \Gin@defaultbp\Gin@urx{\wd\gincltex@box}% + \Gin@defaultbp\Gin@ury{\ht\gincltex@box}% + \expandafter\xdef\csname gincltex@bb@#1\endcsname + {{\Gin@llx}{\Gin@lly}{\Gin@urx}{\Gin@ury}}% + \else + \expandafter\expandafter\expandafter\Gread@tex@setbb + \csname gincltex@bb@#1\endcsname + \setbox\gincltex@box=\box\voidb@x + \fi + \if@filesw + \immediate\write\@auxout{\string\gincltex@bb{#1}% + \csname gincltex@bb@#1\endcsname}% + \fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\gincltex@bb} +% Simply define the corresponding bounding box macro. +% \begin{macrocode} +\def\gincltex@bb#1#2#3#4#5{% + \global\@namedef{gincltex@bb@#1}{{#2}{#3}{#4}{#5}}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +\fi +\endinput +% \end{macrocode} +% +% \Finale +% \iffalse +% +% \fi + diff --git a/Master/texmf-dist/source/latex/gincltex/gincltex.ins b/Master/texmf-dist/source/latex/gincltex/gincltex.ins new file mode 100644 index 00000000000..52858c81cc4 --- /dev/null +++ b/Master/texmf-dist/source/latex/gincltex/gincltex.ins @@ -0,0 +1,49 @@ +%% $Id: skeleton.ins 1041 2009-05-02 16:07:25Z martin $ +\input docstrip.tex +\preamble + +Copyright (C) 2011 by Martin Scharrer + +This work may be distributed and/or modified under the +conditions of the LaTeX Project Public License, either version 1.3c +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.3c or later is part of all distributions of LaTeX +version 2008/05/04 or later. + +This work has the LPPL maintenance status `maintained'. + +The Current Maintainer of this work is Martin Scharrer. + +This work consists of the files gincltex.dtx, gincltex.ins +and the derived file gincltex.sty. + +\endpreamble +\keepsilent + +\generate{% + \file{gincltex.sty}{\from{gincltex.dtx}{package}}% +} + +\obeyspaces +\Msg{*************************************************************} +\Msg{* *} +\Msg{* To finish the installation you have to move the following *} +\Msg{* file into a directory searched by TeX: *} +\Msg{* *} +\Msg{* gincltex.sty *} +\Msg{* *} +\Msg{* To produce the documentation run the file gincltex.dtx *} +\Msg{* through LaTeX. *} +\Msg{* *} +\Msg{* Happy TeXing! *} +\Msg{* *} +\Msg{*************************************************************} + +\endbatchfile + +%% vim: ft=tex + -- cgit v1.2.3