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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
|
% LaTeX package pdfsync.sty
% =========================
%
% Presentation
% ------------
% pdfsync.sty allows one to synchronize between LaTeX source and pdf output.
% When used with a text editor and a PDF viewer that both support pdfsync,
% you can navigate from the source to the output and vice versa.
% This is some kind of srcltx ported from dvi to pdf.
%
% When you typeset foo.tex with pdfsync.sty and either pdfetex or xetex, a foo.pdfsync auxiliary file is created.
% It only contains geometrical information used by text editors or PDF viewers for synchronization.
% You can delete this file when you are done.
%
% Actually, iTeXMac, iTeXMac2, TeXShop, TextMate, AucTeX are text editors implementing pdfsync support at various level.
% iTeXMac, iTeXMac2, TeXShop, TeXniscope, PDFView are PDF viewers implementing pdfsync support at various level.
%
% Version
% -------
% - 01/25/2008: This is the second version officially available.
% Some internals were modified in order to provide a stronger
% \pdfsyncstart, \pdfsyncstop pair.
% Anticipating over pdftex improvements, this package will load with option "off" if the \synchronize macro is defined
%
% Install
% -------
% If this package is not already included in you TeX distribution, just copy the pdfsync.sty file to the proper location.
% On Mac OS X, it can be
% YOUR_HOME_DIRECTORY/Library/texmf/tex/latex/graphics/graphics.sty
% where you should replace YOUR_HOME_DIRECTORY by its actual value.
%
% Usage
% -----
% Put \usepackage{pdfsync} in your LaTeX preamble.
%
% In case of sever conflicts with another package, try \usepackage[novbox]{pdfsync} instead.
%
% If pdfsync only breaks some part of your LaTeX code, you can try to enclose it in a \pdfsyncstop \pdfsyncstart pair.
% If you want to add more control point add \pdfsync at sensible locations in your code.
% In that case, \usepackage[off]{pdfsync} will disable pdf synchronization and \relax the above commands.
%
% Use option nohbox (resp nocr, nopar, nomath, nodisplay) in order not to add control points every hbox (resp cr, par, math,display)
%
% Bugs
% ----
% pdfsync uses extremely severe code. You should not use pdfsync on final documents because it can change the layout rather significantly
% (different page/line breaks are the most obvious changes), despite this is rather rare,
% 17.8th Murphy's law states that it will happen to you when it absolutely must not...
%
% You should report bugs and package conflicts to jlaurens AT users DOT sourceforge DOT net.
%
% The accuracy of pdf synchronization depends on the editor/viewer used for that purpose.
% iTeXMac2 is actually the most accurate implementation because it combines pdfsync with pdf searching.
% So, the lack of accuracy is not a bug in pdfsync a priori.
%
% Credits:
% -------
% The original idea of pdfsync was proposed by Piero D'Ancona in the summer of 2003.
% He and Jerome Laurens (jlaurens AT usersDOT sourceforge DOT net) both created the first working package.
% Hans Hagen and David Kastrup made very significant enhancements to the original code.
%
% License
% -------
% This program is free software; you can redistribute it and/or modify
% it under the terms of the The LaTeX Project Public License version 1.3c at least
% http://www.latex-project.org/lppl.txt
%
% Home page
% ---------
% The official site is
%
% http://itexmac.sourceforge.net/pdfsync.html
%
% copyright 2006-2008, jlaurens AT users DOT sourceforge DOT net
%
\ifx\pdfsync\undefined\else\message{**** pdfsync.sty: WARNING, the package is already loaded.}\expandafter\endinput\fi
\def\c@nfigPDFSYNC@ff{%
\let\pdfsync\relax%
\let\pdfsyncstart\relax%
\let\pdfsyncstop\relax%
}%
\ifx\synchronize\undefined\else
\message{**** pdfsync.sty: WARNING, the package is obsolete with this version of pdftex.}%
\c@nfigPDFSYNC@ff
\let\c@nfigPDFSYNC@ff=\undefined
\expandafter\endinput
\fi
\ifx\pdfsavepos\undefined
\message{**** pdfsync.sty: WARNING, synchronization is only available with pdftex like engines.}%
\c@nfigPDFSYNC@ff
\let\c@nfigPDFSYNC@ff=\undefined
\expandafter\endinput
\fi
% Defining the preamble of the style file:
\NeedsTeXFormat{LaTeX2e}%
\ProvidesPackage{pdfsync}[2008/01/26 v1.1]%
% start of the code
\let\c@nfigPDFSYNCp@r\relax%
\let\c@nfigPDFSYNCm@th\relax%
\let\c@nfigPDFSYNCdispl@y\relax%
\let\c@nfigPDFSYNChb@x\relax%
\let\c@nfigPDFSYNCvb@x\relax%
\let\c@nfigPDFSYNC@cr\relax%
% Subverting |\everypar| to prepend pdfsync |\@PDFSYNC| specific code that will
% be executed for each new paragraph.
%This was primarly suggested by Curtis Clifton on 12/17/2004 (google "subvert token" for details).
\def\c@nfigPDFSYNCp@r{\wlog{**** pdfsync.sty: Synchronizing at \string\everypar}%
\newtoks\PDFSYNCeveryp@r
\PDFSYNCeveryp@r\everypar
\everypar{\bgroup\setbox\z@\lastbox\@PDFSYNC\box\z@\egroup
\the\PDFSYNCeveryp@r}%
\let\everypar\PDFSYNCeveryp@r
}%
%
\def\c@nfigPDFSYNCdispl@y{\wlog{**** pdfsync.sty: Synchronizing at \string\everydisplay}%
\newtoks\PDFSYNCeverydispl@y
\PDFSYNCeverydispl@y\frozen@everydisplay
\frozen@everydisplay{\@PDFSYNC\the\PDFSYNCeverydispl@y}%
\let\frozen@everydisplay\PDFSYNCeverydispl@y
}%
%
\def\c@nfigPDFSYNCm@th{\wlog{**** pdfsync.sty: Synchronizing at \string\everymath}%
\newtoks\PDFSYNCeverym@th
\PDFSYNCeverym@th\frozen@everymath
\frozen@everymath{\@PDFSYNC\the\PDFSYNCeverym@th}%
\let\frozen@everymath\PDFSYNCeverym@th
}%
%
\def\c@nfigPDFSYNChb@x{\wlog{**** pdfsync.sty: Synchronizing at \string\everyhbox}%
\newtoks\PDFSYNCeveryhb@x
\PDFSYNCeveryhb@x\everyhbox
\everyhbox{\PDFSYNCeveryhb@xcontent}%
\def\PDFSYNCeveryhb@xon{\ifPDFSYNC@unblocked
\begingroup
\PDFSYNC@unblockedfalse
\setbox\z@\hbox\bgroup
\@PDFSYNC
\setbox\z@\hbox\bgroup\bgroup
\aftergroup\PDFSYNC@endhbox
\the\PDFSYNCeveryhb@x
\PDFSYNC@unblockedtrue\fi}
\def\PDFSYNCeveryhb@xoff{\the\PDFSYNCeveryhb@x}
\let\everyhbox\PDFSYNCeveryhb@x
\def\PDFSYNC@endhbox{\ifnum\lastnodetype>\m@ne
\egroup \unhbox\z@ \egroup \unhbox\z@
\else \egroup \egroup \fi \endgroup \egroup}%
}%
%
\def\c@nfigPDFSYNCvb@x{\wlog{**** pdfsync.sty: Synchronizing at \string\everyvbox}%
\newtoks\PDFSYNCeveryvb@x
\PDFSYNCeveryvb@x\everyvbox
\everyvbox{\PDFSYNCeveryvb@xcontent}%
\def\PDFSYNCeveryvb@xon{\ifPDFSYNC@unblocked
\begingroup
\PDFSYNC@unblockedfalse
\setbox\z@\vbox\bgroup
\@PDFSYNC
\setbox\z@\vtop\bgroup\bgroup
\aftergroup\PDFSYNC@endvbox
\the\PDFSYNCeveryvb@x\PDFSYNC@unblockedtrue\fi}
\def\PDFSYNCeveryvb@xoff{\the\PDFSYNCeveryvb@x}
\let\everyvbox\PDFSYNCeveryvb@x
\def\PDFSYNC@endvbox{\ifnum\lastnodetype>\m@ne
\egroup
\edef\next{\egroup\hrule\@height\the\ht\z@\@depth-\the\ht\z@\relax}%
\unvbox\z@ \next \unvbox\z@
\else \egroup \egroup \fi \endgroup \egroup}%
}%
%
\def\c@nfigPDFSYNC@cr{\wlog{**** pdfsync.sty: Synchronizing at \string\everycr}%
\newtoks\PDFSYNCevery@cr
\PDFSYNCevery@cr\everycr
\everycr{\the\PDFSYNCevery@cr\@PDFSYNC}%
\let\everycr\PDFSYNCevery@cr
}%
% Configure pdsync
\def\c@nfigPDFSYNC{\wlog{Configuring pdfsync}%
\newwrite\PDFSYNC@ut%
\immediate\openout\PDFSYNC@ut\jobname.pdfsync%
\immediate\write\PDFSYNC@ut{\jobname}% control info
\immediate\write\PDFSYNC@ut{version 1}% control info
% patching \shipout
\let\PDFSYNCship@ut@ld\shipout%
\gdef\PDFSYNCship@utn@w{%
\afterassignment\PDFSYNC@utput%
\setbox\@cclv= %
}%
\def\PDFSYNC@utput{%
\relax%
\ifvoid\@cclv\relax%
\aftergroup\PDFSYNC@@utput%
\else%
\PDFSYNC@@utput%
\fi%
}%
\gdef\PDFSYNC@@utput{%
\global\advance\PDFSYNCf@li@ by 1%
\immediate\write\PDFSYNC@ut{s\space\the\PDFSYNCf@li@}%
\PDFSYNCship@ut@ld\box\@cclv%
}%
%
% patching LaTeX \InputIfFileExists for \include and \input
\let\PDFSYNCInputIfFileExists@ff\InputIfFileExists%
\long\def\PDFSYNCInputIfFileExists@n##1##2##3{%
\immediate\write\PDFSYNC@ut{(##1}%
\PDFSYNCInputIfFileExists@ff{##1}{##2}{##3}%
\immediate\write\PDFSYNC@ut{)}}%
%
\def\PDFSYNCP@siti@n{\the\pdflastxpos\space\the\pdflastypos}%
%
\newif\ifPDFSYNCst@r%
\newif\ifPDFSYNCvb@x%
\newcount\PDFSYNCf@li@\PDFSYNCf@li@=0%
\newcount\PDFSYNC@rder\PDFSYNC@rder=0%
\newif\ifPDFSYNC@unblocked
\PDFSYNC@unblockedtrue
% defining \@@PDFSYNC: the macro that writes to the .pdfsync file
\def\@@PDFSYNC{%
\relax%
\immediate\write\PDFSYNC@ut{l\space\the\PDFSYNC@rder\space\the\inputlineno}%
\pdfsavepos%
\edef\next{\write\PDFSYNC@ut{p\ifPDFSYNCst@r*\else\ifPDFSYNCvb@x+\fi\fi\space\the\PDFSYNC@rder\space\noexpand\PDFSYNCP@siti@n}}%
\next%
\global\advance\PDFSYNC@rder by 1%
\relax%
}%
%
\def\@pdfsync{\bgroup\PDFSYNCst@rtrue\@PDFSYNC\egroup}%
%
\def\pdfsyncstart{%
\let\shipout\PDFSYNCship@utn@w%
\let\pdfsync\@pdfsync%
\let\@PDFSYNC\@@PDFSYNC%
\let\InputIfFileExists\PDFSYNCInputIfFileExists@n%
\let\PDFSYNCeveryhb@xcontent\PDFSYNCeveryhb@xon
\let\PDFSYNCeveryvb@xcontent\PDFSYNCeveryvb@xon
}%
\def\pdfsyncstop{%
%\let\shipout\PDFSYNCship@ut@ld%
\let\pdfsync\relax%
\let\@PDFSYNC\relax%
\let\InputIfFileExists\PDFSYNCInputIfFileExists@ff%
\let\PDFSYNCeveryhb@xcontent\PDFSYNCeveryhb@xoff
\let\PDFSYNCeveryvb@xcontent\PDFSYNCeveryvb@xoff
}%
%
\c@nfigPDFSYNCp@r%
\let\c@nfigPDFSYNCp@r\undefined%
\c@nfigPDFSYNCm@th%
\let\c@nfigPDFSYNCm@th\undefined%
%\c@nfigPDFSYNCdispl@y% This does not work with amsmath
\let\c@nfigPDFSYNCdispl@y\undefined%
\c@nfigPDFSYNChb@x%
\let\c@nfigPDFSYNChb@x\undefined%
\c@nfigPDFSYNCvb@x%
\let\c@nfigPDFSYNCvb@x\undefined%
%\c@nfigPDFSYNC@cr% This does not work "Missing \cr inserted" in maketitle
\let\c@nfigPDFSYNC@cr\undefined%
% the problem of the soul package
\ifx\SOUL@\undefined\relax\else%
\message{! pdfsync is patching the soul package}
\let\PDFSYNC@SOUL@\SOUL@
\def\SOUL@##1{%
\bgroup\pdfsyncstop\PDFSYNC@SOUL@{##1}\egroup
}%
\fi%
\pdfsyncstart%
\wlog{**** pdfsync.sty: started}%
}%
%
\AtBeginDocument{%
\c@nfigPDFSYNC%
\let\c@nfigPDFSYNC\undefined%
}%
% end of the core code
% Declaring the option 'nopar' to disable this feature
\DeclareOption{nopar}{\let\c@nfigPDFSYNCp@r\relax}%
% Declaring the option 'nomath' to disable this feature
\DeclareOption{nomath}{\let\c@nfigPDFSYNCm@th\relax}%
% Declaring the option 'nodisplay' to disable this feature
\DeclareOption{nodisplay}{\let\c@nfigPDFSYNCdispl@y\relax}%
% Declaring the option 'nohbox' to disable this feature
\DeclareOption{nohbox}{\let\c@nfigPDFSYNChb@x\relax}%
% Declaring the option 'novbox' to disable this feature
\DeclareOption{novbox}{\let\c@nfigPDFSYNCvb@x\relax}%
% Declaring the option 'nocr' to disable this feature
\DeclareOption{nocr}{\let\c@nfigPDFSYNC@cr\relax}%
% Declaring the option 'off', all the macros are set to \relax
\DeclareOption{off}{\let\c@nfigPDFSYNC\c@nfigPDFSYNC@ff}%
% Beamer problem
\ifx\beamer@version\undefined\relax\else\let\c@nfigPDFSYNCvb@x\relax\fi
\ProcessOptions%
\endinput%
|