summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/overpic/overpic.sty
blob: 59cc29ad622c998f2d5d26c6ac1b7175fa02ce48 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107

% overpic.sty 

% Copyright  1999-2010 Rolf Niepraschk, Rolf.Niepraschk@gmx.de
% This program can be redistributed and/or modified under the terms
% of the LaTeX Project Public License Distributed from CTAN
% archives in directory macros/latex/base/lppl.txt; either
% version 1 of the License, or any later version. 

%  \changes{v0.53}{2010/09/13}{reset the graphics parameter}
%  \changes{v0.51}{1999/03/02}{New (LPPL) license}
%  \changes{v0.52}{1999/07/04}{Correction of wrong height calculation 
%                              (if depth != 0)}


\def\fileversion{v0.53}
\def\filedate{2010/09/13}% 

\ProvidesPackage{overpic}
    [\filedate\space\fileversion\space\space Overwriting graphics]  
                  
\NeedsTeXFormat{LaTeX2e}

\typeout{Package: overpic \fileversion\space <\filedate> (RN)}

\newcommand\OVP@scale{}

\DeclareOption{percent}{\renewcommand\OVP@scale{100}}
\DeclareOption{permil}{\renewcommand\OVP@scale{\@m}}
\DeclareOption{abs}{\renewcommand\OVP@scale{\z@}}

\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{graphicx}}

\ExecuteOptions{percent}

\ProcessOptions

\RequirePackage{graphicx,epic}

\newif\ifGin@grid 

\define@key{Gin}{grid}[true]{\lowercase{\Gin@boolkey{#1}}{grid}}
\define@key{Gin}{tics}{\count@=#1}
\define@key{Gin}{unit}{\setlength{\@tempdima}{#1}}

\ifnum\OVP@scale>\z@%
  \ifnum\OVP@scale=\@m%
    \typeout{overpic: relative positioning in permil}% 
  \else%
    \typeout{overpic: relative positioning in percent}% 
  \fi%  
  \newcommand\OVP@calc{%  
    \ifnum\@tempcnta>\@tempcntb%
      \divide\@tempcnta by \OVP@scale%
      \setlength\unitlength{\@tempcnta sp}% 
      \@tempcnta=\OVP@scale%
      \divide\@tempcntb by \unitlength%
    \else%
      \divide\@tempcntb by \OVP@scale%
      \setlength\unitlength{\@tempcntb sp}%  
      \@tempcntb=\OVP@scale%
      \divide\@tempcnta by \unitlength%
    \fi%
    \ifnum\count@=\z@% 
      \count@=\OVP@scale\divide\count@ by 10 %
    \fi%
  }%  
\else%           
  \typeout{overpic: absolute positioning in \unitlength}%
  \newcommand\OVP@calc{%
    \setlength{\unitlength}{\@tempdima}%
    \divide\@tempcnta by \unitlength%
    \divide\@tempcntb by \unitlength% 
    \ifnum\count@=\z@\count@=10\fi%  
  }%  
\fi%  
 
\newenvironment{overpic}[2][]{%
  \sbox{\z@}{\includegraphics[#1]{#2}}%
  \settodepth{\@tempcnta}{\usebox{\z@}}%
  \settoheight{\@tempcntb}{\usebox{\z@}}%
  \advance\@tempcntb\@tempcnta%
  \settowidth{\@tempcnta}{\usebox{\z@}}%
  \setlength{\@tempdima}{\unitlength}%
  \count@=\z@\Gin@gridfalse\setkeys{Gin}{#1}% 
%
  \OVP@calc%
%  
  \begin{picture}(\@tempcnta,\@tempcntb)%
    \put(0,0){\makebox(0,0)[bl]{\usebox{\z@}}}%
    \ifGin@grid%
      \put(0,0){\normalfont\fontsize\@viipt\@viiipt\selectfont%
        \grid(\@tempcnta,\@tempcntb)(\count@,\count@)[0,0]}%
    \fi%  
    % reset the graphics parameter
    \let\Gin@outer@scalex\relax
    \let\Gin@outer@scaley\relax
    \let\Gin@angle\relax
    \let\Gin@ewidth\Gin@exclamation
    \let\Gin@eheight\Gin@ewidth
    \def\Gin@scalex{1}
    \let\Gin@scaley\Gin@exclamation
}{% 
  \end{picture}%
}% 

\endinput