From 8a24e67fddd2238ad6e658565cefa4bd7a48b14f Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Wed, 6 Oct 2010 00:09:14 +0000 Subject: new latex pkg cutwin (4oct10) git-svn-id: svn://tug.org/texlive/trunk@20000 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/tex/latex/cutwin/cutwin.sty | 326 ++++++++++++++++++++++++++ 1 file changed, 326 insertions(+) create mode 100644 Master/texmf-dist/tex/latex/cutwin/cutwin.sty (limited to 'Master/texmf-dist/tex/latex/cutwin') diff --git a/Master/texmf-dist/tex/latex/cutwin/cutwin.sty b/Master/texmf-dist/tex/latex/cutwin/cutwin.sty new file mode 100644 index 00000000000..dcd73b55a1a --- /dev/null +++ b/Master/texmf-dist/tex/latex/cutwin/cutwin.sty @@ -0,0 +1,326 @@ +%% +%% This is file `cutwin.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% cutwin.dtx (with options: `pkg') +%% +%% ----------------------------------------------------------------- +%% Author: Peter Wilson, Herries Press (herries dot press at earthlink dot net) +%% and Alan Hoenig +%% Copyright 2010 Peter R. Wilson +%% +%% 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 the license is in +%% http://www.latex-project.org/lppl.txt +%% and version 1.3 or later is part of all distributions of +%% LaTeX version 2003/06/01 or later. +%% +%% This work has the LPPL maintenance status "author-maintained". +%% +%% This work consists of the files listed in the README file. +%% ----------------------------------------------------------------- +%% +%% \iffalse meta-comment +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{cutwin}[2010/09/29 v0.1 cutout windows] + +\newcount\c@twwinlines % window lines +\newcount\c@twtoplines % top lines +\newcount\c@twcnt % a count + +\newdimen\c@twlftside % left width +\newdimen\c@twrtside % right width +\newdimen\c@twtopht % height of top text +\newdimen\c@twvsilg % Vertical Shift or InterLine Glue + +\newtoks\c@twtoka % build of parshape spec +\newtoks\c@twtokb % build of parshape spec + +\newbox\c@twrawtext % text as input +\newbox\c@twholdwin % text for window sides +\newbox\c@twwindow % composed window +\newbox\c@twfinaltext % final assembled cutout paragraph +\newbox\c@twslicea % slice A of window text +\newbox\c@twsliceb % slice B of window text + +\newcommand*{\opencutleft}{\def\c@twl@c{-1}} +\newcommand*{\opencutright}{\def\c@twl@c{1}} +\newcommand*{\opencutcenter}{\def\c@twl@c{0}} +\opencutcenter + +\newcommand{\cutfuzz}{\vbadness=50000 + \hbadness=50000 + \sloppy} + +\newcommand*{\c@twcalcilg}{% + \c@twvsilg=\baselineskip + \setbox0=\hbox{(} + \advance\c@twvsilg-\ht0 \advance\c@twvsilg-\dp0} + +\newcommand*{\pageinwindow}{% + \@tempdimc=\c@twwinlines\baselineskip % cutout height + \@tempdimb=\hsize + \ifnum\c@twl@c=\m@ne % openleft + \advance\@tempdimb -\c@twrtside + \else + \ifnum\c@twl@c=\@ne % openright + \advance\@tempdimb -\c@twlftside + \else% center + \advance\@tempdimb - \c@twlftside + \advance\@tempdimb - \c@twrtside + \fi + \fi + \begin{picture}(0,0)% + \put(0,0){% + \raisebox{4pt}{% + \begin{minipage}[t][\@tempdimc][c]{\@tempdimb} + \windowpagestuff + \end{minipage} + }% end raisebox + }% end put + \end{picture}} +\newcommand*{\windowpagestuff}{} + +\newenvironment{cutout}[4]{% + \cutfuzz + \c@twtoplines=#1\relax + \c@twwinlines=#4\relax + \c@twlftside=#2\relax + \c@twrtside=#3\relax + \c@twtoka={}% + \c@twmakeparspec + \c@twtoplines=#1\relax + \c@twwinlines=#4\relax + \c@twcalcshift \vskip-\c@twvsilg + \setbox\c@twrawtext=\vbox\bgroup + \parshape=\c@twcnt \the\c@twtoka}% + {\egroup% end \box\c@twrawtext + \parshape=0 % reset parshape; + \c@twcalcilg % find ILG using current font + \ifnum\c@twtoplines>\z@ + \setbox\c@twfinaltext=\vsplit\c@twrawtext to\c@twtoplines\baselineskip + \fi + \c@twtopht=\c@twwinlines\baselineskip + \ifnum\c@twl@c=\z@ % center + \c@twtopht=2\c@twtopht + \fi + \setbox\c@twholdwin=\vsplit\c@twrawtext to\c@twtopht + \ifnum\c@twl@c=\z@% center + \c@twcompctr{\c@twholdwin}{\c@twwindow} + \else% left or right + \c@twcomplftrt{\c@twholdwin}{\c@twwindow} + \fi + \setbox\c@twfinaltext= + \vbox{\ifnum\c@twtoplines>\z@\unvbox\c@twfinaltext\vskip\c@twvsilg\fi + \unvbox\c@twwindow% + \vskip-\c@twvsilg\unvbox\c@twrawtext}% + \box\c@twfinaltext} + +\newcommand*{\c@twcompctr}[2]{% + \def\c@twfirst{1} + \loop\advance\c@twwinlines\m@ne + \setbox\c@twslicea=\vsplit#1 to\baselineskip + \setbox\c@twsliceb=\vsplit#1 to\baselineskip + \c@twprune{\c@twslicea}{\c@twlftside}% + \c@twprune{\c@twsliceb}{\c@twrtside}% + \ifnum\c@twfirst=\@ne + \setbox#2=\vbox{\unvbox#2\hbox + to\hsize{\box\c@twslicea\pageinwindow\hfil\box\c@twsliceb}}% + \else + \setbox#2=\vbox{\unvbox#2\hbox + to\hsize{\box\c@twslicea\hfil\box\c@twsliceb}}% + \fi + \def\c@twfirst{2} + \ifnum\c@twwinlines>\z@\repeat} + +\newcommand*{\c@twcomplftrt}[2]{% + \def\c@twfirst{1}% + \loop\advance\c@twwinlines\m@ne + \setbox\c@twslicea=\vsplit#1 to\baselineskip + \ifnum\c@twl@c=\m@ne% open left, text at right + \c@twprune{\c@twslicea}{\c@twrtside} + \ifnum\c@twfirst=\@ne + \setbox#2=\vbox{\unvbox#2\hbox + to\hsize{\pageinwindow\hfil\box\c@twslicea}}% + \else + \setbox#2=\vbox{\unvbox#2\hbox + to\hsize{\mbox{}\hfil\box\c@twslicea}}% + \fi + \def\c@twfirst{2} + \else + \ifnum\c@twl@c=\@ne% open right, text at left + \c@twprune{\c@twslicea}{\c@twlftside} + \ifnum\c@twfirst=\@ne\relax + \setbox#2=\vbox{\unvbox#2\hbox + to\hsize{\box\c@twslicea\pageinwindow}}% + \else + \setbox#2=\vbox{\unvbox#2\hbox + to\hsize{\box\c@twslicea}}% + \fi + \def\c@twfirst{2} + \fi + \fi + \ifnum\c@twwinlines>\z@\repeat} + +\newcommand*{\c@twprune}[2]{% + \unvbox#1 \setbox#1=\lastbox % \box#1 is now an \hbox + \setbox#1=\hbox to#2{\strut\unhbox#1\unskip}} + +\newcommand*{\c@twmakeparspec}{% + \c@twcnt=\c@twwinlines + \ifnum\c@twl@c=\z@ + \multiply \c@twcnt by \tw@ + \fi + \advance\c@twcnt by \c@twtoplines \advance\c@twcnt by \@ne + \ifnum\c@twtoplines>\z@ + \loop\c@twtoka=\expandafter{\the\c@twtoka 0pt \hsize} + \advance\c@twtoplines -1\relax + \ifnum\c@twtoplines>\z@\repeat + \fi + \ifnum\c@twl@c=\m@ne % openleft + \c@twlftside=\hsize + \advance\c@twlftside -\c@twrtside + \fi + \loop\c@twtoka=% + \ifnum\c@twl@c=\m@ne % openleft + \expandafter{\the\c@twtoka \c@twlftside \c@twrtside} + \else + \ifnum\c@twl@c=\@ne % openright + \expandafter{\the\c@twtoka 0pt \c@twlftside} + \else %center + \expandafter{\the\c@twtoka 0pt \c@twlftside 0pt \c@twrtside} + \fi + \fi + \advance\c@twwinlines \m@ne + \ifnum\c@twwinlines>\z@\repeat + \c@twtoka=\expandafter{\the\c@twtoka 0pt \hsize}} + +\newcommand*{\c@twcalcshift}{% vertical shift + \c@twvsilg=\c@twwinlines\baselineskip + \ifnum\c@twtoplines<\@ne + \advance\c@twvsilg -0.25\baselineskip + \fi + \c@twvsilg=0.5\c@twvsilg + \ifnum\c@twl@c=\z@\else + \c@twvsilg=0.5\c@twvsilg + \fi} + +\newcommand*{\picinwindow}{% + \begin{picture}(0,0) + \putstuffinpic + \end{picture}} +\newcommand*{\putstuffinpic}{} + +\newenvironment{shapedcutout}[3]{% + \cutfuzz + \c@twtoplines=#1\relax + \c@twwinlines=#2\relax + \edef\c@twb{#3}% user's parspec + \c@twmaketopoddspec + \c@twbuildoddspec{#3} + \c@twtoplines=#1\relax + \c@twwinlines=#2\relax + \c@twcalcshift \vskip-\c@twvsilg + \setbox\c@twrawtext=\vbox\bgroup + \parshape=\c@twcnt \the\c@twtoka \the\c@twtokb 0pt \hsize}% + {\egroup + \parshape=0 + \c@twcalcilg + \ifnum\c@twtoplines>\z@ + \setbox\c@twfinaltext=\vsplit\c@twrawtext to\c@twtoplines\baselineskip + \fi + \c@twtopht=\c@twwinlines\baselineskip + \ifnum\c@twl@c=\z@ % center + \c@twtopht=2\c@twtopht + \fi + \setbox\c@twholdwin=\vsplit\c@twrawtext to\c@twtopht + \ifnum\c@twl@c=\z@% center + \c@twcompoddctr{\c@twholdwin}{\c@twwindow} + \else% open left or righyt + \c@twcompoddlftrt{\c@twholdwin}{\c@twwindow} + \fi + \setbox\c@twfinaltext= + \vbox{\ifnum\c@twtoplines>\z@\unvbox\c@twfinaltext\vskip\c@twvsilg\fi + \unvbox\c@twwindow% + \vskip-\c@twvsilg\unvbox\c@twrawtext}% + \box\c@twfinaltext} + +\newcommand*{\c@twmaketopoddspec}{% + \c@twcnt=\c@twwinlines + \ifnum\c@twl@c=\z@ + \multiply \c@twcnt by \tw@ + \fi + \advance\c@twcnt by \c@twtoplines \advance\c@twcnt by \@ne +%% \c@twcnt is total of toplines + 2(window lines) + 1 + \c@twtoka={} + \ifnum\c@twtoplines>\z@ + \loop\c@twtoka=\expandafter{\the\c@twtoka 0pt \hsize} + \advance\c@twtoplines -1\relax + \ifnum\c@twtoplines>\z@\repeat + \fi} + +\newcommand*{\c@twaddtospec}[1]{% + \c@twtokb=\c@twxpf{\the\c@twtokb 0pt #1 }} +\let\c@twxpf\expandafter +\newcommand*{\c@twbuildoddspec}[1]{% + \c@twtokb={} + \@for\c@twlspec:=#1\do{% + \c@twxpf\c@twxpf\c@twxpf\c@twaddtospec\c@twxpf{\c@twlspec}}} + +\newcommand*{\c@twcompoddctr}[2]{% + \def\c@twrounds{1} + \def\c@twfirst{1} + \@for\c@twlspec:=\c@twb\do{% + \ifnum\c@twrounds=1 + \setbox\c@twslicea=\vsplit#1 to\baselineskip % first of pair + \c@twprune{\c@twslicea}{\c@twlspec}% + \def\c@twrounds{2} + \else + \setbox\c@twsliceb=\vsplit#1 to\baselineskip % second of pair + \c@twprune{\c@twsliceb}{\c@twlspec}% + \ifnum\c@twfirst=1 + \setbox#2=\vbox{\unvbox#2\hbox + to\hsize{\box\c@twslicea\hfil\picinwindow\hfil\box\c@twsliceb}}% + \def\c@twfirst{2} + \else + \setbox#2=\vbox{\unvbox#2\hbox + to\hsize{\box\c@twslicea\hfil\box\c@twsliceb}}% + \fi + \def\c@twrounds{1} + \fi}} + +\newcommand*{\c@twcompoddlftrt}[2]{% + \def\c@twfirst{1} + \@for\c@twlspec:=\c@twb\do{% + \setbox\c@twslicea=\vsplit#1 to\baselineskip % get a line + \c@twprune{\c@twslicea}{\c@twlspec}% + \ifnum\c@twl@c=\m@ne% open left, text at right + \ifnum\c@twfirst=1 + \setbox#2=\vbox{\unvbox#2\hbox + to\hsize{\mbox{}\hfil\picinwindow\hfil\box\c@twslicea}}% + \def\c@twfirst{2} + \else + \setbox#2=\vbox{\unvbox#2\hbox + to\hsize{\mbox{}\hfil\box\c@twslicea}}% + \fi + \else + \ifnum\c@twl@c=\@ne% open right, text at left + \ifnum\c@twfirst=1 + \setbox#2=\vbox{\unvbox#2\hbox + to\hsize{\box\c@twslicea\hfil\picinwindow\hfil}}% + \def\c@twfirst{2} + \else + \setbox#2=\vbox{\unvbox#2\hbox + to\hsize{\box\c@twslicea\hfil}}% + \fi + \fi + \fi}} + +\endinput +%% +%% End of file `cutwin.sty'. -- cgit v1.2.3