[OS X TeX] pdfsync.sty (the file)

Jérôme Laurens jerome.laurens at u-bourgogne.fr
Mon Sep 11 10:21:51 EDT 2006


Please copy this file to your working directory, or  
~/Library/texmf/tex/latex
%%----- cut here
%%
%% pdfsync.sty Copyright (C) 2006 J\'er\^ome Laurens
%%
% This program is free software; you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation; either version 2 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program; if not, write to the Free Software
% Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  
  USA
%%%
%%%
%%%
\ifx\pdfsync\undefined\else\message{****  pdfsync.sty: WARNING, the  
package is already loaded.}\expandafter\endinput\fi%
\def\c at nfigPDFSYNC@ff{%
   \let\pdfsync\relax%
   \let\pdfsyncstart\relax%
   \let\pdfsyncstop\relax%
}%
\ifx\pdfsavepos\undefined%
\message{****  pdfsync.sty: WARNING, synchronization is only available  
with pdftex.}%
\c at nfigPDFSYNC@ff%
\let\c at nfigPDFSYNC@ff=\relax%
\expandafter\endinput%
\fi%
% Defining the preamble of the style file:
\NeedsTeXFormat{LaTeX2e}%
\ProvidesPackage{pdfsync}[2006/09/07 v1.0]%
% start of the code
\let\c at nfigPDFSYNCp@r\relax%
\let\c at nfigPDFSYNCm@th\relax%
\let\c at nfigPDFSYNChb@x\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 at nfigPDFSYNCp@r{\wlog{****  pdfsync.sty: Synchronizing at  
\string\everypar}%
\let\PDFSYNCeveryp at r\everypar%
\newtoks\everypar%
\everypar\expandafter{\the\PDFSYNCeveryp at r}%
\PDFSYNCeveryp at r{\@PDFSYNC\the\everypar}%
}%
%
\ifx\check at mathfonts\undefined
\def\c at nfigPDFSYNCm@th{\wlog{****  pdfsync.sty: Could not synchronize  
at math, upgrade pdfsync}%
}%
\let\PDFSYNC at CMF@ld\relax%
\let\PDFSYNC at CMFn@w\ relax%
\else
\def\c at nfigPDFSYNCm@th{\wlog{****  pdfsync.sty: Synchronizing at math  
(including display)}%
\let\PDFSYNC at CMF@ld\check at mathfonts%
\def\PDFSYNC at CMFn@w{\PDFSYNC at CMF@ld\@PDFSYNC}%
}%
\fi
%
\def\c at nfigPDFSYNChb@x{\wlog{****  pdfsync.sty: Synchronizing at  
\string\everyhbox}%
\let\PDFSYNCeveryhb at x\everyhbox%
\newtoks\everyhbox%
\everyhbox\expandafter{\the\PDFSYNCeveryhb at x}%
\PDFSYNCeveryhb at x{\@PDFSYNC\the\everyhbox}%
}%
%
\def\c at nfigPDFSYNCvb@x{\wlog{****  pdfsync.sty: Synchronizing at  
\string\everyvbox}%
\let\PDFSYNCeveryvb at x\everyvbox%
\newtoks\everyvbox%
\everyvbox\expandafter{\the\PDFSYNCeveryvb at x}%
\PDFSYNCeveryvb at x{\bgroup\PDFSYNCvb at xtrue\@PDFSYNC\egroup\the\everyvbox} 
%
}%
%
\def\c at nfigPDFSYNC@cr{\wlog{****  pdfsync.sty: Synchronizing at  
\string\everycr}%
\let\PDFSYNCevery at cr\everycr%
\newtoks\everycr%
\everycr\expandafter{\the\PDFSYNCevery at cr}%
\PDFSYNCevery at cr{\@PDFSYNC\the\everycr}%
}%
% Configure pdsync
\def\c at nfigPDFSYNC{\wlog{Configuration de pdfsync}%
\newwrite\PDFSYNC at ut%
\immediate\openout\PDFSYNC at ut\jobname.pdfsync%
\immediate\write\PDFSYNC at ut{\jobname}% control info
\immediate\write\PDFSYNC at ut{version 1}% control info
%   patching \shipout
\let\PDFSYNCship at ut@ld\shipout%
\gdef\PDFSYNCship at utn@w{%
\afterassignment\PDFSYNC at utput%
\setbox\@cclv= %
}%
\def\PDFSYNC at utput{%
\relax%
\ifvoid\@cclv\relax%
\aftergroup\PDFSYNC@@utput%
\else%
\PDFSYNC@@utput%
\fi%
}%
\gdef\PDFSYNC@@utput{%
\global\advance\PDFSYNCf at li@ by 1%
\immediate\write\PDFSYNC at ut{s\space\the\PDFSYNCf at li@}%
\PDFSYNCship at ut@ld\box\@cclv%
}%
%
% patching LaTeX \InputIfFileExists for \include and \input
\let\PDFSYNCInputIfFileExists at ff\InputIfFileExists%
\long\def\PDFSYNCInputIfFileExists at n##1##2##3{%
\immediate\write\PDFSYNC at ut{(##1}%
\PDFSYNCInputIfFileExists at ff{##1}{##2}{##3}%
\immediate\write\PDFSYNC at ut{)}}%
%
\def\PDFSYNCP at siti@n{\the\pdflastxpos\space\the\pdflastypos}%
%
\newif\ifPDFSYNCst at r%
\newif\ifPDFSYNCvb at x%
\newcount\PDFSYNCf at li@\PDFSYNCf at li@=0%
\newcount\PDFSYNC at rder\PDFSYNC at rder=0%
% defining \@@PDFSYNC: the macro that writes to the .pdfsync file
\def\@@PDFSYNC{%
\relax%
\pdfsavepos%
\immediate\write\PDFSYNC at ut{l\space\the\PDFSYNC at rder\space\the\inputline 
no}%
\edef\next{\write\PDFSYNC at ut{p\ifPDFSYNCst at r*\else\ifPDFSYNCvb at x+\fi\fi\ 
space\the\PDFSYNC at rder\space\noexpand\PDFSYNCP at siti@n}}%
\next%
\global\advance\PDFSYNC at rder by 1%
\relax%
}%
%
\def\@pdfsync{\bgroup\PDFSYNCst at rtrue\@PDFSYNC\egroup}%
%
\def\pdfsyncstart{%
\let\shipout\PDFSYNCship at utn@w%
\let\pdfsync\@pdfsync%
\let\@PDFSYNC\@@PDFSYNC%
\let\InputIfFileExists\PDFSYNCInputIfFileExists at n%
\let\check at mathfonts\PDFSYNC at CMFn@w%
}%
\def\pdfsyncstop{%
\let\shipout\PDFSYNCship at ut@ld%
\let\pdfsync\relax%
\let\@PDFSYNC\relax%
\let\InputIfFileExists\PDFSYNCInputIfFileExists at ff%
\let\check at mathfonts\PDFSYNC at CMF@ld%
}%
%
\c at nfigPDFSYNCp@r%
\let\c at nfigPDFSYNCp@r\undefined%
\c at nfigPDFSYNCm@th%
\let\c at nfigPDFSYNCm@th\undefined%
\c at nfigPDFSYNChb@x%
\let\c at nfigPDFSYNChb@x\undefined%
\c at nfigPDFSYNCvb@x%
\let\c at nfigPDFSYNCvb@x\undefined%
% the problem of the soul package
     \ifx\undefined\SOUL@\relax\else%
	\message{! pdfsync is patching the soul package}
         \let\PDFSYNC at SOUL@\SOUL@
         \def\SOUL@##1{%
             \bgroup\pdfsyncstop\PDFSYNC at SOUL@{##1}\egroup
         }%
     \fi%
\pdfsyncstart%
}%
%
\AtBeginDocument{%
\c at nfigPDFSYNC%
\let\c at nfigPDFSYNC\undefined%
}%
% end of the core code
% Declaring the option 'nopar' to disable this feature
\DeclareOption{nopar}{\let\c at nfigPDFSYNCp@r\relax}%
% Declaring the option 'nomath' to disable this feature
\DeclareOption{nomath}{\let\c at nfigPDFSYNCm@th\relax}%
% Declaring the option 'nohbox' to disable this feature
\DeclareOption{nohbox}{\let\c at nfigPDFSYNChb@x\relax}%
% Declaring the option 'novbox' to disable this feature
\DeclareOption{novbox}{\let\c at nfigPDFSYNCvb@x\relax}%
% Declaring the option 'nocr' to disable this feature
\DeclareOption{nocr}{\let\c at nfigPDFSYNC@cr\relax}%
% Declaring the option 'off', all the macros are set to \relax
\DeclareOption{off}{\let\c at nfigPDFSYNC\c at nfigPDFSYNC@ff}%
\ProcessOptions%
\endinput%



























\def\c at nfigPDFSYNCp@r{\wlog{****  pdfsync.sty: Synchronizing par}%
        \global\let\PDFSYNC at everypar\everypar%
         \global\newtoks\everypar%
         \global\everypar\expandafter{\the\PDFSYNC at everypar}%
         \global\PDFSYNC at everypar{\the\everypar\@PDFSYNC}%
%
}%
%
\def\PDFSYNC at mathC@nfig{\wlog{****  pdfsync.sty: Synchronizing math}%
         \global\let\PDFSYNC at everymath\everymath%
         \newtoks\everymath%
         \everymath\expandafter{\the\PDFSYNC at everymath}%
         \PDFSYNC at everymath{\the\everymath\@PDFSYNC}%
  % this change was suggested by Curtis Clifton with everypar on  
12/17/2004
}%
\DeclareOption{nomath}{\let\PDFSYNC at mathC@nfig\relax}
%
\def\PDFSYNC at hboxC@nfig{\wlog{****  pdfsync.sty: Synchronizing hbox}%
         \global\let\PDFSYNC at everyhbox\everyhbox%
         \newtoks\everyhbox%
         \everyhbox\expandafter{\the\PDFSYNC at everyhbox}%
         \PDFSYNC at everyhbox{\the\everyhbox\@PDFSYNC}%
  % this change was suggested by Curtis Clifton with everypar on  
12/17/2004
}%
\DeclareOption{nohbox}{\let\PDFSYNC at hboxC@nfig\relax}
%

\def\PDFSYNC at extraC@nfig{%
}%
\DeclareOption{noextra}{\let\PDFSYNC at extraC@nfig\relax}%
%

  \def\configure at PDFSYNC@off{%

\DeclareOption{off}{\let\pdfsyncstart\relax%
   \let\pdfsyncstop\relax%
   \let\pdfsync\relax%
   \let\@PDFSYNC\relax%
   \let\PDFSYNCC at nfig\relax%
}%
%

\def\configure@@PDFSYNC{%
     \wlog{****  pdfsync.sty: Synchronization is enabled.}%
     \let\PDFSYNC at oldshipout\shipout%
     \let\shipout\PDFSYNC at shipout%
     \immediate\openout\PDFSYNCP at S\jobname.pdfsync%
     \immediate\write\PDFSYNCP at S{\jobname}%            control info
     \immediate\write\PDFSYNCP at S{version 0}%            control info
	%
     % patching LaTeX \InputIfFileExists for \include and \input
     \let\PDFSYNCInputIfFileExists at ff\InputIfFileExists%
     \long\def\PDFSYNCInputIfFileExists at n##1##2##3{%
	  \immediate\write\PDFSYNCP at S{(##1}%
       \PDFSYNCInputIfFileExists at ff{##1}{##2}{##3}%
       \immediate\write\PDFSYNCP at S{)}}%
	\let\InputIfFileExists\PDFSYNCInputIfFileExists at n
	%
	\def\PDFSYNCP at siti@n{\the\pdflastxpos\space\the\pdflastypos}%
	%
     \def\@@PDFSYNC{%
		\relax%
		\pdfsavepos%
		 
\immediate\write\PDFSYNCP at S{l\space\the\PDFSYNC at rder\space\the\inputline 
no}%
		 
\edef\next{\write\PDFSYNCP at S{p\ifPDFSYNCSt at r*\fi\space\the\PDFSYNC at rder\ 
space\noexpand\PDFSYNCP at siti@n}}%
		\next%
		\global\advance\PDFSYNC at rder by 1%
		\relax%
	}%
	\let\@PDFSYNC at ff\relax%
	\def\pdfsyncstart{%
		\let\pdfsync\@pdfsync%
		\let\@PDFSYNC\@@PDFSYNC%
	}%
	\def\pdfsyncstop{}%
	\def\@pdfsync{\def\PDFSYNCst at r{*}\@PDFSYNC\let\PDFSYNCst at r\relax}%
	\let\pdfsync at ff\relax%
}%
\def\PDFSYNCC at nfig@n{%
	\newwrite\PDFSYNCP at S%
	\newcount\PDFSYNCf at lio\PDFSYNCf at lio=0%
	\newcount\PDFSYNC at rder\PDFSYNC at rder=0%
	%
	\def\PDFSYNC at shipout{%
	   \afterassignment\PDFSYNC at utput%
	   \global\setbox\@cclv= %
	   }%
	\def\PDFSYNC at utput{%
	   \ifvoid\@cclv\relax%
		  \aftergroup\PDFSYNC@@utput%
	   \else%
		  \PDFSYNC@@utput%
	   \fi%
	   }%
	\def\PDFSYNC@@utput{%
		\global\advance\PDFSYNCf at lio by 1%
		\immediate\write\PDFSYNCP at S{s\space\the\PDFSYNCf at lio}%
		\PDFSYNC at oldshipout\box\@cclv%
	   }%
	\AtBeginDocument{\pdfsyncstart}%
}%

%%%%  2004-05-24:
%%%%  Improvements suggested by Hans Hagen.
%%%%  2004-01-31:
%%%%  \@p at r is patched instead of \par
%%%%  The pdfsync anchor is now after the \@p at r
%%%%  2004-01-20:
%%%%  \input{foo} is now supported, \input foo not
%%%%  no more underfull hbox
%%%%  cr and vbox are no longer supported, except in latex extras
%%%%  2004-01-13:
%%%%  A layout bug is fixed thanks to J.L. Varona:
%%%%  extra space was added in math mode $\sin$, $\notin$
%%%%  Patched LaTeX commands:
%%%%  \verse, \put, \emph, \comment, \href
%%%%  2003-12-18:
%%%%  The nothing option has been replaced by off
%%%%  Patched LaTeX commands:
%%%%  2003-12-08:
%%%%  There is a bug in using everyvbox... novbox is now the default
%%%%  bug fixed: $0$ was not visible
%%%%  2003-11-28:
%%%%  comment characters added to fix an error. Don't know exactly the  
cause...
%%%%  Default option is all...
%%%%  Could not use \everydisplay... (bug in eqnarray)
%%%%  2003-11-19
%%%%  first version
%%%%
%%%%  Version 0.7 usage: \usepackage[options]{pdfsync}
%%%%  ==================
%%%%  appends reference points before each \par and at each \hbox,  
inline math;
%%%%  Known commands:
%%%%  \pdfsync: add this command everywhere you want to reference a  
point
%%%%  \pdfsyncstop, \pdfsyncstart: if pdfsync beaks your code, enclose  
the dangerous part in stop start group
%%%%  option: nopar
%%%%  don't insert reference point at par's
%%%%  option: nomath
%%%%  don't insert reference point at math's
%%%%  option: nohbox
%%%%  don't insert reference point at hboxes
%%%%  option: noextra
%%%%  don't insert reference point at LaTeX extra commands
%%%%  option: off
%%%%  All the pdfsync related commands are \relax'ed
%%%%
%%%%  If you want additional files to be parsed, please use the command
%%%%  \include{foo} or \input{foo},
%%%%  the \input foo will break up the synchronization
%%%%
%%%%  Credits:
%%%%  ========
%%%%  This file is due to Piero D'Ancona and  
jlaurens at users.sourceforge.net
%%%%  iTeXMac, TeXShop, AucTeX, TeXNiscope are supporting pdfsync
%%%%  Copy this file to ~/Library/texmf/tex/latex or  
~/Library/TeX/texmf/tex/latex if available
%%%%  This file is distributed under the GPL and the "smart licence":  
please make things better if you can
%%%%  copyright 2004, jlaurens at users.sourceforge.net
%

------------------------- Info --------------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
          & FAQ: http://latex.yauh.de/faq/
TeX FAQ: http://www.tex.ac.uk/faq
List Archive: http://tug.org/pipermail/macostex-archives/




More information about the MacOSX-TeX mailing list