diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex')
-rw-r--r-- | Master/texmf-dist/tex/latex/zwpagelayout/zwpagelayout.sty | 378 |
1 files changed, 356 insertions, 22 deletions
diff --git a/Master/texmf-dist/tex/latex/zwpagelayout/zwpagelayout.sty b/Master/texmf-dist/tex/latex/zwpagelayout/zwpagelayout.sty index cd5e9af9cd6..fe33debd52e 100644 --- a/Master/texmf-dist/tex/latex/zwpagelayout/zwpagelayout.sty +++ b/Master/texmf-dist/tex/latex/zwpagelayout/zwpagelayout.sty @@ -1,7 +1,7 @@ -\ProvidesPackage{zwpagelayout}[2008/12/26 ZW Page Layout] -\PackageInfo{zwpagelayout}{$Id: zwpagelayout.sty 290 2008-12-26 17:43:49Z zw $\@gobble} +\ProvidesPackage{zwpagelayout}[2010/12/21 ZW Page Layout] +\PackageInfo{zwpagelayout}{$Id: zwpagelayout.sty 377 2010-12-21 14:29:56Z zw $\@gobble} -%% Copyright 2008 Z. Wagner, http://icebearsoft.euweb.cz +%% Copyright 2008--2010 Z. Wagner, http://icebearsoft.euweb.cz % % This work may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.3 @@ -16,11 +16,34 @@ % The Current Maintainer of this work is Z. Wagner. % % This work consists of the files: zwpagelayout.sty and -% the documentation files zwpagelayout.tex, zwpagelayout.pdf. +% the documentation files zwpagelayout.tex, zwpagelayout.pdf together with +% adjustfoot.tex, adjustfoot.pdf, adjusthead.tex, adjusthead.pdf, +% coversample.tex, coversample.pdf, LoremIpsumDolor.tex. -\RequirePackage{kvoptions,ifpdf} +\IfFileExists{ifpdf.sty}{\RequirePackage{ifpdf}}{\newif\ifpdf} +\IfFileExists{ifxetex.sty}{\RequirePackage{ifxetex}}{\newif\ifxetex} +\RequirePackage{kvoptions} \SetupKeyvalOptions{family=zwpl,prefix=zwpl@} +% Backspace character with catcode=12 + +{\lccode`\!`\\ \lowercase{\gdef\PDFbksp{!}}} + +% Driver selection macros and options + +\def\zwpl@useunknown{0} +\def\zwpl@usepdftex{1} +\def\zwpl@usexetex{2} +\def\zwpl@usedvips{3} +\let\zwpl@usedvipdfm\zwpl@usexetex +\let\zwpl@usexdvipdfmx\zwpl@usexetex +\let\zwpl@useother\zwpl@useunknown +\newcount\zwpl@Driver +\zwpl@Driver\ifpdf \zwpl@usepdftex \else \ifxetex \zwpl@usexetex \else \zwpl@usedvips \fi \fi +\relax + +\DeclareStringOption{driver} + % Landscape/Portrait \DeclareBoolOption{Landscape} @@ -113,23 +136,51 @@ %%%\DeclareStringOption[\fontsize{10}{10}]{cropfontsize} %%%\DeclareStringOption[\normalfont]{cropfont} \DeclareBoolOption{nobleedclip} +\DeclareBoolOption{noBboxes} -% Color support for cropmarks +% Color support for cropmarks and black overprint \DeclareBoolOption{color} \DeclareStringOption[cmyk]{colormodel} \DeclareStringOption[1,1,1,1]{cropcolor} \DeclareStringOption[{CYAN:1,0,0,0},{MAGENTA:0,1,0,0},{YELLOW:0,0,1,0},{BLACK:0,0,0,1}]{colors} +\DeclareBoolOption{redefineblack} +\DeclareBoolOption{redefinetocmyk} + +% Overprint support, it will automatically request color +\DeclareBoolOption{overprint} + +% PDF information +\DeclareStringOption[\zwpl@default@title]{title}[] +\DeclareStringOption{author} +\DeclareStringOption{subject} +\DeclareStringOption{keywords} +\DeclareVoidOption{nopdfinfo}{\setkeys{zwpl}{title}} + +\def\zwpl@default@title{\ifcat$\zwpl@croptitle$\jobname\else\zwpl@croptitle\fi} + +% PDF/X-1a support etc. +\DeclareStringOption{pdfminorversion} +\DeclareBoolOption{pdfx} +\DeclareStringOption[Euroscale Coated v2]{OutputCondition} +\DeclareStringOption[Euroscale Coated v2]{OutputConditionIdentifier} +\DeclareStringOption{ICCfile} -% Reflect, works with pdftex and dvips +% Reflect, works with pdftex, (x)dvipdfm(x) aa well as dvips -\def\zwpl@makeHreflect{\AtBeginDocument{\ifpdf +\def\zwpl@makeHreflect{\AtBeginDocument{\ifcaseZWdriver + \or \let\zwpl@Hship\shipout \def\shipout{\zwpl@Hreflect\zwpl@Hship}\zwpl@Hreflect + \or + \zwpl@XHreflect \else\zwpl@psHreflect\fi}} -\def\zwpl@makeVreflect{\AtBeginDocument{\ifpdf +\def\zwpl@makeVreflect{\AtBeginDocument{\ifcaseZWdriver + \or \let\zwpl@Vship\shipout \def\shipout{\zwpl@Vreflect\zwpl@Vship}\zwpl@Vreflect + \or + \zwpl@XVreflect \else\zwpl@psVreflect\fi}} \DeclareVoidOption{ReflectHorizontally}{\zwpl@makeHreflect} @@ -137,6 +188,30 @@ \ProcessKeyvalOptions* +% Define the driver + +\ifcat$\zwpl@driver$ \else + \expandafter\ifx\csname zwpl@use\zwpl@driver\endcsname\relax + \PackageErrorNoLine{zwpagelayout}{Unsupported driver \zwpl@driver} + \else + \zwpl@Driver\csname zwpl@use\zwpl@driver\endcsname\relax + \fi +\fi +\def\ifcaseZWdriver{\ifcase\zwpl@Driver} +\DeclareRobustCommand\ZWifdriver[2]{\expandafter\ifx\csname zwpl@use#1\endcsname\relax + \PackageWarningNoLine{zwpagelayout}{Driver #1 not recognized, code ignored}% + \else + \ifnum\csname zwpl@use#1\endcsname=\zwpl@Driver\relax #2\fi} + +\PackageInfo{zwpagelayout}{Driver mode used: + \ifcaseZWdriver unknown\or pdftex\or xetex\else dvips\fi.\MessageBreak} + +% Define pdfmark if the RIP does not know it + +\ifnum\zwpl@Driver=\zwpl@usedvips + \special{!/pdfmark where {pop}{userdict /pdfmark /cleartomark load put} ifelse} +\fi + % Other packages \ifzwpl@onlycropmarks @@ -165,11 +240,158 @@ \fi \fi -\AtBeginDocument{\ifpdf +\AtBeginDocument{\ifcaseZWdriver \or \pdfpagewidth\paperwidth \pdfpageheight\paperheight \else \special{papersize=\the\paperwidth,\the\paperheight}\fi} +\def\zwpl@setbpdim#1#2{\@tempdimc#2 \@tempdimc .99626\@tempdimc + \edef#1{\strip@pt\@tempdimc}} + +\def\zwpl@setboxex{\zwpl@setbpdim\zwpl@bleedorig\zwpl@croplength + \@tempdima\paperwidth \advance\@tempdima-\zwpl@croplength + \zwpl@setbpdim\zwpl@bleedwidth\@tempdima + \@tempdima\paperheight \advance\@tempdima-\zwpl@croplength + \zwpl@setbpdim\zwpl@bleedheight\@tempdima + \@tempdimb\zwpl@croplength \advance\@tempdimb\zwpl@cropgap + \zwpl@setbpdim\zwpl@trimorig\@tempdimb + \@tempdima\paperwidth \advance\@tempdima-\@tempdimb + \zwpl@setbpdim\zwpl@trimwidth\@tempdima + \@tempdima\paperheight \advance\@tempdima-\@tempdimb + \zwpl@setbpdim\zwpl@trimheight\@tempdima + \edef\zw@tmp{/BleedBox [\zwpl@bleedorig\space \zwpl@bleedorig\space + \zwpl@bleedwidth\space \zwpl@bleedheight] + /TrimBox [\zwpl@trimorig\space \zwpl@trimorig\space + \zwpl@trimwidth\space \zwpl@trimheight] + /ArtBox [\zwpl@trimorig\space \zwpl@trimorig\space + \zwpl@trimwidth\space \zwpl@trimheight]} + \ifcaseZWdriver + \or + \expandafter\pdfpageattr\expandafter{\zw@tmp} + \or + \edef\zw@tmpx{pdf:put @pages <<\zw@tmp>>} + \expandafter\special\expandafter{\zw@tmpx} + \else + \special{! userdict begin + userdict /bop-hook known {/bop-hook load cvx /ZWBox-hook exch def} if + /bop-hook { + [/BleedBox [\zwpl@bleedorig\space \zwpl@bleedorig\space + \zwpl@bleedwidth\space \zwpl@bleedheight] /PAGE pdfmark + [/TrimBox [\zwpl@trimorig\space \zwpl@trimorig\space + \zwpl@trimwidth\space \zwpl@trimheight] /PAGE pdfmark + [/ArtBox [\zwpl@trimorig\space \zwpl@trimorig\space + \zwpl@trimwidth\space \zwpl@trimheight] /PAGE pdfmark + userdict /ZWBox-hook known {ZWBox-hook} if + } def + end} + \fi} + +\ifzwpl@cropmarks + \ifzwpl@noBboxes \else \AtBeginDocument{\zwpl@setboxex}\fi +\fi + +\def\noBboxes{\def\zwpl@setboxex{}} +\@onlypreamble\noBboxes + +% Two digits +\def\zwpl@num#1{\ifnum #1<10 0\fi \the#1} + +% Date of TeXing in PDF format (without parentheses and D:) +\def\SetTeXingDate#1{\xdef#1{\the\year\zwpl@num\month\zwpl@num\day}} +\SetTeXingDate\DateOfTeXing + +% Time of TeXing, you can modify Date of TeXing by: +% \edef\DateOfTeXing{\DateOfTeXing\TimeOfTeXing} +\count@=\time \divide\count@ by 60 +\edef\@temp{\zwpl@num\count@}% +\multiply\count@ by -60 \advance\count@ by \time +\edef\TimeOfTeXing{\@temp\zwpl@num\count@}% + +% Default version of the modification date +\def\zwpl@modt{(D:\DateOfTeXing\TimeOfTeXing)} + +% PDF info + PDF/X-1a +\def\SetPDFminorversion#1{\ZWifdriver{pdftex}{\pdfminorversion#1 \relax}} +\@onlypreamble\SetPDFminorversion + +\ifzwpl@pdfx + \setkeys{zwpl}{pdfminorversion=3} + \let\SetPDFminorversion\@gobble +\fi + +\ifcat$\zwpl@pdfminorversion$ \else \ZWifdriver{pdftex}{\pdfminorversion3 \relax}\fi +\def\zwpl@pdfxinfo{} +\ifzwpl@pdfx + \def\zwpl@pdfxinfo{ /GTS_PDFXVersion (PDF/X-1:2001) /GTS_PDFXConformance (PDFX-1a:2001)} + \ifcat$\zwpl@ICCfile$ \else + \ifcase\zwpl@Driver + \or + \immediate\pdfobj stream attr{/N 4} file{\zwpl@ICCfile} + \edef\zwpl@iccobj{\the\pdflastobj} + \fi + \fi +\fi + +\edef\zwpl@pdftitle{\zwpl@title} +\ifcat$\zwpl@pdftitle$ + \ifzwpl@pdfx + \ifcase\zwpl@Driver + \or + \pdfinfo{\zwpl@pdfinfo} + \or + \ifxetex \def\zwpl@crt{XeTeX}\else \def\zwpl@crt{TeX+dvipdfm}\fi + \edef\zwpl@pdfcrt{ /Creator (\zwpl@crt) } + \special{pdf:docinfo << \zwpl@pdfmoddate \zwpl@pdfcrt \zwpl@pdfxinfo >>} + \fi + \fi +\else + \edef\zwpl@pdftitle{/Title (\zwpl@pdftitle)} + \ifcat$\zwpl@author$\def\zwpl@pdfauthor{}\else + \edef\zwpl@pdfauthor{ /Author (\zwpl@author)}\fi + \ifcat$\zwpl@subject$\def\zwpl@pdfsubject{}\else + \edef\zwpl@pdfsubject{ /Subject (\zwpl@subject)}\fi + \ifcat$\zwpl@keywords$\def\zwpl@pdfkeywords{}\else + \edef\zwpl@pdfkeywords{ /Keywords (\zwpl@keywords)}\fi + \edef\zwpl@pdfcreationdate{ /CreationDate \zwpl@modt} + \edef\zwpl@pdfmoddate{ /ModDate \zwpl@modt} + \ifcase\zwpl@Driver + \or + \pdfinfo{\zwpl@pdftitle \zwpl@pdfauthor \zwpl@pdfsubject \zwpl@pdfkeywords \zwpl@pdfxinfo} + \or + \ifxetex \def\zwpl@crt{XeTeX}\else \def\zwpl@crt{TeX+dvipdfm}\fi + \edef\zwpl@pdfcrt{ /Creator (\zwpl@crt) } + \special{pdf:docinfo << \zwpl@pdftitle \zwpl@pdfauthor \zwpl@pdfsubject \zwpl@pdfkeywords + \zwpl@pdfmoddate \zwpl@pdfcrt \zwpl@pdfxinfo >>} + \else + \def\zwpl@pdfcrt{ /Creator (TeX+dvips) } + \special{ps:[ \zwpl@pdftitle \zwpl@pdfauthor \zwpl@pdfsubject \zwpl@pdfkeywords + \zwpl@pdfcreationdate \zwpl@pdfmoddate \zwpl@pdfcrt /DOCINFO pdfmark} + \fi +\fi + +% Catalog entry for PDF/X +\ifzwpl@pdfx + \ifx\zwpl@iccobj\undefined + \def\zwpl@profile{} + \else + \def\zwpl@profile{ /DestOutputProfile \zwpl@iccobj\space 0 R} + \fi + \def\zwpl@catalog{/OutputIntents [ << + /Type/OutputIntent + /S/GTS_PDFX + /OutputCondition (\zwpl@OutputCondition) + /OutputConditionIdentifier (\zwpl@OutputConditionIdentifier) + /RegistryName (http://www/color.org)\zwpl@profile + >> ]} + \ifcase\zwpl@Driver + \or + \pdfcatalog{\zwpl@catalog} + \or + \special{pdf: put @catalog <<\zwpl@catalog>>} + \fi +\fi + +% Page margins \ifcat$\zwpl@margins$ \else \setkeys{zwpl}{topmargin=\zwpl@margins,botmargin, leftmargin=\zwpl@margins,rightmargin=\zwpl@margins} @@ -380,8 +602,114 @@ \def\UserTopMargin{\zwpl@topmargin} \def\UserBotMargin{\zwpl@botmargin} -% Handle cropmarks +% Handling color, needed in several cases +\ifzwpl@redefinetocmyk \zwpl@redefineblacktrue \fi +\def\zwpl@next{} +\def\zwpl@reqclr{\def\zwpl@next{\RequirePackage{color}}} +\expandafter\ifx\csname definecolor\endcsname\relax + \ifzwpl@color \zwpl@reqclr \fi + \ifzwpl@cropmarks \ifzwpl@nobleedclip \else \zwpl@reqclr \fi \fi + \ifzwpl@redefineblack \zwpl@reqclr \fi + \ifzwpl@overprint \zwpl@reqclr \fi +\fi +\zwpl@next +\expandafter\ifx\csname definecolor\endcsname\relax \else + \definecolor{cmykblack}{cmyk}{0,0,0,1} + \definecolor{grblack}{gray}{0} + \ifzwpl@redefineblack + \definecolor{black}{cmyk}{0,0,0,1}\color{black} + \fi + \definecolor{cmykred}{cmyk}{0,1,1,0} + \definecolor{cmykgreen}{cmyk}{1,0,1,0} + \definecolor{cmykblue}{cmyk}{1,1,0,0} + \definecolor{rgbred}{rgb}{1,0,0} + \definecolor{rgbgreen}{rgb}{0,1,0} + \definecolor{rgbblue}{rgb}{0,0,1} + \ifzwpl@redefinetocmyk + \definecolor{red}{cmyk}{0,1,1,0} + \definecolor{green}{cmyk}{1,0,1,0} + \definecolor{blue}{cmyk}{1,1,0,0} + \fi +\fi +% Black overprint user macros +\DeclareRobustCommand\SetOverprint{\zwpl@optrue \zwpl@setop \ignorespaces} +\DeclareRobustCommand\SetKnockout{\zwpl@opfalse \zwpl@setop \ignorespaces} +\DeclareRobustCommand\textoverprint[1]{{\SetOverprint#1}} +\DeclareRobustCommand\textknockout[1]{{\SetKnockout#1}} + +% Black overprint implementation +\let\zwpl@setop\relax +\let\zwpl@resetop\relax +\newif\ifzwpl@op + +\ifzwpl@overprint +\ifcase\zwpl@Driver +\or % pdftex + \AtBeginDocument{% + \immediate\pdfobj{<< /Type /ExtGState /op false /OP false /OPM 0 >>} + \edef\op@off{\the\pdflastobj} + \immediate\pdfobj{<< /Type /ExtGState /op true /OP true /OPM 1 >>} + \edef\op@on{\the\pdflastobj} + \immediate\pdfobj{ << % + /GSko \op@off\space 0 R % + /GSop \op@on\space 0 R >>} + \edef\@extgs{\the\pdflastobj} + \edef\next{\global\noexpand\pdfpageresources={\the\pdfpageresources + \space /ExtGState \@extgs\space 0 R }} + \next + } + % macros for setting and resetting the overprint state + \def\zwpl@setop{\zwpl@resetop + \aftergroup\zwpl@resetop} + \def\zwpl@resetop{% + \ifzwpl@op + \pdfliteral direct {/GSop gs}% + \else + \pdfliteral direct {/GSko gs}% + \fi + } +\or % xetex + \iffalse % disabled because it does not work + \special{pdf: object @opoff << /Type /ExtGState /op false /OP false /OPM 0 >>} + \special{pdf: object @opon << /Type /ExtGState /op true /OP true /OPM 1 >>} + \special{pdf: object @extgs << /GSko @opoff 0 R /GSop @opon 0 R >>} + \special{pdf: put @resources << /ExtGState @extgs 0 R >>} + % macros for setting and resetting the overprint state + \def\zwpl@setop{\zwpl@resetop + \aftergroup\zwpl@resetop} + \def\zwpl@resetop{% + \ifzwpl@op + \special{pdf: content /GSop gs}% + \else + \special{pdf: content /GSko gs}% + \fi + } + \else + \def\zwpl@setop{% + \PackageWarningNoLine{zwpagelayout}{Overprint not yet supported in (x)dvipdfm(x)}} + \let\zwpl@resetop\zwpl@setop + \fi % iffalse +\else % dvips + \def\zwpl@setop{\zwpl@resetop + \aftergroup\zwpl@resetop} + \def\zwpl@resetop{% + \ifzwpl@op + \special{ps:true setoverprint}% + \else + \special{ps:false setoverprint}% + \fi + } +\fi +\SetKnockout +\else + \def\zwpl@setop{\global\let\zwpl@setop\relax + \PackageWarningNoLine{zwpagelayout}{Use the "overprint" option to enable overprint.}} +\fi + + + +% Handle cropmarks \newdimen\zwpl@low \zwpl@low 1in \advance\zwpl@low\topmargin \advance\zwpl@low \headheight @@ -391,11 +719,6 @@ \advance\zwpl@low -\paperheight \ifzwpl@cropmarks - \ifzwpl@color - \RequirePackage{color} - \else \ifzwpl@nobleedclip \else - \RequirePackage{color} - \fi \fi \let\zwpl@pagestyle\pagestyle \let\zwpl@thispagestyle\thispagestyle \def\pagestyle{\let\zwpl@next\zwpl@pagestyle \zwpl@testps} @@ -404,14 +727,16 @@ \def\zwpl@testps#1{\@ifundefined{zwpl@ps@#1}{\zwpl@patchps{#1}}{}\zwpl@next{#1}} -\def\zwpl@patchps#1{\expandafter\let\csname zwpl@ps@#1\expandafter\endcsname\csname ps@#1\endcsname - \expandafter\def\csname ps@#1\endcsname{\csname zwpl@ps@#1\endcsname \zwpl@patchfoot}} +\def\zwpl@patchps#1{\global\expandafter\let\csname zwpl@ps@#1\expandafter\endcsname\csname ps@#1\endcsname + \expandafter\gdef\csname ps@#1\endcsname{\csname zwpl@ps@#1\endcsname \zwpl@patchfoot}} \def\zwpl@patchfoot{\let\zwpl@oddfoot\@oddfoot \let\zwpl@evenfoot\@evenfoot \def\@oddfoot{\zwpl@cropbox\zwpl@oddfoot}% \def\@evenfoot{\zwpl@cropbox\zwpl@evenfoot}} -\def\zwpl@cropbox{\rlap{% Some parameters may be changed within the document +% We must use the knockout mode in the cropmarks (added 2010-12-21) +\def\zwpl@cropbox{{\ifzwpl@overprint\SetKnockout\fi + \rlap{% Some parameters may be changed within the document \raisebox{\zwpl@low}[\z@][\z@]{\everyvbox{}\offinterlineskip\boxmaxdepth\z@ \hskip -\hoffset \hskip -1in \hskip - \ifodd\c@page \oddsidemargin \else \evensidemargin \fi @@ -434,7 +759,7 @@ \normalfont \fontsize{10}{10}\selectfont \csname cropmarkstyle@\zwpl@cropmarkstyle\endcsname }% -}}} +}}}} \ifzwpl@cropmarks \zwpl@patchfoot \fi @@ -591,13 +916,22 @@ \def\zwpl@Hreflect{\zwpl@calcshift\zwpl@Hshift\hsize \pdfliteral{-1 0 0 1 \the\zwpl@Hshift\space 0 cm}} -\def\zwpl@Vreflect{\zwpl@calcshift\zwpl@Vshift\vsize +\def\zwpl@Vreflect{\@tempdima\vsize + \advance\@tempdima-\topmargin + \zwpl@calcshift\zwpl@Vshift\@tempdima \pdfliteral{1 0 0 -1 0 -\the\zwpl@Vshift\space cm}} +% (x)dvipdfm(x) version, modifies bop and eop +\def\zwpl@XHreflect{\zwpl@calcshift\zwpl@Hshift\paperwidth + \special{pdf: bop q -1 0 0 1 \the\zwpl@Hshift\space 0 cm}\special{pdf: eop Q}} + +\def\zwpl@XVreflect{\zwpl@calcshift\zwpl@Vshift\paperheight + \special{pdf: bop q 1 0 0 -1 0 \the\zwpl@Vshift\space cm}\space{pdf: eop Q}} + % dvips version (modifies bop-hook) \def\zwpl@psreflect#1#2#3#4{\zwpl@calcshift#3#4 \special{! userdict begin - userdict /bop-hook known {bop-hook load cvx /ZW#1-hook exch def} if + userdict /bop-hook known {/bop-hook load cvx /ZW#1-hook exch def} if /bop-hook { [#2] concat userdict /ZW#1-hook known {ZW#1-hook} if |