| 1 |
% \iffalse meta-comment |
| 2 |
% This package is in the public domain. It comes with no guarantees |
| 3 |
% and no reserved rights. You can use or modify this package at your |
| 4 |
% own risk. |
| 5 |
% |
| 6 |
% Originally written by: Aleksander Simonic |
| 7 |
% Currently maintained by: Stefan Ulrich <[email protected]> |
| 8 |
% \fi |
| 9 |
% |
| 10 |
% \iffalse |
| 11 |
%<*package> |
| 12 |
%<latex>\NeedsTeXFormat{LaTeX2e} |
| 13 |
%<latex>\ProvidesPackage{srcltx}[2006/11/12 v1.6 Source specials for inverse search in DVI files] |
| 14 |
%</package> |
| 15 |
% |
| 16 |
%<*driver> |
| 17 |
\ProvidesFile{srcltx.drv}[2001/04/01 v1.0 Driver for srcltx package] |
| 18 |
\documentclass{ltxdoc} |
| 19 |
\usepackage{tabularx,calc} |
| 20 |
\IfFileExists{url.sty}{\RequirePackage{url}}{\newcommand\url{\texttt}} |
| 21 |
\EnableCrossrefs |
| 22 |
\CodelineIndex |
| 23 |
\RecordChanges |
| 24 |
\usepackage[inactive]{srcltx} |
| 25 |
\def\MainFile{srcltx.dtx} |
| 26 |
\newcommand\package{\textsf} |
| 27 |
\newcommand\file{\texttt} |
| 28 |
\renewcommand\topfraction{.85} |
| 29 |
\renewcommand\textfraction{.15} |
| 30 |
\renewcommand\floatpagefraction{.66} |
| 31 |
\newenvironment{descr}{% |
| 32 |
\renewcommand\descriptionlabel[1]{\hspace\labelsep\normalfont##1} |
| 33 |
\begin{description} |
| 34 |
}{% |
| 35 |
\end{description} |
| 36 |
} |
| 37 |
\DeclareRobustCommand\Com[1]{\texttt{\bslash #1}} |
| 38 |
\pagestyle{headings} |
| 39 |
\frenchspacing |
| 40 |
\usepackage[ |
| 41 |
pdftitle={Documentation for the srcltx package}, |
| 42 |
pdfauthor={Stefan Ulrich}, |
| 43 |
pdfsubject={srcltx}, |
| 44 |
pdfcreator={LaTeX/hyperref package}, |
| 45 |
colorlinks=true, |
| 46 |
% change ghastly default link colors |
| 47 |
linkcolor=blue,citecolor=blue,filecolor=blue,menucolor=blue,pagecolor=blue,urlcolor=blue, |
| 48 |
pdfpagemode=None, |
| 49 |
]{hyperref} |
| 50 |
% get rid of cheesy font settings ... |
| 51 |
\let\sldefault\itdefault |
| 52 |
\let\MakeUppercase\relax |
| 53 |
|
| 54 |
\OnlyDescription |
| 55 |
|
| 56 |
\begin{document} |
| 57 |
\DocInput{srcltx.dtx} |
| 58 |
\end{document} |
| 59 |
%</driver> |
| 60 |
% |
| 61 |
% \fi |
| 62 |
% |
| 63 |
% |
| 64 |
% \CheckSum{394} |
| 65 |
% |
| 66 |
% \CharacterTable |
| 67 |
% {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 |
| 68 |
% 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 |
| 69 |
% Digits \0\1\2\3\4\5\6\7\8\9 |
| 70 |
% Exclamation \! Double quote \" Hash (number) \# |
| 71 |
% Dollar \$ Percent \% Ampersand \& |
| 72 |
% Acute accent \' Left paren \( Right paren \) |
| 73 |
% Asterisk \* Plus \+ Comma \, |
| 74 |
% Minus \- Point \. Solidus \/ |
| 75 |
% Colon \: Semicolon \; Less than \< |
| 76 |
% Equals \= Greater than \> Question mark \? |
| 77 |
% Commercial at \@ Left bracket \[ Backslash \\ |
| 78 |
% Right bracket \] Circumflex \^ Underscore \_ |
| 79 |
% Grave accent \` Left brace \{ Vertical bar \| |
| 80 |
% Right brace \} Tilde \~} |
| 81 |
% |
| 82 |
% |
| 83 |
% \GetFileInfo{srcltx.sty} |
| 84 |
% |
| 85 |
% \title{\package{srcltx.sty} $\cdot$ \package{srctex.sty}} |
| 86 |
% \author{\normalsize Originally written by Aleksander Simonic\\ |
| 87 |
% \normalsize Currenlty maintained by\\ \normalsize Stefan Ulrich \href{mailto:[email protected]}{\texttt{<[email protected]>}}} |
| 88 |
% \date{\fileversion, \filedate} |
| 89 |
% \maketitle |
| 90 |
% |
| 91 |
% \begin{abstract}\noindent |
| 92 |
% This package provides source special insertion into DVI files, |
| 93 |
% allowing to jump from the DVI file to the \file{.tex} source |
| 94 |
% and back (given a DVI viewer that supports this). Additionally, |
| 95 |
% it provides hooks for error tracking from the \file{.log} file |
| 96 |
% for the WinEdt shell. |
| 97 |
% \end{abstract} |
| 98 |
% |
| 99 |
% \tableofcontents |
| 100 |
% |
| 101 |
% \section{Warning} |
| 102 |
% |
| 103 |
% \textbf{Source specials may alter the paragraph spacing |
| 104 |
% in your document. Always process the final version of your document with |
| 105 |
% this package commented out, or deactivated:} |
| 106 |
% |\usepackage[inactive]{srcltx}|. |
| 107 |
% |
| 108 |
% \section{Usage} |
| 109 |
% To use the package with \LaTeX, put the line |
| 110 |
% |
| 111 |
% |\usepackage{srcltx}| |
| 112 |
% |
| 113 |
% \noindent |
| 114 |
% into the preamble of your document. For \TeX, use |
| 115 |
% |
| 116 |
% |\input srctex.sty| |
| 117 |
% |
| 118 |
% \noindent |
| 119 |
% instead. This will insert source specials at every |
| 120 |
% start of a paragraph of your document and at every math environment |
| 121 |
% (see the `Options' section below for how to customize this). A source |
| 122 |
% special is only inserted if there hasn't already been one on the same |
| 123 |
% source input line. |
| 124 |
% |
| 125 |
% For editors and DVI viewers that support it, source specials can be used for |
| 126 |
% `inverse search' between the (La)\TeX\ source and the DVI file: |
| 127 |
% The \file{.dvi} viewer can open a text editor with the file |
| 128 |
% (and line) of the corresponding place in the \file{.tex} source |
| 129 |
% (also called `reverse search'), and the editor can invoke the previewer |
| 130 |
% with the corresponding place in the \file{.dvi} file (`forward search'). |
| 131 |
% Examples for DVI previewers supporting this are: The Windows viewers YAP and Dviwin, |
| 132 |
% and the Unix viewers xdvi(k) (versions $\geq$ 22.38) and KDVI (KDE $\geq$ 3.0). |
| 133 |
% Editors supporting inverse search are e.g. WinEdt, (X)Emacs, nedit and vim. |
| 134 |
% |
| 135 |
% The package was originally written for use with the WinEdt shell, and |
| 136 |
% it offers some special features to customize WinEdt's error |
| 137 |
% tracking. These are shown in the example in figure~\ref{ex} on page~\pageref{ex}. |
| 138 |
% |
| 139 |
% The specials inserted by this package have the following format, which should |
| 140 |
% be compatible with all DVI viewers: |
| 141 |
% |
| 142 |
% \begin{tabular}{@{}l@{}} |
| 143 |
% |\special{src:|\textit{line-number}\textvisiblespace\textit{filename}|}| |
| 144 |
% \end{tabular} |
| 145 |
% |
| 146 |
% |
| 147 |
% \subsection{Options} |
| 148 |
% |
| 149 |
% The following options are only available for the \LaTeX2e\ version of |
| 150 |
% this package. Unless noted otherwise, the Plain \TeX\ version \package{srctex.sty} |
| 151 |
% has a command |\SRC|$\langle$\texttt{foo}$\rangle$ for each option |
| 152 |
% $\langle$\texttt{foo}$\rangle$, e.g. |\SRCnopar| replaces the |
| 153 |
% `\texttt{nopar}' option. |
| 154 |
% \begin{descr} |
| 155 |
% |
| 156 |
% \item[\texttt{active}\slash\texttt{inactive}] |
| 157 |
% With the \texttt{inactive} option, source specials are disabled, but |
| 158 |
% the source file tracking for WinEdt is still active. |
| 159 |
% |
| 160 |
% The \texttt{active} option is only useful to override |
| 161 |
% a global \texttt{inactive} option. |
| 162 |
% |
| 163 |
% For \package{srctex.sty}, use \Com{SRCOKtrue} and \Com{SRCOKfalse} |
| 164 |
% instead. |
| 165 |
% |
| 166 |
% \item[\texttt{nowinedt}] Turn off the source file tracking used by WinEdt (the |
| 167 |
% |:<+ |\texttt{\textit{filename}} line in the output every time |
| 168 |
% an input file is opened, and the |:<-| line when it's closed again). |
| 169 |
% |
| 170 |
% \item[\texttt{dviwin}] Use specials in a format suitable for dviwin |
| 171 |
% (without a space between the line number and the filename). |
| 172 |
% |
| 173 |
% \item[\texttt{debug}] Print debugging information on current |
| 174 |
% input file and the input file stack. |
| 175 |
% \end{descr} |
| 176 |
% The following options can be used to turn off source specials for certain |
| 177 |
% environments; try these options if you encounter problems with the default behaviour: |
| 178 |
% \begin{descr} |
| 179 |
% \item[\texttt{nopar}] Don't hook into |\everypar|. |
| 180 |
% |
| 181 |
% \item[\texttt{nomath}] Don't hook into |\everymath|. |
| 182 |
% |
| 183 |
% %BROKEN \item[\texttt{nodisplay}] Don't hook into |\everydisplay|. |
| 184 |
% |
| 185 |
% \end{descr} |
| 186 |
% |
| 187 |
% \begin{figure} |
| 188 |
% \hrulefill |
| 189 |
% \footnotesize\begin{verbatim} |
| 190 |
% \documentclass{report} |
| 191 |
% \usepackage{srcltx} |
| 192 |
% % |
| 193 |
% % ... Preamble ... |
| 194 |
% % |
| 195 |
% \begin{document} |
| 196 |
% % |
| 197 |
% % ... Title, Author etc. ... |
| 198 |
% % |
| 199 |
% \WinEdt{?0000} % Do not process any errors (overful/underful boxes) |
| 200 |
% % ... Preface etc. ... |
| 201 |
% \WinEdt{?1111} % Process all types of errors from here on |
| 202 |
% \include{chapter1} |
| 203 |
% \include{chapter2} |
| 204 |
% \include{chapter3} |
| 205 |
% \bibliographystyle{plain} |
| 206 |
% \bibliography{xbib} |
| 207 |
% \end{document} |
| 208 |
% \end{verbatim} |
| 209 |
% \hrulefill |
| 210 |
% \caption{Example for using \package{srcltx.sty} with the WinEdt error tracking features.}\label{ex} |
| 211 |
% \end{figure} |
| 212 |
% |
| 213 |
% \subsection{Commands} |
| 214 |
% \begin{descr} |
| 215 |
% |
| 216 |
% \item[\Com{Input}\marg{filename}] In order to keep track |
| 217 |
% of the current filename, the \LaTeX\ commands |
| 218 |
% \Com{include}\marg{filename} and \Com{input}\marg{filename} |
| 219 |
% are overloaded (note the braces enclosing the filename argument). The |
| 220 |
% \Com{input} command where the filename can be specified |
| 221 |
% without any delimiters is a \TeX\ primitive command that can |
| 222 |
% not be overloaded easily. Therefore the package provides an |
| 223 |
% alternative command |\Input| which you should use in Plain |
| 224 |
% \TeX\ instead of \Com{input} if you want the specials in such |
| 225 |
% files to point to the correct filename. For \LaTeX, you |
| 226 |
% should always use the version with braces: |
| 227 |
% \Com{input}\marg{filename}. \emph{Note}: For Winedt, you will |
| 228 |
% also need to specify the file name extension (e.g. |
| 229 |
% \file{.tex}) in the argument of this command. |
| 230 |
% |
| 231 |
% \item[\Com{MainFile}] Usually the \TeX\ primitive |\jobname| contains the name of the |
| 232 |
% ``main'' TeX file, without the filename extension `\file{.tex}'. |
| 233 |
% Accordingly, |\MainFile| is defined as |\jobname.tex|. |
| 234 |
% If you have a very awkward \TeX\ implementation that already adds the extension |
| 235 |
% to |\jobname|, you compensate for this by redefining this command as follows |
| 236 |
% (after loading \package{srcltx.sty}): |
| 237 |
% |
| 238 |
% \noindent\begin{tabular}{@{}l@{}} |
| 239 |
% |\def\MainFile{\jobname}| |
| 240 |
% \end{tabular} |
| 241 |
% |
| 242 |
% \item[\Com{srcIncludeHook}] This is a hook that is called by the \Com{include} |
| 243 |
% command. It takes the argument of that command and sets \Com{CurrentInput} |
| 244 |
% to that argument (or a modified version thereof); the content of \Com{CurrentInput} |
| 245 |
% is used as file name in the source specials. This hook can be used |
| 246 |
% to write a customized file name into the source specials. For example, |
| 247 |
% if the \file{.tex} source file is automatically generated from some |
| 248 |
% master document, the source specials in the DVI file could point |
| 249 |
% to that master document instead of the generated \file{.tex} file. |
| 250 |
% |
| 251 |
% Its default definition is: |
| 252 |
% |
| 253 |
% \noindent\begin{tabular}{@{}l@{}} |
| 254 |
% |\newcommand*\srcIncludeHook[1]{% |\\ |
| 255 |
% | \protected@xdef\CurrentInput{#1.tex}}| |
| 256 |
% \end{tabular} |
| 257 |
% |
| 258 |
% \noindent |
| 259 |
% (for \LaTeX, similar with \Com{def} for \TeX). |
| 260 |
% |
| 261 |
% \item[\Com{srcInputHook}] This is similar to \Com{srcIncludeHook}, but for the \Com{input} |
| 262 |
% command. |
| 263 |
% |
| 264 |
% Its default definition is: |
| 265 |
% |
| 266 |
% \noindent\begin{tabular}{@{}l@{}} |
| 267 |
% |\newcommand*\srcInputHook[1]{\src@getfilename@with@ext{#1}}| |
| 268 |
% \end{tabular} |
| 269 |
% |
| 270 |
% \noindent |
| 271 |
% (for \LaTeX, similar with \Com{def} for \TeX); \Com{src@getfilename@with@ext} |
| 272 |
% will append a `.tex' extension to the filename if it doesn't already end |
| 273 |
% with `.tex'. |
| 274 |
% |
| 275 |
% \item[\Com{SRCOKtrue}, \Com{SRCOKfalse}] You can use these commands to |
| 276 |
% activate\slash deactivate source specials at any place in your |
| 277 |
% document, e.g. when you experience problems with some special |
| 278 |
% constructions (see also `Bugs and Restrictions' in section |
| 279 |
% \ref{sec:bugs}). |
| 280 |
% |
| 281 |
% \end{descr} |
| 282 |
% |
| 283 |
% \section{Bugs and Restrictions}\label{sec:bugs} |
| 284 |
% |
| 285 |
% Since this macro package overloads some internal \LaTeX\ commands, it |
| 286 |
% is not as robust as one might wish, and might interact badly with other |
| 287 |
% packages. Furthermore, the spacing might be altered by using the |
| 288 |
% package; for example, with the \file{amsmath} documentation \file{amsldoc.tex}, |
| 289 |
% the bibliography is shifted from the bottom of page 31 to page 32. |
| 290 |
% Therefore you should comment out the package or disable it with the |
| 291 |
% \texttt{inactive} option when preparing the final version of your document. |
| 292 |
% |
| 293 |
% A somewhat more robust method of inserting source specials is to use \TeX\ |
| 294 |
% (the program) instead of a macro solution. Some \TeX\ implementations |
| 295 |
% provide a command line option for this.\footnote{% |
| 296 |
% E.g. a `\file{-src}' option is available in Mik\TeX\ from version 1.20 upwards, |
| 297 |
% or in te\TeX\ from version beta-20011103 or teTeX-2.0 upwards. See the manual of your |
| 298 |
% \TeX\ implementation for details on this.} |
| 299 |
% You can still load \package{srcltx.sty} with the `\texttt{inactive}' option to enable |
| 300 |
% the WinEdt error tracking features when needed. |
| 301 |
% |
| 302 |
% This section lists known incompatibilities with other packages and workarounds for these. |
| 303 |
% If you know of any other problems, please send a bug report to |
| 304 |
% \href{mailto:[email protected]}{\texttt{<[email protected]>}}. |
| 305 |
% \begin{description} |
| 306 |
% \item[{\normalfont\package{soul.sty}:}] Active source specials inside |
| 307 |
% the soul tokenization routine may lead to a `reconstruction failed' |
| 308 |
% error. As a workaround, the internal command |\SOUL@| is overloaded |
| 309 |
% by \package{srcltx}. With the Plain \TeX\ version, \package{srctex.sty} |
| 310 |
% needs to be loaded \emph{after} \package{soul.sty} to make this work. |
| 311 |
% \item[{\normalfont\package{syntax.sty}:}] This style does extensive parsing |
| 312 |
% of the input inside its `grammar' environment, which is incompatible |
| 313 |
% with \package{srcltx.sty}. |
| 314 |
% \end{description} |
| 315 |
% |
| 316 |
% \section{Related Packages} |
| 317 |
% |
| 318 |
% Heiko Oberdiek's \package{vpe.sty} provides source specials for |
| 319 |
% forward search in PDF files. To our knowledge there exists no |
| 320 |
% implementation for reverse search with PDF viewers, or inverse search |
| 321 |
% in Postscript documents. |
| 322 |
% |
| 323 |
% \section{History} |
| 324 |
% |
| 325 |
% This package was originally written by A.~Simonic, the author of the WinEdt Shell, |
| 326 |
% to implement source file tracking and DVI source specials |
| 327 |
% for \TeX. D.~P.~Carlisle and B.~K.~Horn have contributed bug |
| 328 |
% fixes. Further changes and conversion to \file{ltxdoc} format by S.~Ulrich. |
| 329 |
% Thanks for patches and suggestions to: A.~Cherepanov, J.~Rawnsley, D.~Kastrup, |
| 330 |
% D.~Arseneau, M.~S.~Gr\o nsleth and R.~Hemmecke. |
| 331 |
% |
| 332 |
% |
| 333 |
% \StopEventually{} |
| 334 |
% \section{Implementation} |
| 335 |
% |
| 336 |
% \changes{v1.6}{2006/11/12}{Provide \Com{srcInputHook} and \Com{srcIncludeHook} for changing |
| 337 |
% the input filename on-the-fly, |
| 338 |
% as requested by Ralf Hemmecke for his Axiom and ALLPROSE packages. |
| 339 |
% Also fixed \Com{src@getfilename@with@ext} so that it doesn't append `.tex' any |
| 340 |
% more in cases where the filename had a complex extension (e.g. `foo.bar.tex') |
| 341 |
% with the last element `.tex'.} |
| 342 |
% \changes{v1.5}{2004/10/05}{Fixed version number in documentation, and made \Com{input} append .tex |
| 343 |
% extension if not yet present (feature requested by Martin Sigurd Gr\o nsleth).} |
| 344 |
% \changes{v1.4}{2004/05/15}{Fixed \Com{everypar} hook, as suggested by David Kastrup in comp.text.tex, |
| 345 |
% for compatibility with chapterbib.sty} |
| 346 |
% \changes{v1.3}{2003/03/10}{Also hook into \Com{everydisplay}; unreleased since this change broke |
| 347 |
% regression for gentle.tex} |
| 348 |
% \changes{v1.2c}{2002/03/01}{Added the `nowinedt' option} |
| 349 |
% \changes{v1.2b}{2002/01/23}{Fixed spurious space introduced by uncommented linebreak} |
| 350 |
% \changes{v1.2}{2002/01/21}{Replace stack by macro solution, as suggested by |
| 351 |
% Alexander Cherepanov (cherepan at mccme.ru). |
| 352 |
% Also overload LaTeX's \Com{input} command.} |
| 353 |
% \changes{v1.1a}{2001/07/14}{Minor fixes in the documentation.} |
| 354 |
% \changes{v1.1}{2001/03/31}{SU: converted to ltxdoc format, changed the |
| 355 |
% push\slash pop commands to use a `real' stack, |
| 356 |
% other minor modifications} |
| 357 |
% \changes{v1.002}{1999/09/03}{modified to change \Com{everypar}, by David Carlisle} |
| 358 |
% \changes{v1.001}{1998/12/23}{modified to change \Com{output}, by Berthold Horn} |
| 359 |
% |
| 360 |
% |
| 361 |
% \begin{macrocode} |
| 362 |
%<*package> |
| 363 |
%<tex>\catcode`\@=11 |
| 364 |
\newif\ifSRCOK \SRCOKtrue |
| 365 |
\newif\ifsrc@debug@ |
| 366 |
\newif\ifsrc@dviwin@ |
| 367 |
\newif\ifsrc@winedt@\src@winedt@true |
| 368 |
\newif\ifsrc@everypar@\src@everypar@true |
| 369 |
\newif\ifsrc@everymath@\src@everymath@true |
| 370 |
%<*latex> |
| 371 |
\RequirePackage{ifthen} |
| 372 |
\DeclareOption{active}{\SRCOKtrue} |
| 373 |
\DeclareOption{inactive}{\SRCOKfalse} |
| 374 |
\DeclareOption{nowinedt}{\src@winedt@false} |
| 375 |
\DeclareOption{debug}{\src@debug@true} |
| 376 |
\DeclareOption{nopar}{\global\src@everypar@false} |
| 377 |
\DeclareOption{nomath}{\global\src@everymath@false} |
| 378 |
%</latex> |
| 379 |
%<*tex> |
| 380 |
\def\SRCdebug{\src@debug@true} |
| 381 |
\def\SRCnopar{\src@everypar@false} |
| 382 |
\def\SRCnomath{\src@everymath@false} |
| 383 |
\def\typeout#1{{\newlinechar`\^^J\message{#1^^J}}} |
| 384 |
\def\AtBeginDocument#1{#1} |
| 385 |
%</tex> |
| 386 |
%<latex>\newcommand*\src@maybe@space{} |
| 387 |
\let\src@maybe@space\space |
| 388 |
%<latex>\DeclareOption{dviwin}{\let\src@maybe@space\relax} |
| 389 |
% \end{macrocode} |
| 390 |
% SU: Originally the default was |\ExecuteOptions{inactive}|, but this |
| 391 |
% was rather unintuitive, so I changed it. |
| 392 |
% \begin{macrocode} |
| 393 |
%<latex>\ExecuteOptions{active} |
| 394 |
%<latex>\ProcessOptions |
| 395 |
\newcount\src@lastline |
| 396 |
\global\src@lastline=-1 |
| 397 |
%<latex>\newcommand*\src@debug{} |
| 398 |
\def\src@debug#1{\ifsrc@debug@\typeout{DBG: |#1|}\fi} |
| 399 |
% \end{macrocode} |
| 400 |
% \begin{macro}{\MainFile} |
| 401 |
% This is for compatibility with \TeX\ implementations that add already |
| 402 |
% the `\file{.tex}' extension to \Com{jobname} (very rare): |
| 403 |
% \begin{macrocode} |
| 404 |
%<latex>\newcommand*\MainFile{} |
| 405 |
\def\MainFile{\jobname.tex} |
| 406 |
% \end{macrocode} |
| 407 |
% \end{macro} |
| 408 |
% \begin{macro}{\CurrentInput} |
| 409 |
% Used to keep track of current input file name: |
| 410 |
% \begin{macrocode} |
| 411 |
%<latex>\newcommand*\CurrentInput{} |
| 412 |
\gdef\CurrentInput{\MainFile} |
| 413 |
% \end{macrocode} |
| 414 |
% \end{macro} |
| 415 |
% Command to customize WinEdt's log mode, and enable its input file |
| 416 |
% tracking. This is switched off when the option \texttt{nowinedt} is |
| 417 |
% selected. |
| 418 |
% \begin{macrocode} |
| 419 |
%<latex>\newcommand*\WinEdt{} |
| 420 |
\def\WinEdt#1{\ifsrc@winedt@\typeout{:#1}\fi} |
| 421 |
% \end{macrocode} |
| 422 |
% A hook for \package{soul}, which might otherwise break with |
| 423 |
% a `reconstruction failed' error: |
| 424 |
% \begin{macrocode} |
| 425 |
%<latex>\newcommand\src@AfterFi{} |
| 426 |
\def\src@AfterFi#1\fi{\fi#1} |
| 427 |
\AtBeginDocument{% |
| 428 |
%<latex> \@ifpackageloaded{soul}{% |
| 429 |
%<tex>\ifx\SOUL@\relax |
| 430 |
%<tex>\else |
| 431 |
\let\src@SOUL@\SOUL@ |
| 432 |
\def\SOUL@#1{% |
| 433 |
\ifSRCOK |
| 434 |
\SRCOKfalse\src@SOUL@{#1}\SRCOKtrue |
| 435 |
\else |
| 436 |
\src@AfterFi\src@SOUL@{#1}% |
| 437 |
\fi |
| 438 |
}% |
| 439 |
%<tex>\fi |
| 440 |
%<latex> }{}% |
| 441 |
} |
| 442 |
% \end{macrocode} |
| 443 |
% \begin{macro}{\srcIncludeHook} |
| 444 |
% Hook to set the name of the current input file (\Com{CurrentInput}) for the \Com{include} command. |
| 445 |
% \begin{macrocode} |
| 446 |
%<latex>\newcommand*\srcIncludeHook[1]{\protected@xdef\CurrentInput{#1.tex}} |
| 447 |
%<tex>\def\srcIncludeHook#1{\xdef\CurrentInput{#1.tex}} |
| 448 |
% \end{macrocode} |
| 449 |
% \end{macro} |
| 450 |
% |
| 451 |
% \begin{macro}{\srcInputHook} |
| 452 |
% Hook to set the name of the current input file (\Com{CurrentInput}) for the \Com{Input} command. |
| 453 |
% \begin{macrocode} |
| 454 |
%<latex>\newcommand*\srcInputHook[1]{% |
| 455 |
%<tex>\def\srcInputHook#1{% |
| 456 |
\src@getfilename@with@ext{#1}% |
| 457 |
} |
| 458 |
% \end{macrocode} |
| 459 |
% \end{macro} |
| 460 |
% |
| 461 |
% \begin{macro}{\src@spec} |
| 462 |
% Macro that actually inserts the special. |
| 463 |
% \begin{macrocode} |
| 464 |
%<latex>\newcommand*\src@spec{} |
| 465 |
\def\src@spec{% |
| 466 |
\ifSRCOK |
| 467 |
\ifnum\inputlineno>\src@lastline |
| 468 |
\global\src@lastline=\inputlineno |
| 469 |
\src@debug{% |
| 470 |
src:\the\inputlineno\src@maybe@space\CurrentInput}% |
| 471 |
\special{src:\the\inputlineno\src@maybe@space\CurrentInput}% |
| 472 |
\fi |
| 473 |
\fi |
| 474 |
} |
| 475 |
% \end{macrocode} |
| 476 |
% \end{macro} |
| 477 |
% |
| 478 |
% \begin{macro}{\src@before@file@hook} |
| 479 |
% \begin{macro}{\src@after@file@hook} |
| 480 |
% Hooks executed before and after a level of input happens: |
| 481 |
% \begin{macrocode} |
| 482 |
%<latex>\newcommand\src@before@file@hook{} |
| 483 |
%<latex>\newcommand\src@after@file@hook{} |
| 484 |
\def\src@before@file@hook{% |
| 485 |
\WinEdt{<+ \CurrentInput}% |
| 486 |
\global\src@lastline=0 |
| 487 |
\ifSRCOK\special{src:1\src@maybe@space\CurrentInput}\fi |
| 488 |
} |
| 489 |
\def\src@after@file@hook#1{% |
| 490 |
\WinEdt{<-}% |
| 491 |
\global\src@lastline=\inputlineno |
| 492 |
\global\advance\src@lastline by -1% |
| 493 |
\gdef\CurrentInput{#1}% |
| 494 |
\src@spec |
| 495 |
} |
| 496 |
% \end{macrocode} |
| 497 |
% \end{macro} |
| 498 |
% \end{macro} |
| 499 |
% |
| 500 |
% \begin{macro}{\src@getfilename@with@ext} |
| 501 |
% Check if \verb+#1+ has the extension `.tex', and if not, append it, saving the |
| 502 |
% result to \Com{CurrentInput}. \emph{Warning:} This does not completely mimick |
| 503 |
% the behaviour of \Com{input}, since it also expands a filename `foo.sty' to |
| 504 |
% `foo.sty.tex' even if `foo.sty' exists. However in the context of this |
| 505 |
% package that doesn't matter much since we assume that files that don't have |
| 506 |
% a `.tex' extension won't create any content in the DVI file. |
| 507 |
% |
| 508 |
% The command \Com{src@extensions@path} is similar to \Com{filename@parse} |
| 509 |
% from \file{latex.ltx}. |
| 510 |
% \begin{macrocode} |
| 511 |
%<*latex> |
| 512 |
\newcommand*\src@fname{}% |
| 513 |
\newcommand*\src@tempa{}% |
| 514 |
\newcommand*\src@extensions@path{}% |
| 515 |
\newcommand*\src@getfilename@with@ext{}% |
| 516 |
%</latex> |
| 517 |
%<*tex> |
| 518 |
\def\src@tempa{}% |
| 519 |
%</tex> |
| 520 |
\def\src@extensions@path#1.#2\end{% |
| 521 |
%<*latex> |
| 522 |
\ifthenelse{\equal{#2}{}}{% |
| 523 |
\protected@edef\src@extensions@last{#1}% |
| 524 |
\let\src@tempa\relax |
| 525 |
}{% |
| 526 |
\def\src@tempa{\src@extensions@path#2\end}% |
| 527 |
}% |
| 528 |
%</latex> |
| 529 |
%<*tex> |
| 530 |
\ifx\\#2\\ |
| 531 |
\edef\src@extensions@last{#1}% |
| 532 |
\let\src@tempa\relax |
| 533 |
\else |
| 534 |
\def\src@tempa{\src@extensions@path#2\end}% |
| 535 |
\fi |
| 536 |
%</tex> |
| 537 |
\src@tempa |
| 538 |
} |
| 539 |
\def\src@getfilename@with@ext#1{% |
| 540 |
\expandafter\src@extensions@path#1.\end |
| 541 |
%<*latex> |
| 542 |
\ifthenelse{\equal{\src@extensions@last}{tex}}{% |
| 543 |
\protected@xdef\CurrentInput{#1}% |
| 544 |
}{% |
| 545 |
\protected@xdef\CurrentInput{#1.tex}% |
| 546 |
}% |
| 547 |
\PackageInfo{srcltx}{Expanded filename `#1' to `\CurrentInput'}% |
| 548 |
%</latex> |
| 549 |
%<*tex> |
| 550 |
\def\src@tempa{tex}% |
| 551 |
\ifx\src@extensions@last\src@tempa |
| 552 |
\xdef\CurrentInput{#1}% |
| 553 |
\else |
| 554 |
\xdef\CurrentInput{#1.tex}% |
| 555 |
\fi |
| 556 |
%</tex> |
| 557 |
} |
| 558 |
% \end{macrocode} |
| 559 |
% \end{macro} |
| 560 |
% |
| 561 |
% \begin{macro}{\include} |
| 562 |
% Redefine the original \Com{include} command. This is done for LaTeX only. |
| 563 |
% The \file{.tex} extension is added to the argument. |
| 564 |
% \begin{macrocode} |
| 565 |
%<*latex> |
| 566 |
\newcommand*\src@include{} |
| 567 |
\newcommand*\src@@include{} |
| 568 |
\let\src@include\include |
| 569 |
\def\include#1{% |
| 570 |
\src@spec |
| 571 |
\clearpage |
| 572 |
\expandafter\src@@include\expandafter{\CurrentInput}{#1}% |
| 573 |
}% |
| 574 |
\def\src@@include#1#2{% |
| 575 |
\srcIncludeHook{#2}% |
| 576 |
\src@before@file@hook |
| 577 |
\src@include{#2}% |
| 578 |
\src@after@file@hook{#1}% |
| 579 |
} |
| 580 |
%</latex> |
| 581 |
% \end{macrocode} |
| 582 |
% \end{macro} |
| 583 |
% |
| 584 |
% \begin{macro}{\input} |
| 585 |
% For \Com{input}, we can only overload the LaTeX syntax, i.e. the usage |
| 586 |
% with the argument in braces. For plain \TeX, we provide an alternative command |
| 587 |
% \Com{Input} that can be used instead of \Com{input}. We can't redefine |
| 588 |
% \Com{input}, since that is a \TeX\ primitive with a different way of parsing |
| 589 |
% the argument line. |
| 590 |
% |
| 591 |
% A \file{.tex} extension is added to the argument if it's not already present. |
| 592 |
% \begin{macrocode} |
| 593 |
%<*latex> |
| 594 |
\newcommand*\src@input{} |
| 595 |
\newcommand*\src@@input{} |
| 596 |
\newcommand*\src@@@input{} |
| 597 |
%</latex> |
| 598 |
\let\src@input\input |
| 599 |
%<*latex> |
| 600 |
\def\input{\src@spec\@ifnextchar\bgroup\src@@input\@@input}% |
| 601 |
% \end{macrocode} |
| 602 |
% \Com{@@input} is \LaTeX's alias for \TeX's \Com{input} command. |
| 603 |
% \begin{macrocode} |
| 604 |
\def\src@@input#1{% |
| 605 |
\expandafter\src@@@input\expandafter{\CurrentInput}{#1}% |
| 606 |
} |
| 607 |
\def\src@@@input#1#2{% |
| 608 |
\srcInputHook{#2}% |
| 609 |
\src@before@file@hook |
| 610 |
\src@input{#2}% |
| 611 |
\src@after@file@hook{#1}% |
| 612 |
} |
| 613 |
%</latex> |
| 614 |
% \end{macrocode} |
| 615 |
% \end{macro} |
| 616 |
% \begin{macro}{\Input} |
| 617 |
% \begin{macrocode} |
| 618 |
%<*tex> |
| 619 |
\def\Input#1{% |
| 620 |
\expandafter\src@Input\expandafter{\CurrentInput}{#1}% |
| 621 |
} |
| 622 |
\def\src@Input#1#2{% |
| 623 |
\srcInputHook{#2}% |
| 624 |
\src@before@file@hook |
| 625 |
\src@input #2 |
| 626 |
\src@after@file@hook{#1}% |
| 627 |
} |
| 628 |
%</tex> |
| 629 |
% \end{macrocode} |
| 630 |
% For \LaTeX, \Com{Input} is just an alias for \Com{input}: |
| 631 |
% \begin{macrocode} |
| 632 |
%<*latex> |
| 633 |
\newcommand\Input{} |
| 634 |
\let\Input\input |
| 635 |
%</latex> |
| 636 |
% \end{macrocode} |
| 637 |
% \end{macro} |
| 638 |
% Hook into `everypar'. This should concatenate the \Com{src@spec} with |
| 639 |
% whatever those token lists contained before, just in case they were not |
| 640 |
% empty token lists (hoping that later hooks will do the same). David Kastrup |
| 641 |
% writes in \url{<[email protected]>}: |
| 642 |
% \begin{quote} |
| 643 |
% You need \emph{two} new tokens |
| 644 |
% for a proper subversion. One to save the old meaning in when the |
| 645 |
% package is loaded, and one to refer to [\dots] the old meaning at |
| 646 |
% the time the package is running, even if somebody else subverts the |
| 647 |
% \Com{everypar} token again. |
| 648 |
% \end{quote} |
| 649 |
% \begin{macrocode} |
| 650 |
\ifsrc@everypar@ |
| 651 |
%<latex> \newcommand*\src@old@everypar{} |
| 652 |
\let\src@old@everypar\everypar |
| 653 |
\newtoks\src@new@everypar |
| 654 |
\let\everypar\src@new@everypar |
| 655 |
\everypar\expandafter{\the\src@old@everypar} |
| 656 |
\src@old@everypar{\the\src@new@everypar\src@spec} |
| 657 |
\fi |
| 658 |
% \end{macrocode} |
| 659 |
% Use the `nomath' option to disable the following: |
| 660 |
% \begin{macrocode} |
| 661 |
\ifsrc@everymath@ |
| 662 |
%<*latex> |
| 663 |
\def\@tempa#1\the\everymath#2\delimiter{{#1\src@spec\the\everymath#2}} |
| 664 |
\frozen@everymath=\expandafter\@tempa\the\frozen@everymath\delimiter |
| 665 |
%</latex> |
| 666 |
%<*tex> |
| 667 |
\everymath\expandafter{\the\everymath\src@spec} |
| 668 |
%</tex> |
| 669 |
\fi |
| 670 |
% \end{macrocode} |
| 671 |
% \begin{macro}{\bibliography} |
| 672 |
% Hook into the \Com{bibliography} command: |
| 673 |
% \begin{macrocode} |
| 674 |
%<*latex> |
| 675 |
\newcommand*\src@bibliography{} |
| 676 |
\newcommand*\src@@bibliography{} |
| 677 |
\let\src@bibliography\bibliography |
| 678 |
\def\bibliography#1{% |
| 679 |
\expandafter\src@@bibliography\expandafter{\CurrentInput}{#1}% |
| 680 |
} |
| 681 |
\def\src@@bibliography#1#2{% |
| 682 |
%<latex> \protected@xdef\CurrentInput{\jobname.bbl}% |
| 683 |
%<tex> \xdef\CurrentInput{\jobname.bbl}% |
| 684 |
\src@before@file@hook |
| 685 |
\src@bibliography{#2}% |
| 686 |
\src@after@file@hook{#1}% |
| 687 |
} |
| 688 |
%</latex> |
| 689 |
% \end{macrocode} |
| 690 |
% \end{macro} |
| 691 |
% Hook into output routine to turn off \Com{src@spec} while \Com{output} is active: |
| 692 |
% \begin{macrocode} |
| 693 |
%<latex>\newcommand*\src@old@output{} |
| 694 |
\let\src@old@output\output |
| 695 |
\newtoks\src@new@output |
| 696 |
\let\output\src@new@output |
| 697 |
\output\expandafter{\the\src@old@output} |
| 698 |
\src@old@output{\SRCOKfalse\the\src@new@output} |
| 699 |
%<tex>\catcode`\@=12 |
| 700 |
%</package> |
| 701 |
% \end{macrocode} |
| 702 |
% \Finale |
| 703 |
\endinput |