diff options
author | Karl Berry <karl@freefriends.org> | 2017-02-08 22:19:00 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2017-02-08 22:19:00 +0000 |
commit | 6e51339ef42840e5c37785cc48d3b5ad525cead3 (patch) | |
tree | d02fe5cdd1ae504c167470fb7b95ca84a29a9f12 /Master/texmf-dist | |
parent | 77b2f02d23f8f97c8c131011f8ce1bc82c58a360 (diff) |
bxpapersize (8feb17)
git-svn-id: svn://tug.org/texlive/trunk@43169 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r-- | Master/texmf-dist/doc/latex/bxpapersize/LICENSE | 8 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/bxpapersize/README.md | 81 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/bxpapersize/bxpapersize.sty | 249 |
3 files changed, 259 insertions, 79 deletions
diff --git a/Master/texmf-dist/doc/latex/bxpapersize/LICENSE b/Master/texmf-dist/doc/latex/bxpapersize/LICENSE index 49f803e083e..8ada757fbc8 100644 --- a/Master/texmf-dist/doc/latex/bxpapersize/LICENSE +++ b/Master/texmf-dist/doc/latex/bxpapersize/LICENSE @@ -1,12 +1,6 @@ -$BK\%=%U%H%&%'%"$O(B MIT $B%i%$%;%s%9$N2<$GG[I[$5$l$^$9!#(B -$BCx:n8"$O:n<T$G$"$k!VH,EP(B $B?rG7!JJLL>(B ZR$B!K!W$KB0$7$^$9!#(B -$B$^$?K\%=%U%H%&%'%"$OL5J]>Z$G$9!#(B - -This software is distributed under the MIT License. - The MIT License -Copyright (c) 2016 Takayuki YATO (aka. "ZR") +Copyright (c) 2017 Takayuki YATO (aka. "ZR") Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Master/texmf-dist/doc/latex/bxpapersize/README.md b/Master/texmf-dist/doc/latex/bxpapersize/README.md index f884ec0f5fa..cad12f7d8ed 100644 --- a/Master/texmf-dist/doc/latex/bxpapersize/README.md +++ b/Master/texmf-dist/doc/latex/bxpapersize/README.md @@ -5,8 +5,14 @@ LaTeX: To synchronize output paper size with layout paper size As is well known, in LaTeX processing layout paper size specified by document class options is not automatically applied to output paper -size. This package enables LaTeX authors to synchronize both kinds of -paper sizes. +size. By employing this package, authors can make output paper size +be identical to layout paper size. They can also set output paper size +to arbitrary values. + +It should be noted that there are many packages that try to synchronize +paper sizes, possibly in a slightly different manner. This package +allows authors to decide whether the setting made by this package +should have higher or lower priority over the settings made by others. ### System requirement @@ -42,7 +48,7 @@ The available options are described hereafter. useful to resolve conflict caused by some packages depending on the bxpapersize package. Note that once `disabled` is used there is no way to enable the functionality. - + * `nodvidriver`: A synonym for `disabled`. #### Priority @@ -51,20 +57,34 @@ The available options are described hereafter. ‘papersize’ specials issued by others. The set of valid values is: - `low`: Priotizes specials by others. - - `middle` (default): Does not care about priority. + - `middle`/`default` (default): Does not care about priority. - `high`: Priotizes specials by this package. + * `olddvips`: Must be specified when you use dvips older than that + included in TeX Live 2017, so as to make the `priority` option + work correctly. #### Other options -Any key-value pairs that are valid in `\bxpapersizesetup` can be used +Any key-value pairs that are valid in `\papersizesetup` can be used as package options. % to begin with deactivated state \usepackage[active=false]{bxpapersize} +Note that the default values of the `\papersizesetup` command are also +applied when the package is loaded. For example, `size=real` will be +in effect when this package is loaded without the `size` option key. + ### Usage -You can change the settings of this package using `\bxpapersizesetup` +Once the package is loaded, the output paper size will be adjusted, +respecting the settings given by the package options. By default, the +output papersize will be made identical to the layout paper size. + + % For many cases, it's enough. + \usepackage{bxpapersize} + +You can change the settings of this package using `\papersizesetup` command, invoked as follows: \bxpapersizesetup[<key>=<value>,...] @@ -72,18 +92,55 @@ command, invoked as follows: The available keys are listed below: * `active=true|false`: Temporarily activates/deactivates the function - of this package. Note that, however, what happens about paper size - synchronization when activation settings are changed in the midst - of documents differs among TeX engines and/or DVI drivers. Thus - this should be employed only by advanced users. - + of this package. + * `size=<value>`: Decides what the output paper size should be. + Available values are: + - `real`: The output should be equal to the layout paper size + given by `\paperwidth/height`, except that the stock paper size + given by `\stockwidth/height` will be employed instead when + it is available. + - `real*`: The output should be equal to the layout paper size, + even if the stock paper size is available. + - `{<width>,<height>}`: The output should be equal to the + specified values. + - `<papersize-name>`: The output should be equal to the given + size. The set pf available paper-size names is the same as the + [geometry package] and is listed below: + a0paper--a6paper, b0paper--b6paper, c0paper--c6paper, b0j--b6j, + ansiapaper--ansiepaper, letterpaper, legalpaper, executivepaper, + screen. + - `landscape`, `truedimen`: These are used in combination with + `<papersize-name>` options, and have the same meaning as in the + geometry package. + - `box`: The output should be the actual size of the TeX box + to be shipped out. It is provided for advanced users. + +[geometry package]: https://www.ctan.org/pkg/geometry + +Note that, however, what happens about output paper size when some +settings are changed in the midst of pages differs among TeX engines +and/or DVI drivers. Thus such usage should be employed only by advanced +users. + +The comamnd `\bxpapersizesetup` is a synonym for `\papersizesetup`, +so as to cope with command name conflict. Namely, `\papersizesetup` +will be not (re)defined if the command of that name is already defined, +but `\bxpapersizesetup` will be always provided. Revision History ---------------- + * Version 0.3 ‹2017/02/08› + - As to `size=real`, the stock size becomes taken into account, + and the new value `real*` is provided. + - Make `nodvidriver` synonym for `disabled`. + - Make `\papersizesetup` synonym for `\bxpapersizesetup`. + - Add `olddvips`. + - Support `size=<papersize-name>`. together with `landscape` and + `truedimen`. * Version 0.2 ‹2016/03/26› - The first public version. -------------------- Takayuki YATO (aka. "ZR") -http://zrbabbler.sp.land.to/ +https://github.com/zr-tex8r diff --git a/Master/texmf-dist/tex/latex/bxpapersize/bxpapersize.sty b/Master/texmf-dist/tex/latex/bxpapersize/bxpapersize.sty index e15bf32cc84..d5cd3b0d4b1 100644 --- a/Master/texmf-dist/tex/latex/bxpapersize/bxpapersize.sty +++ b/Master/texmf-dist/tex/latex/bxpapersize/bxpapersize.sty @@ -2,7 +2,7 @@ %% package declaration \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{bxpapersize}[2016/03/26 v0.2] +\ProvidesPackage{bxpapersize}[2017/02/08 v0.3] %% preparation \def\bxpr@pkgname{bxpapersize} @@ -10,32 +10,40 @@ %--------------------------------------- options -%% 'disabled' +% Note: Only non-key-value global options should be picked. + +%% 'disabled' / 'nodvidriver' \chardef\bxpr@disabled=0 \DeclareOption{disabled}{% \chardef\bxpr@disabled=1 } +\DeclareOption{nodvidriver}{% + \chardef\bxpr@disabled=1 } +%% 'olddvips' +\chardef\bxpr@olddvips=0 +\DeclareOption{olddvips}{% + \chardef\bxpr@olddvips=1 } %% keyval \@onlypreamble\bxpr@kvopt -\let\bxpr@kvopt\@empty +\let\bxpr@kvopt\@empty % key-value option list \DeclareOption*{% \edef\bxpr@kvopt{\bxpr@kvopt,\CurrentOption}} \ProcessOptions* %% If 'disabled' is given, quit now. \ifnum\bxpr@disabled>\z@ + \providecommand*\papersizesetup{\bxpapersizesetup}% \newcommand*\bxpapersizesetup[1]{}% \expandafter\endinput\fi\relax %--------------------------------------- general %% load packages -\RequirePackage{xkeyval} +\RequirePackage{xkeyval}[2008/08/10]% v2.6 \RequirePackage{atbegshi} \RequirePackage{ifpdf,ifxetex,ifluatex,ifvtex} %% variables \newdimen\bxpr@dima -\newif\ifbxpr@active \let\bxpr@width\relax \let\bxpr@height\relax @@ -83,19 +91,30 @@ \let\bxpr@mode\bxpr@mode@@pdfmode \fi +%% \bxpr@csletcs{<CSa>}{<CSb>} +\def\bxpr@csletcs#1#2{% + \expandafter\let\csname#1\expandafter\endcsname\csname#2\endcsname} + %--------------------------------------- parameters %% constants \chardef\bxpr@priority@@low=0 \chardef\bxpr@priority@@middle=1 +\chardef\bxpr@priority@@default=1 \chardef\bxpr@priority@@high=2 +\ifnum\bxpr@olddvips>\z@ + \chardef\bxpr@priority@@low=2 + \chardef\bxpr@priority@@high=0 +\fi \chardef\bxpr@size@@real=0 %'real', use \paperwidth/height -\chardef\bxpr@size@@box=1 %'box', use shipout box size -\chardef\bxpr@size@@boxS=2 %'box*' -\chardef\bxpr@size@@custom=3 % size explicitly given +\chardef\bxpr@size@@realS=1 %'real*' +\chardef\bxpr@size@@box=2 %'box', use shipout box size +\chardef\bxpr@size@@boxS=3 %'box*' +\chardef\bxpr@size@@custom=4 % size explicitly given %% variables -\let\bxpr@priority\bxpr@priority@@middle +\newif\ifbxpr@needs@reset@size +\let\bxpr@priority\bxpr@priority@@default \let\bxpr@size\bxpr@size@@real \def\bxpr@cs@width{\z@}% custom page width \def\bxpr@cs@height{\z@}% custom page height @@ -109,28 +128,98 @@ \PackageError\bxpr@pkgname {Invalid value for '#1': #2}% \@ehc} +\def\bxpr@err@ivkey{% + \begingroup \let\MessageBreak\relax % freeze + \let\bxpr@tmpb\@empty + \@for\bxpr@tmpa:=\XKV@rm\do{% + \edef\bxpr@tmpb{\bxpr@tmpb\MessageBreak\@spaces\bxpr@tmpa}}% + \PackageError\bxpr@pkgname + {Unknown parameter(s)\bxpr@tmpb\MessageBreak + are found in the given list} + \endgroup} %% 'active' -\define@boolkey+{bxpr}{active}% - {\@nameuse{bxpr@active#1}}% +\define@boolkey+[bxpr]{prm}{active}[true]{}% {\bxpr@ivval{active}{#1}} -\bxpr@activetrue +\bxpr@prm@activetrue %% 'priority' -\define@choicekey*+{bxpr}{priority}[\bxpr@tmpa\bxpr@tmpb]% - {low,middle,high}% - {\bxpr@set@priority}% +\define@choicekey*+[bxpr]{prm}{priority}% + {low,middle,default,high}% + {\bxpr@set@priority{#1}}% {\bxpr@ivval{priority}{#1}} -\def\bxpr@set@priority{% - \chardef\bxpr@priority\bxpr@tmpb\relax} +\def\bxpr@set@priority#1{% + \bxpr@csletcs{bxpr@priority}{bxpr@priority@@#1}} \AtBeginDocument{% - \def\bxpr@set@priority{\bxpr@err@nlprm{priority}}} + \def\bxpr@set@priority#1{% invalidate + \bxpr@err@nlprm{priority}}} + +%% 'truedimen' +\define@boolkey+[bxpr]{prm}{truedimen}[true]% + {\bxpr@needs@reset@sizetrue}% + {\bxpr@ivval{truedimen}{#1}} + +%% 'landscape' +\define@boolkey+[bxpr]{prm}{landscape}[true]% + {\bxpr@needs@reset@sizetrue}% + {\bxpr@ivval{landscape}{#1}} %% 'size' -\define@choicekey*+{bxpr}{size}[\bxpr@tmpa\bxpr@tmpb]% - {real,box,box*}% - {\chardef\bxpr@size\bxpr@tmpb\relax}% +\define@choicekey*+[bxpr]{prm}{size}[\bxpr@tmpa\bxpr@tmpb]% + {real,real*,box,box*, + % preset paper sizes + a0paper,a1paper,a2paper,a3paper,a4paper,a5paper,a6paper,% + b0paper,b1paper,b2paper,b3paper,b4paper,b5paper,b6paper,% + c0paper,c1paper,c2paper,c3paper,c4paper,c5paper,c6paper,% + b0j,b1j,b2j,b3j,b4j,b5j,b6j,% + ansiapaper,ansibpaper,ansicpaper,ansidpaper,ansiepaper,% + letterpaper,legalpaper,executivepaper,screen}% + {\def\bxpr@val@size{#1}\bxpr@needs@reset@sizefalse + \ifcase\bxpr@tmpb\relax + \let\bxpr@size\bxpr@size@@real + \or \let\bxpr@size\bxpr@size@@realS + \or \let\bxpr@size\bxpr@size@@box + \or \let\bxpr@size\bxpr@size@@boxS + \or \bxpr@set@size@a(841,1189){mm}% a0paper + \or \bxpr@set@size@a(594,841){mm}% a1paper + \or \bxpr@set@size@a(420,594){mm}% a2paper + \or \bxpr@set@size@a(297,420){mm}% a3paper + \or \bxpr@set@size@a(210,297){mm}% a4paper + \or \bxpr@set@size@a(148,210){mm}% a5paper + \or \bxpr@set@size@a(105,148){mm}% a6paper + \or \bxpr@set@size@a(1000,1414){mm}% b0paper + \or \bxpr@set@size@a(707,1000){mm}% b1paper + \or \bxpr@set@size@a(500,707){mm}% b2paper + \or \bxpr@set@size@a(353,500){mm}% b3paper + \or \bxpr@set@size@a(250,353){mm}% b4paper + \or \bxpr@set@size@a(176,250){mm}% b5paper + \or \bxpr@set@size@a(125,176){mm}% b6paper + \or \bxpr@set@size@a(917,1297){mm}% c0paper + \or \bxpr@set@size@a(648,917){mm}% c1paper + \or \bxpr@set@size@a(458,648){mm}% c2paper + \or \bxpr@set@size@a(324,458){mm}% c3paper + \or \bxpr@set@size@a(229,324){mm}% c4paper + \or \bxpr@set@size@a(162,229){mm}% c5paper + \or \bxpr@set@size@a(114,162){mm}% c6paper + \or \bxpr@set@size@a(1030,1456){mm}% b0j + \or \bxpr@set@size@a(728,1030){mm}% b1j + \or \bxpr@set@size@a(515,728){mm}% b2j + \or \bxpr@set@size@a(364,515){mm}% b3j + \or \bxpr@set@size@a(257,364){mm}% b4j + \or \bxpr@set@size@a(182,257){mm}% b5j + \or \bxpr@set@size@a(128,182){mm}% b6j + \or \bxpr@set@size@a(8.5,11){in}% ansiapaper + \or \bxpr@set@size@a(11,17){in}% ansibpaper + \or \bxpr@set@size@a(17,22){in}% ansicpaper + \or \bxpr@set@size@a(22,34){in}% ansidpaper + \or \bxpr@set@size@a(34,44){in}% ansiepaper + \or \bxpr@set@size@a(8.5,11){in}% letterpaper + \or \bxpr@set@size@a(8.5,14){in}% legalpaper + \or \bxpr@set@size@a(7.25,10.5){in}% executivepaper + \or \bxpr@set@size@a(225,180){mm}% screen + \fi}% {% custom page size ('size={<width>,<height>}') + \def\bxpr@val@size{#1}\bxpr@needs@reset@sizefalse \def\bxpr@tmpa##1,##2,##3\@nil{% \begingroup\setbox\z@\hbox{% \@tempdima##1\relax \@tempdimb##2\relax @@ -140,17 +229,36 @@ \endgroup\bxpr@g@next}% \bxpr@tmpa#1,,\@nil \let\bxpr@size\bxpr@size@@custom} - -%% apply package options -\edef\bxpr@tmpa{% - \noexpand\setkeys{bxpr}{\bxpr@kvopt}% -}\bxpr@tmpa +\def\bxpr@set@size@a(#1,#2)#3{% + \edef\bxpr@tmpa##1##2{% + \ifbxpr@prm@landscape##2\else##1\fi + \ifbxpr@prm@truedimen true\fi #3\relax}% + \bxpr@dima=\bxpr@tmpa{#1}{#2}\edef\bxpr@cs@width{\the\bxpr@dima}% + \bxpr@dima=\bxpr@tmpa{#2}{#1}\edef\bxpr@cs@height{\the\bxpr@dima}% + \let\bxpr@size\bxpr@size@@custom} %--------------------------------------- user interface %%<*> \bxpapersizesetup{<key>=<value>,...} \newcommand*\bxpapersizesetup[1]{% - \setkeys{bxpr}{#1}} + \setkeys*[bxpr]{prm}{#1}% + \ifx\XKV@rm\@empty\else + \bxpr@err@ivkey + \fi + \ifbxpr@needs@reset@size + \edef\bxpr@tmpa{% + \noexpand\setkeys[bxpr]{prm}{size=\bxpr@val@size}% + }\bxpr@tmpa + \fi} +%%<*> \papersizesetup{<key>=<value>,...} +% Synonym for \bxpapersizesetup, declared only if not yet defined. +\providecommand*\papersizesetup{% + \bxpapersizesetup} + +%% apply package options +\edef\bxpr@tmpa{% + \noexpand\bxpapersizesetup{\bxpr@kvopt}% +}\bxpr@tmpa %--------------------------------------- page hook @@ -165,19 +273,20 @@ \the\toks@} \endgroup -%% \bxpr@begindoc@second@hook +%% \bxpr@begindoc@last@hook % Placed after the begin-docuemnt hook. -\def\bxpr@begindoc@second@hook{% - \let\bxpr@begindoc@second@hook\@undefined} +\def\bxpr@begindoc@last@hook{% + \let\bxpr@begindoc@last@hook\@undefined} \g@addto@macro\document{% - \bxpr@begindoc@second@hook} + \bxpr@begindoc@last@hook} %% add hook for every page \g@addto@macro\bxpr@begindoc@first@hook{% \bxDebug{bxpapersize settings:^^J% mode=\the\bxpr@mode^^J% - prioity=\the\bxpr@priority^^J% - size=\the\bxpr@size}% + priority=\the\bxpr@priority^^J% + size=\the\bxpr@size(\bxpr@cs@width,\bxpr@cs@height)% + \ifnum\bxpr@tombow>\z@ [tombow]\fi}% \bxpr@geometry@hack \ifcase\bxpr@mode % dvi \ifcase\bxpr@priority % low @@ -190,7 +299,7 @@ \bxpr@page@process \AtBeginShipoutNext{\bxpr@every@page@hook}}% \AtBeginShipoutFirst{\bxpr@special@chunk} - \or % middle + \or % default \def\bxpr@every@page@hook{% \bxpr@page@process \bxpr@modify@output@box\relax\bxpr@special@chunk}% @@ -210,7 +319,14 @@ \AtBeginShipout{\bxpr@every@page@hook}% \fi} -%% \bxpr@modify@output@box +%% \bxpr@tombow +\chardef\bxpr@tombow=0 +\expandafter\ifx\csname iftombow\expandafter\endcsname + \csname iftrue\endcsname + \chardef\bxpr@tombow=1 +\fi + +%% \bxpr@modify@output@box{<pre>}{<post>} \def\bxpr@modify@output@box#1#2{% \setbox\AtBeginShipoutBox\vbox{% #1\box\AtBeginShipoutBox#2}} @@ -233,7 +349,7 @@ \edef\bxpr@tmpa{% \paperwidth=\the\paperwidth \paperheight=\the\paperheight}% - \expandafter\g@addto@macro\expandafter\bxpr@begindoc@second@hook + \expandafter\g@addto@macro\expandafter\bxpr@begindoc@last@hook \expandafter{\bxpr@tmpa}% }{}} @@ -245,8 +361,13 @@ %% \bxpr@set@page@size{<width>}{<height>} \ifcase\bxpr@mode %dvi \def\bxpr@set@page@size#1#2{% - \bxpr@dima=#1\relax \edef\bxpr@tmpb{\the\bxpr@dima}% - \bxpr@dima=#2\relax \edef\bxpr@tmpb{\bxpr@tmpb,\the\bxpr@dima}% + \begingroup + \bxpr@let@real@mag@to\bxpr@tmpa + \paperwidth=#1\relax \paperwidth=\bxpr@tmpa\paperwidth + \paperheight=#2\relax \paperheight=\bxpr@tmpa\paperheight + \xdef\bxpr@g@next{% + \def\noexpand\bxpr@tmpb{\the\paperwidth,\the\paperheight}}% + \endgroup \bxpr@g@next \bxDebug{papersize=\bxpr@tmpb}% \edef\bxpr@special@chunk{\special{papersize=\bxpr@tmpb}}}% \else %pdf @@ -255,23 +376,28 @@ \bxDebug{papersize=\the\bxpr@pagewidth,\the\bxpr@pageheight}}% \fi +%% \bxpr@let@real@mag@to\CS +\def\bxpr@let@real@mag@to#1{% + \begingroup + \@tempcnta=\mag \advance\@tempcnta100000 + \def\bxpr@tmpa1##1##2##3##4##5\relax{% + \@tempdima=##1##2.##3##4##5\p@}% + \expandafter\bxpr@tmpa\the\@tempcnta\relax + \xdef\bxpr@g@next{% + \def\noexpand#1{\strip@pt\@tempdima}}% + \endgroup \bxpr@g@next} + %% \bxpr@page@process \def\bxpr@page@process{% - \ifbxpr@active + \ifbxpr@prm@active \bxpr@page@process@a \fi} \def\bxpr@page@process@a{% \ifcase\bxpr@size % real - \ifcase\bxpr@mode % dvi - \ifnum\mag=\@m - \bxpr@set@page@size{\paperwidth}{\paperheight}% - \else - \bxpr@apply@mag - \bxpr@set@page@size{\bxpr@width}{\bxpr@height}% - \fi - \or % pdf - \bxpr@set@page@size{\paperwidth}{\paperheight}% - \fi + \bxpr@use@real@size + \bxpr@set@page@size{\bxpr@width}{\bxpr@height}% + \or % real* + \bxpr@set@page@size{\paperwidth}{\paperheight}% \or % box \bxpr@use@box@size \setbox\AtBeginShipoutBox\vbox{% @@ -285,20 +411,23 @@ \bxpr@set@page@size{\bxpr@cs@width}{\bxpr@cs@height}% \fi} -%% \bxpr@apply@mag -\def\bxpr@apply@mag{% +%% \bxpr@use@real@size +\def\bxpr@use@real@size{% + \bxpr@use@real@size@a{width}% + \bxpr@use@real@size@a{height}} +\def\bxpr@use@real@size@a#1{% \begingroup - \ifnum\mag=\@m\else - \@tempcnta=\mag \advance\@tempcnta100000 - \def\bxpr@next1##1##2##3##4##5\relax{% - \def\bxpr@tmpa{##1##2.##3##4##5}}% - \expandafter\bxpr@next\the\@tempcnta\relax - \paperwidth=\bxpr@tmpa\paperwidth - \paperheight=\bxpr@tmpa\paperheight + \bxpr@csletcs{bxpr@tmpa}{paper#1}% + \ifnum\bxpr@tombow>\z@ + \advance\bxpr@tmpa2truein\relax \fi + \bxpr@csletcs{bxpr@tmpb}{stock#1}% + \ifx\bxpr@tmpb\relax\else \ifdim\bxpr@tmpb>\z@ + \bxpr@tmpa\bxpr@tmpb + \fi\fi \xdef\bxpr@g@next{% - \def\noexpand\bxpr@width{\the\paperwidth}% - \def\noexpand\bxpr@height{\the\paperheight}}% + \def\expandafter\noexpand\csname bxpr@#1\endcsname{% + \the\bxpr@tmpa}} \endgroup \bxpr@g@next} %% \bxpr@use@box@size |