summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/vertbars/vertbars.sty
blob: 522cf9b0b817e8d745674aa928b129cd96987072 (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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
% vertbars.sty  The VERTical BARS package
%               An extension to the lineno package
%               to put vertical rules at left (right)
%               of lines instead of numbers
%
% This package requires the lineno package
%
% Author: Peter Wilson, Herries Press
% Maintainer: Will Robertson (will dot robertson at latex-project dot org)
% Copyright Peter R Wilson 2000
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
% version 1.3c of this license or (at your option) any 
% later version: <http://www.latex-project.org/lppl.txt>
%
% This work has the LPPL maintenance status "maintained".
% The Current Maintainer of this work is Will Robertson.
%
% Instructions are at the end of this file, after \endinput

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{vertbars}[2009/09/04 v1.0a vertical bars]

\newcommand{\LNenv}{runninglinenumbers}
\DeclareOption{switch}{%
  \renewcommand{\LNenv}{runningpagewiselinenumbers}
  \PassOptionsToPackage{\CurrentOption}{lineno}
}

\DeclareOption{switch*}{%
  \renewcommand{\LNenv}{runningpagewiselinenumbers}
  \PassOptionsToPackage{\CurrentOption}{lineno}
}

\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{lineno}}
\ProcessOptions\relax
\RequirePackage{lineno}

%%% code to add stuff at start and end of a pre-existing zero argument macro
\newcommand{\addtodef}[3]{\begingroup
  \@temptokena{#2}%
  \toks@\expandafter{#1#3}%
  \edef\x{\endgroup
    \def\noexpand#1{\the\@temptokena \the\toks@}}%
  \x
}

\newlength{\pwvbbl}
\setlength{\pwvbbl}{\baselineskip}  % it's useful to preserve \baselineskip
\newlength{\barwidth}         % width of bars
\setlength{\barwidth}{0.4pt}
\newlength{\barspace}         % horizontal space between bars
\setlength{\barspace}{0.5\linenumbersep}

\newcommand{\addtomakeLNL}{{\rule[-0.25\pwvbbl]{\barwidth}{1.1\pwvbbl}\hskip\barspace\relax}}
\newcommand{\pwvbLNL}{}
\newenvironment{vertbar}{\begin{\LNenv}%
  \addtodef{\pwvbLNL}{}{\addtomakeLNL}%
  \let\LineNumber\pwvbLNL%
  }{\end{\LNenv}}

\endinput

% Instructions:
%
%    Read the documentation for the lineno package.
%
%    The vertbars package takes the same options as the lineno package.
% In particular, the switch and switch* options control which side
% of the page any bars will be printed. The package automatically
% calls the lineno package, so you just need:
% \usepackage[...]{vertbars}
%
%    The package provides one environment, namely the vertbar environment.
% The vertbar environment is equivalent to the linenumbers environment
% except that a vertical bar replaces the line number. Text paragraphs 
% within a vertbar environment will be marked with a vertical bar in 
% the margin. Nested environments generate multiple marginal bars.
%
%    The width of the bars is controlled by the value of \barwidth, which 
% is initialised to 0.4pt, and can be changed via \setlength.
%
%    The horizontal seperation between adjacent bars is controlled by
% the value of \barspace, which is initialised to 0.5\linenumbersep, and can
% be changed via \setlength. (\linenumbersep is a command from the
% lineno package that controls the spacing between line numbers and the
% text body).
%
% NOTE: Bars can only be applied to complete paragraphs. For bars 
% between arbitrary points, use the changebar package. Any limitations
% of the lineno package apply equally to the vertbars package.
%
% Peter W.
%
% CHANGE HISTORY
%
% v1.0a (2009/09/04) - New maintainer (Will Robertson)
%