summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/typogrid/typogrid.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/latex/typogrid/typogrid.dtx')
-rw-r--r--Master/texmf-dist/source/latex/typogrid/typogrid.dtx214
1 files changed, 214 insertions, 0 deletions
diff --git a/Master/texmf-dist/source/latex/typogrid/typogrid.dtx b/Master/texmf-dist/source/latex/typogrid/typogrid.dtx
new file mode 100644
index 00000000000..4fb0af5ed09
--- /dev/null
+++ b/Master/texmf-dist/source/latex/typogrid/typogrid.dtx
@@ -0,0 +1,214 @@
+% \iffalse meta comment
+% File: typogrid.dtx Copyright (C) 2003 Harald Harders
+% \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
+%%
+\EnableCrossrefs
+\CodelineIndex
+\DoNotIndex{\def,\edef,\let,\newcommand,\newenvironment,\newcounter}
+\DoNotIndex{\setcounter,\space,\if,\else,\fi,\empty,\@empty,\ifx,\fi}
+\DoNotIndex{\ifnum,\fi,\expandafter,\csname,\endcsname,\the}
+\DoNotIndex{\MessageBreak,\message,\newlength,\newif,\xdef,\newcount}
+\DoNotIndex{\begingroup,\endgroup,\,,\@tempcnta,\@tempdima,\advance}
+\DoNotIndex{\ensuremath,\filedate,\fileversion,\docdate}
+\DoNotIndex{\mathit,\mathrm,\mathsf,\nprt@tmp,\nprt@tmpnum,\relax}
+\DoNotIndex{\protect,\renewcommand,\setlength,\settowidth,\stepcounter}
+\DoNotIndex{\string}
+\CodelineNumbered
+\RecordChanges
+\CheckSum{111}
+\begin{document}
+ \DocInput{typogrid.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \changes{0.10}{2003/10/30}{First version}%
+%
+% \maketitle
+% \begin{abstract}
+% \noindent
+% This package produces a typographic grid on every page of the
+% document.
+% That grid consists of vertical lines that devide the text block into
+% columns.
+% This may be useful to get the horizontal measures (distances etc.)
+% into good values.
+% \end{abstract}
+%
+% \tableofcontents
+%
+% \section*{Copyright}
+% 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.
+%
+% \section{Usage}
+%
+% Load the package using the
+% \begin{quote}
+% \cs{usepackage}\oarg{options}|{typogrid}|
+% \end{quote}
+% command.
+% Valid options are |final|, |draft|, and
+% |columns=|\meta{value}.
+% The options |final| and |draft| may be given explicitely or
+% implicitely from the document-class options.
+%
+% When |draft| is given the typographic grid is switched on; if
+% |final| or none of the above is given it is switched off.
+%
+% The |columns| option determines the number of columns printed.
+% If it is not given, a default of 12 is used.
+%
+% \DescribeMacro{\typogridsetup}
+% There is a second possibility to change the number of columns.
+% You may use the \cs{typogridsetup} command that takes a keyval list
+% as argument.
+% This version suports only |columns=|\meta{value}, e.g.,
+% \begin{quote}
+% |\typogridsetup{columns=4}|
+% \end{quote}
+% You may also change the number of columns within the text.
+%
+% \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]
+\RequirePackage{calc}
+\RequirePackage{keyval}
+% \end{macrocode}
+% Introduce the used lengths.
+% \begin{macrocode}
+\newlength{\tpg@left}%
+\newlength{\tpg@top}%
+\newlength{\tpg@bottom}%
+\newlength{\tpg@gridwidth}%
+% \end{macrocode}
+% Introduce the used counters and set the default number of columns.
+% \begin{macrocode}
+\newcounter{tpg@bloecke}%
+\setcounter{tpg@bloecke}{12}%
+% \end{macrocode}
+% \begin{macro}{\typogridsetup}
+% Declare a command that can be used to change the appearence of the
+% typographic grid.
+% The argument takes a list of keyval options.
+% \begin{macrocode}
+\newcommand*\typogridsetup[1]{%
+ \expandafter\setkeys\expandafter{typogrid}{#1}}
+% \end{macrocode}
+% \end{macro}
+% 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
+ \PackageError{typogrid}{Less than 1 column given}{You have to
+ declare at least 1 column.}%
+ \setcounter{tpg@bloecke}{1}%
+ \fi
+}
+% \end{macrocode}
+% Package options:
+% \begin{macrocode}
+\newif\iftpg@draft
+\DeclareOption{draft}{\tpg@drafttrue}
+\DeclareOption{final}{\tpg@draftfalse}
+\DeclareOption*{\expandafter\typogridsetup\expandafter{\CurrentOption}}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\ExecuteOptions{final}
+\ProcessOptions\relax
+% \end{macrocode}
+% Start the grid with the first page (should not be necessary).
+% \begin{macrocode}
+\AtBeginDocument{%
+% \end{macrocode}
+% Print the grid on any page.
+% \begin{macrocode}
+ \iftpg@draft
+ \typeout{Typographic grid switched on}%
+ \AddToShipoutPicture{%
+% \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.
+% \begin{macrocode}
+ \begingroup
+ \normalcolor
+ \setlength{\unitlength}{1pt}%
+ \thinlines
+% \end{macrocode}
+% Calculate the distance of the text block from the page corner.
+% \begin{macrocode}
+ \setlength{\tpg@top}{\paperheight-1in-\topmargin-\headheight-\headsep}%
+ \setlength{\tpg@bottom}{\tpg@top-\textheight}%
+ \setlength{\tpg@gridwidth}{\textwidth/\thetpg@bloecke}%
+% \end{macrocode}
+% Calculate the number of vertical lines to be printed.
+% \begin{macrocode}
+ \@tempcnta=\thetpg@bloecke
+ \advance\@tempcnta by 1
+% \end{macrocode}
+% The left distance varies between odd and even pages.
+% \begin{macrocode}
+ \ifodd\arabic{page}%
+ \setlength{\tpg@left}{\oddsidemargin+1in}%
+ \else
+ \setlength{\tpg@left}{\evensidemargin+1in}%
+ \fi
+% \end{macrocode}
+% Print horizontal lines.
+% \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}}%
+% \end{macrocode}
+% Print equidistant vertical lines.
+% \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
+ }%
+ \else
+ \typeout{Typographic grid switched off}%
+ \fi
+}
+% \end{macrocode}
+%
+% \iffalse
+%</package>
+% \fi
+% \Finale
+