From 755ee977e784df555d3142c1dcf67a6701c76cc5 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Fri, 13 Jul 2012 23:27:59 +0000 Subject: new latex package incgraph (21jun12) git-svn-id: svn://tug.org/texlive/trunk@27038 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/tex/latex/incgraph/incgraph.sty | 325 ++++++++++++++++++++++ 1 file changed, 325 insertions(+) create mode 100644 Master/texmf-dist/tex/latex/incgraph/incgraph.sty (limited to 'Master/texmf-dist/tex/latex/incgraph') diff --git a/Master/texmf-dist/tex/latex/incgraph/incgraph.sty b/Master/texmf-dist/tex/latex/incgraph/incgraph.sty new file mode 100644 index 00000000000..a7c6bbe7c0a --- /dev/null +++ b/Master/texmf-dist/tex/latex/incgraph/incgraph.sty @@ -0,0 +1,325 @@ +%% The LaTeX package incgraph - version 1.02 (2012/07/06) +%% incgraph.sty: Graphics inclusion page +%% +%% ------------------------------------------------------------------------------------------- +%% Copyright (c) 2012 by Prof. Dr. Dr. Thomas F. Sturm +%% ------------------------------------------------------------------------------------------- +%% +%% This work may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either version 1.3 +%% 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.3 or later is part of all distributions of LaTeX +%% version 2005/12/01 or later. +%% +%% This work has the LPPL maintenance status `author-maintained'. +%% +%% This work consists of all files listed in README +%% +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{incgraph}[2012/07/06 version 1.02 LaTeX special graphics inclusion] + +\DeclareOption{pgf}{\def\igrreq@pgf{\RequirePackage{pgf}[2008/01/15]\RequirePackage{pgffor}}}% +\DeclareOption{nopgf}{\def\igrreq@pgf{}}% +\DeclareOption{graphicx}{\def\igrreq@graphicx{\RequirePackage{graphicx}}}% +\DeclareOption{nographicx}{\def\igrreq@graphicx{}}% +\DeclareOption{bookmark}{\def\igrreq@bookmark{\RequirePackage{bookmark}}}% +\DeclareOption{nobookmark}{\def\igrreq@bookmark{}}% + +\ExecuteOptions{pgf,graphicx,bookmark} +\ProcessOptions\relax + +\RequirePackage{pgfkeys} +\igrreq@pgf +\igrreq@graphicx +\igrreq@bookmark + +% key management +\pgfkeys{/igr/.is family} + +\def\igrset{\pgfqkeys{/igr}} + +\newbox\igrbox +\newdimen\igr@length +\newcounter{igrtarget} + +\AtBeginDocument{% + \edef\igrOrginalPageWidth{\the\pdfpagewidth}% + \edef\igrOrginalPageHeight{\the\pdfpageheight}% +} + +\def\igr@target@auto{% + \edef\igrAutoTarget{igr-\theigrtarget}% +} + +\def\igr@target@user{% + \edef\igrAutoTarget{\igr@usertarget}% + \global\let\igr@target@next=\igr@target@auto% +} + +\let\igr@target@next=\igr@target@auto + +\def\igrtargetset#1{% + \def\igr@usertarget{#1}% + \let\igr@target@next=\igr@target@user% +} + +\def\igr@nextAutoTarget{% + \refstepcounter{igrtarget}% + \igr@target@next% +} + +\long\def\igrboxset#1{% + \igr@nextAutoTarget% + \setbox\igrbox\hbox{#1}% + \igr@length=\wd\igrbox% + \edef\igrBoxWidth{\the\igr@length}% + \igr@length=\ht\igrbox% + \edef\igrBoxht{\the\igr@length}% + \igr@length=\dp\igrbox% + \edef\igrBoxdp{\the\igr@length}% + \advance\igr@length by \igrBoxht% + \edef\igrBoxHeight{\the\igr@length}% +} + +\def\igr@hyper{\hypertarget{\igrAutoTarget}{}} +\def\igr@empty{} + +\def\igrboxcenter{% + \thispagestyle{\igrpagestyle}% + % + \igr@length=-1in% + \advance\igr@length by -\voffset% + \advance\igr@length by -\topmargin% + \advance\igr@length by -\headheight% + \advance\igr@length by -\headsep% + \advance\igr@length by -\lineskip% + \edef\igr@offy@top{\the\igr@length}% + % + \igr@length=\pdfpageheight% + \advance\igr@length by -\igrBoxHeight% + \divide\igr@length by 2% + \edef\igr@offy@abs{\the\igr@length}% + % + \igr@length=-1in% + \advance\igr@length by -\hoffset% + \advance\igr@length by -\@themargin% + \edef\igr@offx@left{\the\igr@length}% + % + \igr@length=\pdfpagewidth% + \advance\igr@length by -\igrBoxWidth% + \divide\igr@length by 2% + \advance\igr@length by \igr@offx@left% + \edef\igr@offx{\the\igr@length}% + % + \vbox to \vsize{% + \kern\igr@offy@top\hbox{\kern\igr@offx@left\igr@hypertarget\hss}\kern\igr@offy@abs% + \hbox to \hsize{\kern\igr@offx\box\igrbox\hss}% + \vss}% + \break% +} + +\def\igrboxtikz{% + \path[use as bounding box] (0,0) rectangle (\igrBoxWidth,\igrBoxHeight); + \node[line width=0mm,inner sep=0,rectangle,above right] (box) at (0,0) {\box\igrbox}; + \node[minimum width=\igrBoxWidth,minimum height=\igrBoxHeight,line width=0mm,inner sep=0mm,above right] (page) at (0,0) {};% +} + +\let\igrboxtikzpage=\igrboxtikz + +\def\igrboxtikzcenter{% + \path[use as bounding box] (0,0) rectangle (\pdfpagewidth,\pdfpageheight); + \node[line width=0mm,inner sep=0,rectangle,above right] (box) at ({(\pdfpagewidth-\igrBoxWidth)/2},{(\pdfpageheight-\igrBoxHeight)/2}) {\box\igrbox}; + \let\igrBoxWidth=\pdfpagewidth% + \let\igrBoxHeight=\pdfpageheight% + \node[minimum width=\pdfpagewidth,minimum height=\pdfpageheight,line width=0mm,inner sep=0mm,above right] (page) at (0,0) {};% +} + +\long\def\igrpage#1{% + \def\igr@mode{page}% + \igrboxset{#1}% + \eject% + \pdfpagewidth=\igrBoxWidth% + \pdfpageheight=\igrBoxHeight% + \edef\theigrpage{\thepage}% + \igrboxcenter% + \pdfpagewidth=\igrOrginalPageWidth% + \pdfpageheight=\igrOrginalPageHeight% +} + +\long\def\igrcenter#1{% + \def\igr@mode{center}% + \igrboxset{#1}% + \clearpage% + \edef\theigrpage{\thepage}% + \igrboxcenter% +} + +\def\incgraph{% + \@ifnextchar[{\inc@incgraph}{\inc@incgraph[]}} + +\def\inc@incgraph[#1]{% + \@ifnextchar[{\inc@@incgraph[#1]}{\inc@@incgraph[#1][]}} + +\long\def\inc@@incgraph[#1][#2]#3{% + \begingroup% + \def\nt{#3}% + \igr@if@file@exists{\nt}{% + \igrset{#1}% + \igr@match@hook% + \edef\igr@incgraph{\noexpand\igr@include@graphics[\igr@options,#2]}% + \igr@output{\igr@incgraph{\nt}\ifx\igr@label@text\igr@empty\else\label{\igr@label@text}\fi}% + \ifx\igr@bookmark@text\igr@empty\else% + \edef\igr@bookmark{\noexpand\bookmark[\igr@bookmark@options,dest=\noexpand\igrAutoTarget]}% + \igr@bookmark{\igr@bookmark@text}\fi% + }{}% + \endgroup% +} + +\def\igr@bookmark@heading{% + \global\let\igr@process@label=\igr@empty% + \ifx\igr@bookmark@heading@text\igr@empty\else% + \edef\igr@bookmark{\noexpand\bookmark[\igr@bookmark@heading@options,dest=\noexpand\igrAutoTarget]}% + \igr@bookmark{\igr@bookmark@heading@text}\fi% + \global\let\igr@process@bookmark@heading=\igr@empty% +} + +\def\incmultigraph{% + \@ifnextchar[{\inc@incmultigraph}{\inc@incmultigraph[]}} + +\def\inc@incmultigraph[#1]{% + \@ifnextchar[{\inc@@incmultigraph[#1]}{\inc@@incmultigraph[#1][]}} + +\long\def\inc@@incmultigraph[#1][#2]#3#4{% + \begingroup% + \igrset{#1}% + \ifx\igr@label@text\igr@empty\global\let\igr@process@label=\igr@empty\else% + \global\def\igr@process@label{\label{\igr@label@text}}\fi% + \global\let\igr@process@bookmark@heading=\igr@bookmark@heading% + \foreach \n [count=\ni] in {#4} {% + \edef\nn{\igr@zero@fill{\n}}% + \def\nt{#3}% + \igr@if@file@exists{\nt}{% + \igr@match@hook% + \edef\igr@incgraph{\noexpand\igr@include@graphics[\igr@options,#2]}% + \igr@output{\igr@incgraph{\nt}\igr@process@label}% + \igr@process@bookmark@heading% + \ifx\igr@bookmark@text\igr@empty\else% + \edef\igr@bookmark{\noexpand\bookmark[\igr@bookmark@options,dest=\noexpand\igrAutoTarget]}% + \igr@bookmark{\igr@bookmark@text}\fi% + }{}}\endgroup% +} + +\def\igr@make@zerofill#1#2#3#4#5#6#7#8#9{% + \def\igr@zerofill##1{% + \ifnum##1<10 #1% + \else\ifnum##1<100 #2% + \else\ifnum##1<1000 #3% + \else\ifnum##1<10000 #4% + \else\ifnum##1<100000 #5% + \else\ifnum##1<1000000 #6% + \else\ifnum##1<10000000 #7% + \else\ifnum##1<100000000 #8% + \else\ifnum##1<1000000000 #9% + \fi\fi\fi\fi\fi\fi\fi\fi\fi% + ##1% + }% +} + +\def\igrmakezerofill#1#2{% + \def\igr@zerofill##1{##1}% + \ifcase#2\or\or\igr@make@zerofill{0}{}{}{}{}{}{}{}{}% + \or\igr@make@zerofill{00}{0}{}{}{}{}{}{}{}% + \or\igr@make@zerofill{000}{00}{0}{}{}{}{}{}{}% + \or\igr@make@zerofill{0000}{000}{00}{0}{}{}{}{}{}% + \or\igr@make@zerofill{00000}{0000}{000}{00}{0}{}{}{}{}% + \or\igr@make@zerofill{000000}{00000}{0000}{000}{00}{0}{}{}{}% + \or\igr@make@zerofill{0000000}{000000}{00000}{0000}{000}{00}{0}{}{}% + \or\igr@make@zerofill{00000000}{0000000}{000000}{00000}{0000}{000}{00}{0}{}% + \else\igr@make@zerofill{000000000}{00000000}{0000000}{000000}{00000}{0000}{000}{00}{0}% + \fi% + \let#1=\igr@zerofill% +} + +\newcommand{\igrsetmatchvalue}[2]{% + \pgfkeyssetvalue{/igrmatch/#1}{#2}% +} + +\newcommand{\igrifmatch}[3]{% + \pgfkeysifdefined{/igrmatch/#1}{% + \pgfkeysgetvalue{/igrmatch/#1}{\igrmatchvalue}#2}{#3}% +} + +\pgfkeys{% + /igrsetmatch/.unknown/.code={% + \let\igrmatchkey=\pgfkeyscurrentname% + \igrsetmatchvalue{\igrmatchkey}{#1}% + }% +} + +\newcommand{\igrsetmatches}[1]{\pgfkeys{/igrsetmatch/.cd,#1}} + +\newcommand{\igr@no@existence@check}[3]{#2} + +\newcommand{\igr@include@graphics@tikz}[2][1]{% + \igrboxset{\includegraphics[#1]{#2}}% + \begin{tikzpicture}% + \csname igrboxtikz\igr@mode\endcsname% + \igr@tikz@hook% + \end{tikzpicture}} + +\igrset{% + center/.code={\let\igr@output=\igrcenter}, + page/.code={\let\igr@output=\igrpage}, + options/.store in=\igr@options, + options add/.code={% + \toks0=\expandafter{\igr@options}% + \def\temp{#1}\toks1=\expandafter{\temp}% + \edef\igr@options{\the\toks0,\the\toks1}}, + bookmark/.store in=\igr@bookmark@text, + bookmark options/.store in=\igr@bookmark@options, + bookmark heading/.store in=\igr@bookmark@heading@text, + bookmark heading options/.store in=\igr@bookmark@heading@options, + label/.store in=\igr@label@text, + zerofill/.code={\igrmakezerofill{\igr@zero@fill}{#1}}, + set matches/.code=\igrsetmatches{#1}, + hyper/.code={\let\igr@hypertarget=\igr@hyper}, + no hyper/.code={\let\igr@hypertarget=\igr@empty}, + if match code/.code args={#1#2#3}{\def\igr@match@hook{\igrifmatch{#1}{#2}{#3}}}, + if match set/.style args={#1#2#3}{if match code={#1}{\igrset{#2}}{\igrset{#3}}}, + if match set bookmark/.style args={#1#2#3}{if match code={#1}{\igrset{bookmark={#2}}}{\igrset{bookmark={#3}}}}, + disable match/.code={\let\igr@match@hook=\igr@empty}, + include command/.code={\let\igr@include@graphics=#1}, + include command/.default=\includegraphics, + existence check/.code={\let\igr@if@file@exists=#1}, + fail on not found/.style={existence check=\igr@no@existence@check}, + ignore on not found/.style={existence check=\IfFileExists}, + pagestyle/.store in=\igrpagestyle, + target/.code={\igrtargetset{#1}}, + overlay@code/.store in=\igr@tikz@hook, + overlay/.style={include command=\igr@include@graphics@tikz,overlay@code={#1}}, + overlay page number at/.style={overlay={\node[fill opacity=0.35,draw opacity=0.5,text opacity=1, + inner xsep=1em,rounded corners,fill=white,draw=black] at (#1) {\thepage};}}, + overlay page number at top/.style={overlay page number at={\igrBoxWidth/2,\igrBoxHeight-#1}}, + overlay page number at top/.default=1.5cm, + overlay page number at bottom/.style={overlay page number at={\igrBoxWidth/2,#1}}, + overlay page number at bottom/.default=1.5cm, + no overlay/.style={include command}, +% + page, + options=, + bookmark=, + bookmark options=, + bookmark heading=, + bookmark heading options=, + label=, + zerofill=0, + hyper, + disable match, + include command, + ignore on not found, + pagestyle=empty, + overlay@code=, +} + -- cgit v1.2.3