• No results found

Relative Viewport for Graphics Inclusion ∗

N/A
N/A
Protected

Academic year: 2021

Share "Relative Viewport for Graphics Inclusion ∗"

Copied!
7
0
0

Bezig met laden.... (Bekijk nu de volledige tekst)

Hele tekst

(1)

Relative Viewport for Graphics Inclusion

Boris Veytsman 2011/08/27, v1.0

Abstract

The package adds a new keyword rviewport to the graphicx package specifiying Relative Viewport for graphics inclusion: a window defined by the given fractions of the natural width and height of the image.

Contents

1 User Interface 2

2 Examples 2

3 Implementation 5

3.1 Declarations . . . . 5 3.2 The New Key . . . . 5 3.3 The Last Words . . . . 6

Boris Veytsman, 2011. E-mail: borisv@lk.net c

This work was partially supported by The Food and Agriculture Organization of the United

Nations

(2)

1 User Interface

Package graphicx provides a useful keyword viewport which allows to show just a part of an image. However, one needs to put there the actual coordinates of the viewport window. Sometimes it is useful to have relative coordinates as fractions of natural size. For example, one may want to print a large image on a spread, putting a half on a verso page, and another half on the next recto page. For this one would need a viewport occupying exactly one half of the file’s bounding box, whatever the actual width of the image may be.

Here we define the new option rviewport for Relative Viewport. It works like this. Suppose the image has the bounding box x ll , y ll , x ur , y ur . We give four numbers ξ ll , η ll , ξ ur , η ur , and the viewport coordinates become

x 0 ll = x ll + ξ ll ∆ x

y 0 ll = y ll + η lly x 0 ur = x ll + ξ ur ∆ x

y 0 ur = y ll + η ury where

x = x ur − x ll

∆ y = y ur − y ll

This means that the left half of the image can be defined as rviewport = 0 0 0.5 1, and the right half can be defined as rviewport = 0.5 0 1 1.

The package may be loaded before or after graphicx package.

2 Examples

\includegraphics[rviewport=0 0 1 1,clip]{vitruvian}

(3)

\includegraphics[rviewport=0 0 0.5 1,clip]{vitruvian}

\includegraphics[rviewport=0.5 0 1 1,clip]{vitruvian}

\includegraphics[rviewport=0 0 0.5 0.5,clip]{vitruvian}

(4)

\includegraphics[rviewport=0 0.5 1 1,clip]{vitruvian}

\includegraphics[rviewport=0 0 1 0.5,clip]{vitruvian}

\includegraphics[rviewport=0.4 0.6 0.6 0.9,clip]{vitruvian}

(5)

3 Implementation

3.1 Declarations

We start with declaration, who we are:

1 h*stylei

2 \NeedsTeXFormat{LaTeX2e}

3 \ProvidesPackage{rviewport}

4 [2011/08/27 v1.0 Relative viewport for graphics inclusion]

The package graphicx loads keyval, but in case we are loaded before graphicx we require it here:

5 \RequirePackage{keyval}

3.2 The New Key

We add a new key for the graphicx package:

6 \define@key{Gin}{rviewport}

7 {\let\Gin@viewport@code\Gin@rviewport\Gread@parse@rvp#1 \\}

\Gread@parse@rvp We parse four numbers into the corresponding macros:

8 \def\Gread@parse@rvp#1 #2 #3 #4 #5\\{%

9 \def\Gin@vllx{#1}%

10 \def\Gin@vlly{#2}%

11 \def\Gin@vurx{#3}%

12 \def\Gin@vury{#4}}%

\Gin@rviewport And the viewport code. Note that pdftex.def relies on the values of \Gin@v...

macros, so we redefine them as well.

13 \def\Gin@rviewport{%

14 \let\Gin@ollx\Gin@llx

15 \let\Gin@olly\Gin@lly

16 \let\Gin@ourx\Gin@urx

17 \let\Gin@oury\Gin@ury

18 \Gin@nat@width\Gin@urx\p@

19 \advance\Gin@nat@width-\Gin@llx\p@

20 \Gin@nat@height\Gin@ury\p@

21 \advance\Gin@nat@height-\Gin@lly\p@

22 \dimen@\Gin@vurx\Gin@nat@width

23 \edef\Gin@vurx{\strip@pt\dimen@}%

24 \advance\dimen@\Gin@llx\p@

25 \edef\Gin@urx{\strip@pt\dimen@}%

26 \dimen@\Gin@vury\Gin@nat@height

27 \edef\Gin@vury{\strip@pt\dimen@}%

28 \advance\dimen@\Gin@lly\p@

29 \edef\Gin@ury{\strip@pt\dimen@}%

30 \dimen@\Gin@vllx\Gin@nat@width

31 \edef\Gin@vllx{\strip@pt\dimen@}%

32 \advance\dimen@\Gin@llx\p@

(6)

33 \edef\Gin@llx{\strip@pt\dimen@}%

34 \dimen@\Gin@vlly\Gin@nat@height

35 \edef\Gin@vlly{\strip@pt\dimen@}%

36 \advance\dimen@\Gin@lly\p@

37 \edef\Gin@lly{\strip@pt\dimen@}}

3.3 The Last Words

38 h/stylei

(7)

Index

Numbers written in italic refer to the page where the corresponding entry is de- scribed; numbers underlined refer to the code line of the definition; numbers in roman refer to the code lines where the entry is used.

Symbols

\\ . . . . 7, 8 A

\advance . . . . 19,

21, 24, 28, 32, 36 D \define@key . . . . 6

\dimen@ . . 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37 E \edef . . . . 23, 25, 27, 29, 31, 33, 35, 37 G \Gin@llx 14, 19, 24, 32, 33 \Gin@lly 15, 21, 28, 36, 37 \Gin@nat@height . . . . . . . 20, 21, 26, 34 \Gin@nat@width . . . . . . . . 18, 19, 22, 30 \Gin@ollx . . . . 14

\Gin@olly . . . . 15

\Gin@ourx . . . . 16

\Gin@oury . . . . 17

\Gin@rviewport . . . 7, 13 \Gin@urx . . . . 16, 18, 25 \Gin@ury . . . . 17, 20, 29 \Gin@viewport@code . . 7

\Gin@vllx . . . . 9, 30, 31 \Gin@vlly . . . 10, 34, 35 \Gin@vurx . . . 11, 22, 23 \Gin@vury . . . 12, 26, 27 \Gread@parse@rvp . 7, 8 L \let . . . 7, 14, 15, 16, 17 P \p@ . . . . . 18, 19, 20, 21, 24, 28, 32, 36 R \RequirePackage . . . . 5

S

\strip@pt 23, 25, 27,

29, 31, 33, 35, 37

Referenties

GERELATEERDE DOCUMENTEN

When a user stream points to a token list rather than a TEX stream, any material to be written must be written to our temporary file and read back in to apply the same expansion

These commands use the same optional arguments as \scalerel and \stretchrel to constrain the width and/or the aspect ratio, respectively, of the manipulated object.. As was mentioned

The statistics package can compute and typeset statistics like frequency tables, cumulative distribution functions (increasing or decreasing, in frequency or absolute count

References are given below, but the essence is that the metadata is stored in an XML file, and this XML stream is then embedded in the file to which it applies.. How you create this

This would declare a default rule, such that all unknown extensions would be treated as EPS files, and the graphic file would be read for a BoundingBox com- ment.. If the driver

\KV@Gin@scale If the scaling is being handled externally, wrap \includegraphics in the inter- nal form of \scalebox, otherwise locally define \Gin@req@sizes to calculate the

The names used in the named model are those suggested by Jim Hafner in his colordvi and foiltex packages, and implemented originally in the color.pro header file for the dvips

\emojicitep{wakefield1998retracted, facepalm, roll-eyes, shrug} renders as (Wakefield et al., 1998 emojicite does not support more than two emojis.)... If you use the latexmk tool,