| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% Copyright (C) 2013 by Scott Lawrence <[email protected]> |
| 4 |
% --------------------------------------------------------------------------- |
| 5 |
% This work may be distributed and/or modified under the |
| 6 |
% conditions of the LaTeX Project Public License, either version 1.3 |
| 7 |
% of this license or (at your option) any later version. |
| 8 |
% The latest version of this license is in |
| 9 |
% http://www.latex-project.org/lppl.txt |
| 10 |
% and version 1.3 or later is part of all distributions of LaTeX |
| 11 |
% version 2005/12/01 or later. |
| 12 |
% |
| 13 |
% This work has the LPPL maintenance status `maintained'. |
| 14 |
% |
| 15 |
% The Current Maintainer of this work is Scott Lawrence. |
| 16 |
% |
| 17 |
% This work consists of the files vgrid.dtx and vgrid.ins |
| 18 |
% and the derived filebase vgrid.sty. |
| 19 |
% |
| 20 |
% \fi |
| 21 |
% |
| 22 |
% \iffalse |
| 23 |
%<*driver> |
| 24 |
\ProvidesFile{vgrid.dtx} |
| 25 |
%</driver> |
| 26 |
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01] |
| 27 |
%<package>\ProvidesPackage{vgrid} |
| 28 |
%<*package> |
| 29 |
[2013/12/20 0.1 Overlays a vertical grid] |
| 30 |
%</package> |
| 31 |
% |
| 32 |
%<*driver> |
| 33 |
\documentclass{ltxdoc} |
| 34 |
\EnableCrossrefs |
| 35 |
\CodelineIndex |
| 36 |
\RecordChanges |
| 37 |
\usepackage{vgrid} |
| 38 |
\begin{document} |
| 39 |
\DocInput{vgrid.dtx} |
| 40 |
\PrintChanges |
| 41 |
\PrintIndex |
| 42 |
\end{document} |
| 43 |
%</driver> |
| 44 |
% \fi |
| 45 |
% |
| 46 |
% \CheckSum{72} |
| 47 |
% |
| 48 |
% \CharacterTable |
| 49 |
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z |
| 50 |
% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z |
| 51 |
% Digits \0\1\2\3\4\5\6\7\8\9 |
| 52 |
% Exclamation \! Double quote \" Hash (number) \# |
| 53 |
% Dollar \$ Percent \% Ampersand \& |
| 54 |
% Acute accent \' Left paren \( Right paren \) |
| 55 |
% Asterisk \* Plus \+ Comma \, |
| 56 |
% Minus \- Point \. Solidus \/ |
| 57 |
% Colon \: Semicolon \; Less than \< |
| 58 |
% Equals \= Greater than \> Question mark \? |
| 59 |
% Commercial at \@ Left bracket \[ Backslash \\ |
| 60 |
% Right bracket \] Circumflex \^ Underscore \_ |
| 61 |
% Grave accent \` Left brace \{ Vertical bar \| |
| 62 |
% Right brace \} Tilde \~} |
| 63 |
% |
| 64 |
% |
| 65 |
% \changes{1}{2013/12/20}{Converted to DTX file} |
| 66 |
% |
| 67 |
% \DoNotIndex{\newcommand,\newenvironment} |
| 68 |
% |
| 69 |
% \GetFileInfo{vgrid.dtx} |
| 70 |
% \title{The \textsf{vgrid} package} |
| 71 |
% \author{Scott Lawrence\\ \texttt{[email protected]}} |
| 72 |
% \date{\fileversion~from \filedate} |
| 73 |
% |
| 74 |
% \maketitle |
| 75 |
% |
| 76 |
% \section{Introduction} |
| 77 |
% |
| 78 |
% The \texttt{vgrid} package overlays a grid intended to help the author |
| 79 |
% enforce vertical rhythm on each page. The spacing of the grid is taken from |
| 80 |
% \verb|\baselineskip|, with the first line at the top of the text area. |
| 81 |
% |
| 82 |
% Note that \texttt{vgrid} itself does not change any spacing -- other packages |
| 83 |
% (or careful font settings) must be used to achieve vertical rhythm. This document, for example, can be clearly seen to not have vertical rhythm. |
| 84 |
% |
| 85 |
% \section{Usage} |
| 86 |
% |
| 87 |
% To add a grid to each page, just place \verb|\usepackage{vgrid}| in your |
| 88 |
% document's preamble. As of this version, there is no fine-grained control to |
| 89 |
% allow grids to be excluded from certain pages. The grid will use |
| 90 |
% \verb|\baselineskip| as the line height. |
| 91 |
% |
| 92 |
|
| 93 |
% |
| 94 |
% \StopEventually{} |
| 95 |
% |
| 96 |
% \section{Implementation} |
| 97 |
% |
| 98 |
% \iffalse |
| 99 |
%<*package> |
| 100 |
% \fi |
| 101 |
% |
| 102 |
% \begin{macrocode} |
| 103 |
\RequirePackage{everypage} |
| 104 |
\RequirePackage{tikz} |
| 105 |
\RequirePackage{ifoddpage} |
| 106 |
\newlength\vgrid@l \setlength\vgrid@l{\baselineskip} |
| 107 |
\newlength\vgrid@y |
| 108 |
\AddEverypageHook{ |
| 109 |
% \end{macrocode} |
| 110 |
% For every page, we need to re-calculate the coordinates of the grid. |
| 111 |
% \begin{macrocode} |
| 112 |
\def\@csm{\ifoddpageoroneside\oddsidemargin\else\evensidemargin\fi} |
| 113 |
\def\@left{\hoffset+\@csm} |
| 114 |
\def\@right{\@left+\textwidth} |
| 115 |
\def\@top{-\voffset-\topmargin-\headheight-\headsep} |
| 116 |
\def\@gridline{\draw [thin, gray]} |
| 117 |
\begin{tikzpicture}[overlay] |
| 118 |
\def\y{\@top-\vgrid@y} |
| 119 |
\@gridline (\@left, \@top) -- (\@left, \@top-\textheight); |
| 120 |
\@gridline (\@right, \@top) -- (\@right, \@top-\textheight); |
| 121 |
\setlength\vgrid@y{0pt} |
| 122 |
\@whiledim\vgrid@y<\textheight\do{ |
| 123 |
\@gridline (\@left, \y) -- (\@right, \y); |
| 124 |
\addtolength{\vgrid@y}{\vgrid@l} |
| 125 |
} |
| 126 |
\@gridline (\@left, \y) -- (\@right, \y); |
| 127 |
\end{tikzpicture} |
| 128 |
} |
| 129 |
% \end{macrocode} |
| 130 |
|
| 131 |
% |
| 132 |
% \iffalse |
| 133 |
%</package> |
| 134 |
% \fi |
| 135 |
% |
| 136 |
% \Finale |
| 137 |
\endinput |