From 23ab143d707b8fa83fb9c63646807bc43b9456af Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sun, 1 Jan 2012 23:05:44 +0000 Subject: typogrid 0.21 (1jan12) git-svn-id: svn://tug.org/texlive/trunk@24994 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/tex/latex/typogrid/typogrid.sty | 141 ++++++++++++++++------ 1 file changed, 101 insertions(+), 40 deletions(-) (limited to 'Master/texmf-dist/tex/latex/typogrid') diff --git a/Master/texmf-dist/tex/latex/typogrid/typogrid.sty b/Master/texmf-dist/tex/latex/typogrid/typogrid.sty index a7a18c53a5b..67056ea747e 100644 --- a/Master/texmf-dist/tex/latex/typogrid/typogrid.sty +++ b/Master/texmf-dist/tex/latex/typogrid/typogrid.sty @@ -8,74 +8,135 @@ %% %% typogrid package %% -%% Copyright 2003 Harald Harders +%% Copyright 2003, 2011 Harald Harders, Rolf Niepraschk %% %% 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 +%% h.harders@tu-bs.de, rolf.niepraschk@ptb.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] +\ProvidesPackage{typogrid} + [2011/12/31 v0.21 Typographic grid] \RequirePackage{calc} \RequirePackage{keyval} -\newlength{\tpg@left}% -\newlength{\tpg@top}% -\newlength{\tpg@bottom}% -\newlength{\tpg@gridwidth}% -\newcounter{tpg@bloecke}% -\setcounter{tpg@bloecke}{12}% +\newlength{\gridwidth}% +\newcount\tpg@blocks% +\newcounter{tpg@blocks@new}% +\setcounter{tpg@blocks@new}{12}% \newcommand*\typogridsetup[1]{% \expandafter\setkeys\expandafter{typogrid}{#1}} \define@key{typogrid}{columns}{% - \setcounter{tpg@bloecke}{#1}% - \ifnum\arabic{tpg@bloecke}<1 + \setcounter{tpg@blocks@new}{#1}% + \ifnum\the\c@tpg@blocks@new<1\relax \PackageError{typogrid}{Less than 1 column given}{You have to declare at least 1 column.}% - \setcounter{tpg@bloecke}{1}% + \setcounter{tpg@blocks@new}{1}% \fi } +\newif\iftpg@headings +\newif\iftpg@headings@new +\tpg@headings@newtrue +\define@key{typogrid}{headings}[true]{% + \csname tpg@headings@new#1\endcsname +} +\newif\iftpg@margin +\newif\iftpg@margin@new +\tpg@margin@newtrue +\define@key{typogrid}{margin}[true]{% + \csname tpg@margin@new#1\endcsname +} \newif\iftpg@draft \DeclareOption{draft}{\tpg@drafttrue} \DeclareOption{final}{\tpg@draftfalse} +\DeclareOption{colorgrid}{\PassOptionsToPackage{\CurrentOption}{eso-pic}} +\DeclareOption{grid}{\PassOptionsToPackage{\CurrentOption}{eso-pic}} \DeclareOption*{\expandafter\typogridsetup\expandafter{\CurrentOption}} \ExecuteOptions{final} \ProcessOptions\relax +\RequirePackage{eso-pic}[2002/11/16] +\newcommand*\typogrid{% + \begingroup + \normalcolor + \thinlines + \@tempcnta=\tpg@blocks + \advance\@tempcnta by -1% + \AtTextLowerLeft{% + \put(0,0){% + \framebox(\LenToUnit{\textwidth},\LenToUnit{\textheight}){}}% + \multiput(\LenToUnit{\gridwidth},0)% + (\LenToUnit{\gridwidth},0){\the\@tempcnta}{% + \line(0,1){\LenToUnit{\textheight}}}% + }% + \iftpg@headings + \AtTextUpperLeft{% + \put(0,\LenToUnit{\headsep}){% + \framebox(\LenToUnit{\textwidth},\LenToUnit{\headheight}){}}% + \multiput(\LenToUnit{\gridwidth},\LenToUnit{\headsep})% + (\LenToUnit{\gridwidth},0){\the\@tempcnta}{% + \line(0,1){\LenToUnit{\headheight}}}% + }% + \AtTextLowerLeft{% + \put(0,\LenToUnit{-\footskip}){% + \line(1,0){\LenToUnit{\textwidth}}}% + \put(0,\LenToUnit{-\footskip}){% + \line(0,1){\LenToUnit{\baselineskip}}}% + \put(\LenToUnit{\textwidth},\LenToUnit{-\footskip}){% + \line(0,1){\LenToUnit{\baselineskip}}}% + \multiput(\LenToUnit{\gridwidth},\LenToUnit{-\footskip})% + (\LenToUnit{\gridwidth},0){\the\@tempcnta}{% + \line(0,1){\LenToUnit{\baselineskip}}}% + }% + \fi + \iftpg@margin + \AtTextLowerLeft{% + \@tempdima=\textwidth\advance\@tempdima\marginparsep% + \if@twoside% + \ifodd\c@page + \else + \@tempdima=-\marginparsep\advance\@tempdima-\marginparwidth% + \fi% + \fi% + \put(\LenToUnit{\@tempdima},0){% + \framebox(\LenToUnit{\marginparwidth},% + \LenToUnit{\textheight}){}}% + }% + \fi + \endgroup + \setlength\gridwidth{\textwidth/\arabic{tpg@blocks@new}}% + \global\gridwidth=\gridwidth + \global\tpg@blocks=\arabic{tpg@blocks@new}% + \iftpg@headings@new + \global\tpg@headingstrue + \else + \global\tpg@headingsfalse + \fi + \iftpg@margin@new + \global\tpg@margintrue + \else + \global\tpg@marginfalse + \fi +} \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 - }% + \AddToShipoutPicture{\typogrid}% \else \typeout{Typographic grid switched off}% \fi + \setlength\gridwidth{\textwidth/\arabic{tpg@blocks@new}}% + \global\tpg@blocks=\arabic{tpg@blocks@new}% + \iftpg@headings@new + \tpg@headingstrue + \else + \tpg@headingsfalse + \fi + \iftpg@margin@new + \tpg@margintrue + \else + \tpg@marginfalse + \fi } \endinput -- cgit v1.2.3