diff options
author | Karl Berry <karl@freefriends.org> | 2012-01-01 23:05:44 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2012-01-01 23:05:44 +0000 |
commit | 23ab143d707b8fa83fb9c63646807bc43b9456af (patch) | |
tree | 9c240f06526e7d7c5e08a9f5bbbd39f0a1535370 | |
parent | 053930a0ae346b5d7e31ad8e9e576cac0ea1bb70 (diff) |
typogrid 0.21 (1jan12)
git-svn-id: svn://tug.org/texlive/trunk@24994 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Master/texmf-dist/doc/latex/typogrid/ChangeLog | 10 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/typogrid/Makefile (renamed from Master/texmf-dist/source/latex/typogrid/Makefile) | 35 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/typogrid/README | 10 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/typogrid/getversion.tex | 7 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/typogrid/testtypogrid.tex | 27 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/typogrid/typogrid.pdf | bin | 60201 -> 293839 bytes | |||
-rw-r--r-- | Master/texmf-dist/source/latex/typogrid/typogrid.dtx | 279 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/typogrid/typogrid.ins | 4 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/typogrid/typogrid.sty | 141 |
9 files changed, 372 insertions, 141 deletions
diff --git a/Master/texmf-dist/doc/latex/typogrid/ChangeLog b/Master/texmf-dist/doc/latex/typogrid/ChangeLog new file mode 100644 index 00000000000..6b791a71280 --- /dev/null +++ b/Master/texmf-dist/doc/latex/typogrid/ChangeLog @@ -0,0 +1,10 @@ +2011/12/31 0.21 Harald Harders (harald.harders@gmx.de) + - Change Makefile in order to produce pdf documentation + - Set date and version explicitly in \ProvidesPackage + +2003/11/09 0.20 Harald Harders (harald.harders@gmx.de), Rolf Niepraschk + - Reimplementation, provide grid for headings and a frame for + the margin + +2003/10/30 0.10 Harald Harders (harald.harders@gmx.de) + - First version diff --git a/Master/texmf-dist/source/latex/typogrid/Makefile b/Master/texmf-dist/doc/latex/typogrid/Makefile index 6f6cfa0a53d..8ea95b17b8a 100644 --- a/Master/texmf-dist/source/latex/typogrid/Makefile +++ b/Master/texmf-dist/doc/latex/typogrid/Makefile @@ -2,26 +2,22 @@ SRCDIR=typogrid INSTALLDIR=`kpsewhich --expand-path='$$TEXMFLOCAL'`/tex/latex/typogrid DOCDIR=`kpsewhich --expand-path='$$TEXMFLOCAL'`/doc/latex/typogrid -VERSION=`grep '^\\\\def\\\\fileversion' typogrid.dtx | sed 's/^\\\\def\\\\fileversion{\\(.*\\)\\.\\(.*\\)}/\\1_\\2/'` +VERSION=`latex getversion | grep '^VERSION' | sed 's/^VERSION \\(.*\\)\\.\\(.*\\)/\\1_\\2/'` -.SUFFIXES: .sty .ins .dtx .dvi .ps .pdf +.SUFFIXES: .sty .ins .dtx .pdf .ps .pdf .ins.sty: - latex $< + pdflatex $< -.dtx.dvi: - latex $< - latex $< +.dtx.pdf: + pdflatex $< + pdflatex $< makeindex -s gind.ist $(*D)/$(*F) makeindex -s gglo.ist -o $(*D)/$(*F).gls $(*D)/$(*F).glo - latex $< + pdflatex $< -.dvi.ps: - dvips -o $(*D)/$(*F).ps $(*D)/$(*F) - - -all: typogrid.sty typogrid.dvi +all: typogrid.sty typogrid.pdf clean: @@ -31,19 +27,21 @@ clean: @-rm -f *~ distclean: clean - @-rm -f typogrid.sty typogrid.dvi - @-rm -f testtypogrid.dvi + @-rm -f typogrid.sty typogrid.pdf + @-rm -f testtypogrid.pdf tar: all clean - echo Lege typogrid-$(VERSION).tar.gz an -rm -f typogrid-$(VERSION).tar.gz tar czCf .. typogrid-$(VERSION).tar.gz \ $(SRCDIR)/README \ + $(SRCDIR)/ChangeLog \ $(SRCDIR)/Makefile \ $(SRCDIR)/typogrid.dtx \ $(SRCDIR)/typogrid.ins \ - $(SRCDIR)/typogrid.dvi \ + $(SRCDIR)/typogrid.pdf \ + $(SRCDIR)/getversion.tex \ $(SRCDIR)/testtypogrid.tex + rm -f getversion.log zip: all clean -@rm -f typogrid-$(VERSION).zip @@ -53,15 +51,16 @@ zip: all clean mv typogrid.sty tex/latex/typogrid cp typogrid.dtx typogrid.ins typogrid.xml source/latex/typogrid cp Makefile source/latex/typogrid - cp README typogrid.dvi testtypogrid.tex doc/latex/typogrid + cp README ChangeLog typogrid.pdf testtypogrid.tex doc/latex/typogrid zip -r typogrid-$(VERSION).zip tex doc source rm -r tex/ doc/ source/ + rm -f getversion.log install: all if [ ! -d $(INSTALLDIR) ]; then mkdirhier $(INSTALLDIR); fi if [ ! -d $(DOCDIR) ]; then mkdirhier $(DOCDIR); fi install -m644 typogrid.sty $(INSTALLDIR) - install -m644 typogrid.dvi $(DOCDIR) + install -m644 typogrid.pdf $(DOCDIR) texhash diff --git a/Master/texmf-dist/doc/latex/typogrid/README b/Master/texmf-dist/doc/latex/typogrid/README index 82ffa8bc0e3..2b2f4478ce8 100644 --- a/Master/texmf-dist/doc/latex/typogrid/README +++ b/Master/texmf-dist/doc/latex/typogrid/README @@ -7,7 +7,7 @@ text block into columns. This may be useful to get the horizontal measures (distances etc.) into good values. -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 @@ -42,10 +42,6 @@ by hand: - execute latex on typogrid.ins again -Change log: -- 0.10 2003/10/30 New version - - -2003-10-30 +2011-12-31 Harald Harders -h.harders@tu-bs.de +harald.harders@gmx.de diff --git a/Master/texmf-dist/doc/latex/typogrid/getversion.tex b/Master/texmf-dist/doc/latex/typogrid/getversion.tex new file mode 100644 index 00000000000..689da0b89c5 --- /dev/null +++ b/Master/texmf-dist/doc/latex/typogrid/getversion.tex @@ -0,0 +1,7 @@ +\documentclass[english]{ltxdoc} +\nofiles +\usepackage{typogrid} +\GetFileInfo{typogrid.sty} +\typeout{VERSION \fileversion} +\begin{document} +\end{document} diff --git a/Master/texmf-dist/doc/latex/typogrid/testtypogrid.tex b/Master/texmf-dist/doc/latex/typogrid/testtypogrid.tex index d0362f41e49..532dbb142a0 100644 --- a/Master/texmf-dist/doc/latex/typogrid/testtypogrid.tex +++ b/Master/texmf-dist/doc/latex/typogrid/testtypogrid.tex @@ -1,27 +1,40 @@ -\documentclass[draft]{article} -\usepackage[columns=4]{typogrid} +\documentclass[draft,a4paper]{article} +%\usepackage[columns=4,headings=false,margin=false]{typogrid} +\usepackage[columns=4,colorgrid]{typogrid} +\usepackage[dvips]{geometry} +\flushbottom \long\def\text{This is a sample text without any meaning. It contains some arbitrary text. But I don't know more. I really have no idea what I could now write. This is the next try to build a new sentence. Somehow, I have to fill the page with arbitrary text.\par} +\pagestyle{headings} + \begin{document} \text \text \text \text \text +\section{Test} \text + +\noindent\rule{\gridwidth}{2pt} + \text \text +\marginpar[This is left margin text.]{This is right margin text.} \text \text \text \text \text \text -\typogridsetup{columns=6}% +\typogridsetup{columns=6,margin=false}% \text + +\noindent\rule{\gridwidth}{2pt} + \text \text \text @@ -29,4 +42,12 @@ \text \text \text +\begin{figure} + \centering + \thicklines + \framebox[2\gridwidth][c]{Hello}% + \caption{A figure fitting into the grid}% + \label{fig:grid}% +\end{figure} + \end{document} diff --git a/Master/texmf-dist/doc/latex/typogrid/typogrid.pdf b/Master/texmf-dist/doc/latex/typogrid/typogrid.pdf Binary files differindex 18054fae1c7..9a50141f9bc 100644 --- a/Master/texmf-dist/doc/latex/typogrid/typogrid.pdf +++ b/Master/texmf-dist/doc/latex/typogrid/typogrid.pdf diff --git a/Master/texmf-dist/source/latex/typogrid/typogrid.dtx b/Master/texmf-dist/source/latex/typogrid/typogrid.dtx index 4fb0af5ed09..4ea0c77c650 100644 --- a/Master/texmf-dist/source/latex/typogrid/typogrid.dtx +++ b/Master/texmf-dist/source/latex/typogrid/typogrid.dtx @@ -1,25 +1,27 @@ % \iffalse meta comment -% File: typogrid.dtx Copyright (C) 2003 Harald Harders +% File: typogrid.dtx Copyright (C) 2003, 2011 Harald Harders, Rolf Niepraschk % \fi % % \iffalse -% -%<*package> -\def\fileversion{0.10} -\def\filedate{2003/10/30} -\def\docdate{2003/10/30} -%</package> %<*driver> \listfiles \documentclass[a4paper]{ltxdoc} -\title{The \texttt{typogrid} package\thanks{This file has version - \fileversion\ last revised \filedate, documentation dated - \docdate.}} -\author{Harald Harders\\\texttt{h.harders@tu-bs.de}} -\date{File Date \filedate, Printed \today} \usepackage[T1]{fontenc} -%\def\meta@font@select{\normalfont\itshape} -\makeatother +\IfFileExists{typogrid.sty}{% + \usepackage[draft,columns=4,margin=false,headings=true]{typogrid} +}{% + \GenericWarning{typogrid.dtx}{Package file typogrid.sty not found + (Documentation will be messed up!^^J^^A + Generate typogrid.sty by (La)TeXing typogrid.ins, process + typogrid.dtx again)^^J}\stop +} +%% +\GetFileInfo{typogrid.sty} +\title{The \texttt{typogrid} package} +\author{% + Harald Harders (\texttt{h.harders@tu-bs.de}),\\ + Rolf Niepraschk (\texttt{rolf.niepraschk@ptb.de})} +\date{File Version \fileversion, \filedate, printed \today} %% \EnableCrossrefs \CodelineIndex @@ -31,16 +33,21 @@ \DoNotIndex{\ensuremath,\filedate,\fileversion,\docdate} \DoNotIndex{\mathit,\mathrm,\mathsf,\nprt@tmp,\nprt@tmpnum,\relax} \DoNotIndex{\protect,\renewcommand,\setlength,\settowidth,\stepcounter} -\DoNotIndex{\string} +\DoNotIndex{\string,\put,\multiput} \CodelineNumbered \RecordChanges -\CheckSum{111} +\CheckSum{219} \begin{document} \DocInput{typogrid.dtx} \end{document} %</driver> % \fi % +% \changes{0.21}{2011/12/31}{Update Makefile}% +% \changes{0.21}{2011/12/31}{Set date and version explicitly in +% \cs{ProvidesPackage}}% +% \changes{0.20}{2003/11/09}{Reimplementation with respect to +% \texttt{showframe.sty} by Rolf Niepraschk}% % \changes{0.10}{2003/10/30}{First version}% % % \maketitle @@ -57,7 +64,7 @@ % \tableofcontents % % \section*{Copyright} -% 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 @@ -71,8 +78,9 @@ % \cs{usepackage}\oarg{options}|{typogrid}| % \end{quote} % command. -% Valid options are |final|, |draft|, and -% |columns=|\meta{value}. +% Valid options are |final|, |draft|, +% |columns=|\meta{value}, |headings=|\meta{true,false}, and +% |margin=|\meta{true,false}. % The options |final| and |draft| may be given explicitely or % implicitely from the document-class options. % @@ -82,40 +90,70 @@ % The |columns| option determines the number of columns printed. % If it is not given, a default of 12 is used. % +% If |headings=true| is given, a grid is printed for the head line and +% the foot line, too (this is the default, you may also omit it). +% If |headings=false| is given, no grid is printed for the headings. +% +% With |margin=false|, you can switch off printing a frame around the +% area for margin notes (default is to print the frame). +% % \DescribeMacro{\typogridsetup} -% There is a second possibility to change the number of columns. +% There is a second possibility to change the typographic grid. % You may use the \cs{typogridsetup} command that takes a keyval list % as argument. -% This version suports only |columns=|\meta{value}, e.g., +% The same keywords are allowed as in the \cs{usepackage} line, e.g., % \begin{quote} % |\typogridsetup{columns=4}| % \end{quote} -% You may also change the number of columns within the text. +% You may use this command within the text in order to change the grid +% at arbitrary position of the document. +% The change takes effect on the next page. % +% \DescribeMacro{\typogrid} +% If you have switched off printing of the grid, you may get a grid +% for single pages using +% \begin{quote} +% |\AddToShipoutPicture*{\typogrid}| +% \end{quote} +% +% The package defines the length \cs{gridwidth} which is as long as +% the space between too grid lines. +% You may use it to scale pictures to fit to the grid, for instance. +% +% +% \section{Shortcomings} +% +% \begin{itemize} +% \item Calculation of position and size of the headings and the +% margin works for standard cases, only. +% \item If the text width changes from one page to the next, the grid +% width is wrong on the first page after the change. +% \end{itemize} +% +% % \StopEventually{\PrintChanges \PrintIndex} % +% % \section{The implementation} % \iffalse %<*package> % \fi % Heading of the package: % \begin{macrocode} -\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} % \end{macrocode} % Introduce the used lengths. % \begin{macrocode} -\newlength{\tpg@left}% -\newlength{\tpg@top}% -\newlength{\tpg@bottom}% -\newlength{\tpg@gridwidth}% +\newlength{\gridwidth}% % \end{macrocode} % Introduce the used counters and set the default number of columns. % \begin{macrocode} -\newcounter{tpg@bloecke}% -\setcounter{tpg@bloecke}{12}% +\newcount\tpg@blocks% +\newcounter{tpg@blocks@new}% +\setcounter{tpg@blocks@new}{12}% % \end{macrocode} % \begin{macro}{\typogridsetup} % Declare a command that can be used to change the appearence of the @@ -129,81 +167,180 @@ % Define the key |columns| that takes the number of columns. % \begin{macrocode} \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 } % \end{macrocode} +% Define the key |headings| to switch on or off a frame around the +% headings. +% \begin{macrocode} +\newif\iftpg@headings +\newif\iftpg@headings@new +\tpg@headings@newtrue +\define@key{typogrid}{headings}[true]{% + \csname tpg@headings@new#1\endcsname +} +% \end{macrocode} +% Define the key |margin| to switch on or off a frame around the +% margin. +% \begin{macrocode} +\newif\iftpg@margin +\newif\iftpg@margin@new +\tpg@margin@newtrue +\define@key{typogrid}{margin}[true]{% + \csname tpg@margin@new#1\endcsname +} +% \end{macrocode} % Package options: % \begin{macrocode} \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}} % \end{macrocode} -% +% Default is no grid. % \begin{macrocode} \ExecuteOptions{final} \ProcessOptions\relax % \end{macrocode} -% Start the grid with the first page (should not be necessary). +% Load this package after processing the options. % \begin{macrocode} -\AtBeginDocument{% +\RequirePackage{eso-pic}[2002/11/16] % \end{macrocode} -% Print the grid on any page. +% \begin{macro}{\typogrid} +% Define the command that produces the grid. % \begin{macrocode} - \iftpg@draft - \typeout{Typographic grid switched on}% - \AddToShipoutPicture{% +\newcommand*\typogrid{% % \end{macrocode} -% Set the unit length each time because the use may have changed it. -% Do everything inside a group to prevent the changes to be seen -% outside. +% Switch to black and thin lines. % \begin{macrocode} - \begingroup - \normalcolor - \setlength{\unitlength}{1pt}% - \thinlines + \begingroup + \normalcolor + \thinlines % \end{macrocode} -% Calculate the distance of the text block from the page corner. +% Calculate the number of lines to be printed. % \begin{macrocode} - \setlength{\tpg@top}{\paperheight-1in-\topmargin-\headheight-\headsep}% - \setlength{\tpg@bottom}{\tpg@top-\textheight}% - \setlength{\tpg@gridwidth}{\textwidth/\thetpg@bloecke}% + \@tempcnta=\tpg@blocks + \advance\@tempcnta by -1% % \end{macrocode} -% Calculate the number of vertical lines to be printed. +% Print a frame around the text block. % \begin{macrocode} - \@tempcnta=\thetpg@bloecke - \advance\@tempcnta by 1 + \AtTextLowerLeft{% + \put(0,0){% + \framebox(\LenToUnit{\textwidth},\LenToUnit{\textheight}){}}% % \end{macrocode} -% The left distance varies between odd and even pages. +% Print the vertical lines for the grid. % \begin{macrocode} - \ifodd\arabic{page}% - \setlength{\tpg@left}{\oddsidemargin+1in}% - \else - \setlength{\tpg@left}{\evensidemargin+1in}% - \fi + \multiput(\LenToUnit{\gridwidth},0)% + (\LenToUnit{\gridwidth},0){\the\@tempcnta}{% + \line(0,1){\LenToUnit{\textheight}}}% + }% % \end{macrocode} -% Print horizontal lines. +% Print a frame around the head line if wanted. % \begin{macrocode} - \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}}% + \iftpg@headings + \AtTextUpperLeft{% + \put(0,\LenToUnit{\headsep}){% + \framebox(\LenToUnit{\textwidth},\LenToUnit{\headheight}){}}% % \end{macrocode} -% Print equidistant vertical lines. +% Print the grid. % \begin{macrocode} - \multiput(\strip@pt\tpg@left,\strip@pt\tpg@bottom)% - (\strip@pt\tpg@gridwidth,0){\the\@tempcnta}{% - \line(0,1){\strip@pt\textheight}}% - \endgroup - }% + \multiput(\LenToUnit{\gridwidth},\LenToUnit{\headsep})% + (\LenToUnit{\gridwidth},0){\the\@tempcnta}{% + \line(0,1){\LenToUnit{\headheight}}}% + }% +% \end{macrocode} +% Print a line below the foot line if wanted (the height of the foot +% line is not available). +% \begin{macrocode} + \AtTextLowerLeft{% + \put(0,\LenToUnit{-\footskip}){% + \line(1,0){\LenToUnit{\textwidth}}}% +% \end{macrocode} +% Print the grid. +% \begin{macrocode} + \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 +% \end{macrocode} +% Print a frame around the margin if wanted. +% \begin{macrocode} + \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 +% \end{macrocode} +% Calculate the width of each grid. +% Store it globally to be able to use it inside the document. +% \begin{macrocode} + \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 +} +% \end{macrocode} +% \end{macro} +% Start the grid at \cs{begin\{document\}}. +% Do it that late to enable the author to switch between |draft| and +% |final| before that position. +% \begin{macrocode} +\AtBeginDocument{% +% \end{macrocode} +% Print the grid on any page if wanted. +% \begin{macrocode} + \iftpg@draft + \typeout{Typographic grid switched on}% + \AddToShipoutPicture{\typogrid}% \else \typeout{Typographic grid switched off}% \fi +% \end{macrocode} +% Declare width of grid for first page of document. +% \begin{macrocode} + \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 } % \end{macrocode} % diff --git a/Master/texmf-dist/source/latex/typogrid/typogrid.ins b/Master/texmf-dist/source/latex/typogrid/typogrid.ins index 1e19f6e146e..0320cbf8d03 100644 --- a/Master/texmf-dist/source/latex/typogrid/typogrid.ins +++ b/Master/texmf-dist/source/latex/typogrid/typogrid.ins @@ -3,14 +3,14 @@ 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 \endpreamble 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 |