CoCalc Public Fileswww / talks / harvard-talk-2004-12-08 / auto / srcltx.styOpen with one click!
Author: William A. Stein
Compute Environment: Ubuntu 18.04 (Deprecated)
1
2
% ------------------------------------------------------------------------
3
% File: srcltx.sty
4
% ==========
5
%
6
% Version 1.002 1999 Sep 3 (modified to change \everypar)
7
% by David Carlisle
8
%
9
% Version 1.001 1998 Dec 23 (modified to change \output)
10
% by Berthold Horn
11
%
12
% This package was originally written by Aleksander Simonic (the
13
% author of WinEdt Shell) to implement a source file tracking and
14
% DVI "SRC" specials for LaTeX.
15
%
16
% This package comes with no guarantees and no reserved rights.
17
% You can use or modify this file at your own risk.
18
% ************************************************************************
19
% NOTE: TeX commands are case sensitive. You have to use uppercase
20
% \Input to take advantage of this package
21
%
22
% This package supports nested \Input commands...
23
% File extension should be specified in \Input!
24
%
25
% This file should be placed in a directory where your LaTeX is
26
% looking for inputs (eg. ...\localtexmf\tex for MiKTeX).
27
%
28
% If you are writing a book with WinEdt and LaTeX simply
29
% include this file and use \include{mychapter} command...
30
% This way all the necessary specials for DVI Search and
31
% Inverse Search are inserted in your DVI File.
32
%
33
% WinEdt will be able to track Errors from your LOG file.
34
%
35
% ************************************************************************
36
%
37
% Some TeX implementations (eg. MiKTeX 1.20 [or later]) can insert
38
% the SRC specials much better than any macro package. Consult your
39
% TeX documentation to see if it is better to leave the task to your
40
% TeX. You can still use the [inactive] version of this package to
41
% take advantage of the re-defined Input commands and thus allowing
42
% WinEdt to keep track of errors in included source files.
43
%
44
% MiKTeX inserts the SRC specials in the DVI file if you start
45
% [La]TeX with --src qualifier (see MiKTeX's Manual:
46
% ...\texmf\Doc\MiKTeX\MiKTeX.pdf for more info).
47
%
48
% ************************************************************************
49
%
50
% * NOTE: Some TeX implementations add the file type to the "\jobname".
51
% In that case the definition of the "\MainFile" should be modified to:
52
%
53
% \def\MainFile{\jobname} instead of \def\MainFile{\jobname.tex}.
54
%
55
% ************************************************************************
56
%
57
% *** Example - Your LaTeX thesis document may look like this:
58
%
59
%\documentclass[12pt]{report}
60
%\usepackage[centertags]{amstex}
61
%\usepackage{thesis,newlfont,amsthm}
62
%\usepackage[active]{srcltx}
63
%%No src specials are written when loading the package by
64
%%\usepackage[inactive]{srcltx}
65
%
66
% .... Preamble ....
67
%
68
%\begin{document}
69
%
70
% .... Title, Author etc. ....
71
%
72
%\WinEdt{?0000} % Do not process any Errors (Overful/Underful Boxes)
73
%\beforepreface
74
%\WinEdt{?1111} % Process All Types of Errors from here on
75
%\include{ABS}
76
%\include{ACK}
77
%\afterpreface
78
%\include{chapter0}
79
%\include{chapter1}
80
%\include{chapter2}
81
%\include{chapter3}
82
%\bibliographystyle{amsplain}
83
%\bibliography{xbib}
84
%\end{document}
85
%
86
% ------------------------------------------------------------------------
87
\NeedsTeXFormat{LaTeX2e}
88
\ProvidesPackage{srcltx}[1999/10/11 v1.002 DVI Search]
89
\newif\ifSRCOK \SRCOKtrue
90
\DeclareOption{active}{\SRCOKtrue}
91
\DeclareOption{inactive}{\SRCOKfalse}
92
\ExecuteOptions{inactive}
93
\ProcessOptions
94
% ------------------------------------------------------------------------
95
\newcount\PAGETOP
96
\newcount\LASTLINE
97
\global\PAGETOP=1
98
\global\LASTLINE=-1
99
\gdef\MainFile{\jobname.tex}% ".tex" needed for MiKTeX
100
\gdef\CurrentInput{\MainFile}
101
\newcount\INPSP
102
\global\INPSP=0
103
\def\EJECT{\SRC\eject}
104
\def\WinEdt#1{\typeout{:#1}}% WinEdt LOG MODE and INPUT
105
% ------------------------------------------------------------------------
106
%If your are using DVIWIN remove the \space from the definitions below...
107
\def\SRC{\ifSRCOK%
108
\ifnum\inputlineno>\LASTLINE%
109
\ifnum\LASTLINE<0%
110
\global\PAGETOP=\inputlineno%
111
\fi%
112
\global\LASTLINE=\inputlineno%
113
\ifnum\INPSP=0%
114
\ifnum\inputlineno>\PAGETOP%
115
\special{src:\the\inputlineno\space\CurrentInput}%
116
\fi%
117
\else%
118
\special{src:\the\inputlineno\space\CurrentInput}%
119
\fi%
120
\fi%
121
\fi}
122
% ------------------------------------------------------------------------
123
\def\PUSH#1{%
124
\SRC%
125
\ifnum\INPSP=0 \global\let\INPSTACKA=\CurrentInput \else%
126
\ifnum\INPSP=1 \global\let\INPSTACKB=\CurrentInput \else%
127
\ifnum\INPSP=2 \global\let\INPSTACKC=\CurrentInput \else%
128
\ifnum\INPSP=3 \global\let\INPSTACKD=\CurrentInput \else%
129
\ifnum\INPSP=4 \global\let\INPSTACKE=\CurrentInput \else%
130
\ifnum\INPSP=5 \global\let\INPSTACKF=\CurrentInput \else%
131
\global\let\INPSTACKX=\CurrentInput \fi\fi\fi\fi\fi\fi%
132
\gdef\CurrentInput{#1}%
133
\WinEdt{<+ \CurrentInput}%
134
\global\LASTLINE=0%
135
\ifSRCOK\special{src:1\CurrentInput}\fi%
136
\global\advance\INPSP by 1}
137
%
138
\def\POP{%
139
\ifnum\INPSP>0 \global\advance\INPSP by -1 \fi%
140
\ifnum\INPSP=0 \global\let\CurrentInput=\INPSTACKA \else%
141
\ifnum\INPSP=1 \global\let\CurrentInput=\INPSTACKB \else%
142
\ifnum\INPSP=2 \global\let\CurrentInput=\INPSTACKC \else%
143
\ifnum\INPSP=3 \global\let\CurrentInput=\INPSTACKD \else%
144
\ifnum\INPSP=4 \global\let\CurrentInput=\INPSTACKE \else%
145
\ifnum\INPSP=5 \global\let\CurrentInput=\INPSTACKF \else%
146
\global\let\CurrentInput=\INPSTACKX \fi\fi\fi\fi\fi\fi%
147
\WinEdt{<-}%
148
\global\LASTLINE=\inputlineno%
149
\global\advance\LASTLINE by -1%
150
\SRC}
151
% ------------------------------------------------------------------------
152
% Dummy Input: can be used as \INPUT{<file>.bbl} to collect \bibitems
153
\def\INPUT#1{\relax}
154
% ------------------------------------------------------------------------
155
% Redefine the original \include command
156
\let\OldINCLUDE=\include
157
\def\include#1{%Always ".tex" file type!
158
\EJECT%
159
\PUSH{#1.tex}%
160
\OldINCLUDE{#1}%
161
\POP}
162
% ------------------------------------------------------------------------
163
\def\Input#1{%Specify File Extension!
164
\PUSH{#1}%
165
\input #1%
166
\POP}
167
% ------------------------------------------------------------------------
168
% Note that these have been defined to concatenate the \SRC with
169
% whatever those token lists did before, just in case they were not
170
% empty token lists. Of course, later definitions may undo all this...
171
\let\originalxxxeverypar\everypar
172
\newtoks\everypar
173
\originalxxxeverypar{\the\everypar\expandafter\SRC}
174
%\everypar\expandafter{\the\everypar\expandafter\SRC}
175
% ??? Remove the following line if you encounter problems:
176
\everymath\expandafter{\the\everymath\expandafter\SRC}
177
% ------------------------------------------------------------------------
178
% Redefine the \bibliography command:
179
\let\zzzxxxbibliography=\bibliography
180
\def\bibliography#1{\PUSH{\jobname.bbl}\zzzxxxbibliography{#1}\POP}
181
%------------------------------------------------------------------------
182
% Modification to output routine to turn off \SRC while \output is active
183
\output\expandafter{\expandafter\SRCOKfalse\the\output}
184
%------------------------------------------------------------------------
185