summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/vertbars/vertbars.sty
blob: bb988addbf3cbafd52ea354c325bf39491ebd319 (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
%% LaTeX2e file `vertbars.sty'
%% generated by the `filecontents' environment
%% from source `vertbars' on 2010/11/27.
%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{vertbars}[2010/11/27 v1.0b vertical bars in the margin]

\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
}

% It's useful to preserve \cmd\baselineskip:
\newlength{\pwvbbl}
\setlength{\pwvbbl}{\baselineskip}

% Width of bars:
\newlength{\barwidth}
\setlength{\barwidth}{0.4pt}

% Horizontal space between bars:
\newlength{\barspace}
\setlength{\barspace}{0.5\linenumbersep}

\newcommand{\addtomakeLNL}{{\rule[-0.25\pwvbbl]{\barwidth}{1.1\pwvbbl}\hskip\barspace\relax}}
\newcommand{\pwvbLNL}{}

\newenvironment{vertbar}{%
  \pagewiselinenumbers % <= added v1.0b
  \begin{\LNenv}%
    \addtodef{\pwvbLNL}{}{\addtomakeLNL}%
    \let\LineNumber\pwvbLNL
}{%
  \end{\LNenv}%
}