forked from quantixed/CoB-LaTeX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TI-lineno-COB.sty
102 lines (91 loc) · 3.25 KB
/
TI-lineno-COB.sty
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
\usepackage[switch,mathlines,displaymath]{lineno}
%\runninglinenumbers %% for continous line numbering regardless of box and minipage but only on left side in single/double column
\linenumbers %% properly in single/double column but boxes and minipage linenos not getting continuous
\def\linenumberfont{\usefont{T1}{ptm}{m}{n}\color{red}\fontsize{8}{10}\selectfont}
\if@twocolumn
\setlength\marginparwidth{.75cm}
\setlength\marginparsep{19.5\p@}
\else
\setlength\marginparwidth{20pt}
\setlength\marginparsep{24pt}
\fi
\newcommand\linenomathWithnumbersforams{%
\ifLineNumbers
%\ifx\@@par\@@@par\else
\ifnum\interlinepenalty>-\linenopenaltypar
\global\holdinginserts\thr@@
\advance\interlinepenalty \linenopenalty
\ifhmode % v4.3
\advance\predisplaypenalty \linenopenalty
\fi
%\advance\postdisplaypenalty \linenopenalty
\advance\interdisplaylinepenalty \linenopenalty
\fi
\fi
\ignorespaces
}
\newcommand\linenomathWithnumbersformultline{%
\ifLineNumbers
%\ifx\@@par\@@@par\else
\ifnum\interlinepenalty>-\linenopenaltypar
\global\holdinginserts\thr@@
\advance\interlinepenalty \linenopenalty
\ifhmode % v4.3
%\advance\predisplaypenalty \linenopenalty
\fi
%\advance\postdisplaypenalty \linenopenalty
\advance\interdisplaylinepenalty \linenopenalty
\fi
\fi
\ignorespaces
}
\newcommand*\patchAmsMathEnvironmentForLineno[1]{%
\expandafter\let\csname old#1\expandafter\endcsname\csname #1\endcsname
\expandafter\let\csname oldend#1\expandafter\endcsname\csname end#1\endcsname
\renewenvironment{#1}%
{\def\linenomath{\linenomathWithnumbersforams}%added
\@namedef{linenomath*}{\linenomathNonumbers}%added
\linenomath\csname old#1\endcsname}%
{\csname oldend#1\endcsname\endlinenomath}}%
\newcommand*\patchBothAmsMathEnvironmentsForLineno[1]{%
\patchAmsMathEnvironmentForLineno{#1}%
\patchAmsMathEnvironmentForLineno{#1*}%
}%
\AtBeginDocument{%
\patchBothAmsMathEnvironmentsForLineno{equation}% deleted
\patchBothAmsMathEnvironmentsForLineno{align}%
\patchBothAmsMathEnvironmentsForLineno{flalign}%
\patchBothAmsMathEnvironmentsForLineno{alignat}%
\patchBothAmsMathEnvironmentsForLineno{gather}%
%\patchBothAmsMathEnvironmentsForLineno{multline}%
%\patchBothAmsMathEnvironmentsForLineno{split}%
\patchAmsMathEnvironmentForLineno{array}%
%\patchAmsMathEnvironmentForLineno{split}%
}
%%\AtBeginDocument{%
\let\LN@align\align
\let\LN@endalign\endalign
\renewenvironment{align}%
{\linenomath\LN@align}%
{\LN@endalign\endlinenomath}%
%%}
\renewenvironment{multline}{\linenomathWithnumbersformultline%
\start@multline\st@rredfalse
}{%
\iftagsleft@ \@xp\lendmultline@ \else \@xp\rendmultline@ \fi
\ignorespacesafterend
\endlinenomath}
\renewenvironment{multline*}{\linenomathWithnumbersformultline\start@multline\st@rredtrue}{\endmultline\endlinenomath}
\def\insplit@{%
\global\setbox\z@\vbox\bgroup
\Let@ \chardef\dspbrk@context\@ne \restore@math@cr
\default@tag % disallow use of \tag here
\ialign\bgroup
\hfil%
\strut@
$\m@th\displaystyle{##}$%
&$\m@th\displaystyle{{}##}$%
\hfill % Why not \hfil?---dmj, 1994/12/28
\crcr\noalign{\global\advance\c@linenumber\@ne}%
}
\endinput