summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/typogrid/typogrid.sty
blob: a7a18c53a5bfaea14371a211fd0f290bf92cf25c (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
%%
%% This is file `typogrid.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% typogrid.dtx  (with options: `package')
%% 
%%   typogrid package
%% 
%%   Copyright  2003 Harald Harders
%% 
%%   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.
%% 
%%   h.harders@tu-bs.de
%% 
\def\fileversion{0.10}
\def\filedate{2003/10/30}
\def\docdate{2003/10/30}
\ProvidesPackage{typogrid}[2003/10/29 v\fileversion\space Typographic grid]
\RequirePackage{eso-pic}[2002/11/16]
\RequirePackage{calc}
\RequirePackage{keyval}
\newlength{\tpg@left}%
\newlength{\tpg@top}%
\newlength{\tpg@bottom}%
\newlength{\tpg@gridwidth}%
\newcounter{tpg@bloecke}%
\setcounter{tpg@bloecke}{12}%
\newcommand*\typogridsetup[1]{%
  \expandafter\setkeys\expandafter{typogrid}{#1}}
\define@key{typogrid}{columns}{%
  \setcounter{tpg@bloecke}{#1}%
  \ifnum\arabic{tpg@bloecke}<1
    \PackageError{typogrid}{Less than 1 column given}{You have to
      declare at least 1 column.}%
    \setcounter{tpg@bloecke}{1}%
  \fi
}
\newif\iftpg@draft
\DeclareOption{draft}{\tpg@drafttrue}
\DeclareOption{final}{\tpg@draftfalse}
\DeclareOption*{\expandafter\typogridsetup\expandafter{\CurrentOption}}
\ExecuteOptions{final}
\ProcessOptions\relax
\AtBeginDocument{%
  \iftpg@draft
    \typeout{Typographic grid switched on}%
    \AddToShipoutPicture{%
      \begingroup
      \normalcolor
      \setlength{\unitlength}{1pt}%
      \thinlines
      \setlength{\tpg@top}{\paperheight-1in-\topmargin-\headheight-\headsep}%
      \setlength{\tpg@bottom}{\tpg@top-\textheight}%
      \setlength{\tpg@gridwidth}{\textwidth/\thetpg@bloecke}%
      \@tempcnta=\thetpg@bloecke
      \advance\@tempcnta by 1
      \ifodd\arabic{page}%
        \setlength{\tpg@left}{\oddsidemargin+1in}%
      \else
        \setlength{\tpg@left}{\evensidemargin+1in}%
      \fi
      \put(\strip@pt\tpg@left,\strip@pt\tpg@top){%
        \line(1,0){\strip@pt\textwidth}}%
      \put(\strip@pt\tpg@left,\strip@pt\tpg@bottom){%
        \line(1,0){\strip@pt\textwidth}}%
      \multiput(\strip@pt\tpg@left,\strip@pt\tpg@bottom)%
               (\strip@pt\tpg@gridwidth,0){\the\@tempcnta}{%
        \line(0,1){\strip@pt\textheight}}%
      \endgroup
    }%
  \else
    \typeout{Typographic grid switched off}%
  \fi
}

\endinput
%%
%% End of file `typogrid.sty'.