PageRenderTime 100ms CodeModel.GetById 12ms RepoModel.GetById 1ms app.codeStats 0ms

/examples/slide/advi.sty

#
TeX | 416 lines | 290 code | 78 blank | 48 comment | 1 complexity | 6f60cd05f7a89cdc6177d6d6b924c839 MD5 | raw file
Possible License(s): GPL-3.0, GPL-2.0
  1. %%
  2. %% This is the original source file advi.sty
  3. %%
  4. %% Package `advi' to use with LaTeX 2e
  5. %% Copyright Roberto Di Cosmo, Jun Furuse, Didier Remy, and Pierre Weis
  6. %% All rights reserved.
  7. % Which name is ours
  8. \def \ActiveDVI {Active-DVI}
  9. \NeedsTeXFormat{LaTeX2e}
  10. \ProvidesPackage{advi}
  11. [2001/29/08 v0.40 Advi Package for advi Previewer]
  12. %%
  13. %% Identification
  14. %% Preliminary declarations
  15. \RequirePackage {keyval}
  16. %% Options
  17. \newif \ifadvi@ignore \advi@ignorefalse
  18. \DeclareOption {ignore}{\advi@ignoretrue}
  19. \ProcessOptions
  20. % \@ifundefined {AdviOptions}{}{\ExecuteOptions {\AdviOptions}}
  21. %% More declarations
  22. % Auxilliary macros
  23. \def \advi@empty{}
  24. \def \advi@ifempty #1{\def \@test {#1}\ifx \@test \advi@empty
  25. \expandafter \@firstoftwo \else \expandafter \@secondoftwo \fi}
  26. \def \advi@error #1{\PackageError {Advi}{#1}{Type <RETURN> to proceed.}}
  27. \def \advi@warning #1{\PackageWarning {Advi}{#1}}
  28. \def \advi@undefinedenv {\advi@error {Environment \@currenvir\space undefined.
  29. Maybe you mean \@currenvir ing}}
  30. \def \advi@special@ {\advi@ifadvi{\special}{\advi@ignore}}
  31. \def \advi@special #1{\advi@special@ {advi: #1}}
  32. \def \advi@export #1#2{\@ifdefinable #1{\let #1#2}}
  33. \def \advi@exportenv #1#2{%
  34. \@ifundefined {#1}{\expandafter \let \csname #1\expandafter \endcsname
  35. \csname end#1\endcsname }\relax
  36. \expandafter \@ifdefinable \csname #1\endcsname
  37. {\expandafter \let \csname #1\expandafter \endcsname \csname #2\endcsname
  38. \expandafter \let \csname end#1\expandafter \endcsname
  39. \csname end#2\endcsname}}
  40. \def \advi@ignore #1{}
  41. \def \advi@id #1{#1}
  42. \def \advi@ifadvi {\ifadvi@ignore
  43. \expandafter \@secondoftwo \else \expandafter \@firstoftwo \fi}
  44. \advi@export \adviignore \advi@ignoretrue
  45. \advi@export \ifadvi \advi@ifadvi
  46. %%% Record and play
  47. \newif \ifadvi@recording
  48. \def \advi@ifrecording {\ifadvi@recording
  49. \expandafter \@firstoftwo \else \expandafter \@secondoftwo \fi}
  50. \def \advi@ifrecordenv {\ifx \@currenvir \advi@recordenv
  51. \expandafter \@firstoftwo \else \expandafter \@secondoftwo \fi}
  52. \def \advi@start {start}
  53. \def \advi@startplay {start play}
  54. \define@key{advi@record}{play}[]{\let \advi@do \advi@startplay}
  55. \def \advi@recordenv {advirecord}
  56. \newenvironment{advi@recording}[2][]%
  57. {\begingroup
  58. \let \advi@do \advi@start \setkeys{advi@record}{#1}%
  59. \advi@special {proc=#2 record=\advi@do}%
  60. \endgroup}
  61. {\advi@special {proc record=end}}
  62. \newcommand {\advi@record}[3][]{\advi@recording[#1]{#2}#3\endadvi@recording}
  63. \newcommand {\advi@play}[2][]%
  64. {\begingroup
  65. \advi@ifempty{#1}{}{\color {#1}}{\advi@special {proc=#2 play}}%
  66. \endgroup}
  67. \advi@exportenv {advirecording}{advi@recording}
  68. \advi@export \advirecord \advi@record
  69. \let \endadvirecord \advi@undefinedenv
  70. \advi@export \adviplay \advi@play
  71. %%% Embedded applications
  72. \def \advi@embed@name{anonymous}
  73. \def \advi@embed@mode{ephemeral}
  74. \def \advi@embed@width{0pt}
  75. \def \advi@embed@height{0pt}
  76. \define@key {advi@embed}{name}{\def \advi@embed@name {#1}}
  77. \define@key {advi@embed}{width}%
  78. {\@tempdima#1\relax \edef \advi@embed@width {\the\@tempdima}}
  79. \define@key {advi@embed}{height}%
  80. {\@tempdima#1\relax \edef \advi@embed@height {\the\@tempdima}}
  81. \def \advi@definemode #1{%
  82. \define@key {advi@embed}{#1}[anonymous]{%
  83. \def \advi@embed@mode {#1}\def\advi@embed@name {##1}%
  84. }}
  85. \advi@definemode{ephemeral}
  86. \advi@definemode{persistent}
  87. \advi@definemode{sticky}
  88. \def \advi@embed@ #1#2#3#4#5{%
  89. \mbox{\advi@special
  90. {embed name="#1" mode=#2 width=#3 height=#4 command="#5"}%
  91. {\vbox to #4{\hbox to #3{}}}}}
  92. \def \advi@length #1{\@tempdima #1\relax \the\@tempdima}
  93. \newcommand{\advi@embed}[2][]{%
  94. \mbox {\setkeys {advi@embed}{#1}%
  95. \advi@embed@ {\advi@embed@name}{\advi@embed@mode}
  96. {\advi@embed@width}{\advi@embed@height}{#2}}}
  97. \newcommand{\advi@killembed}[2][]{\advi@special {kill name="#2" signal="#1"}}
  98. \advi@export \adviembed \advi@embed
  99. \advi@export \advikillembed \advi@killembed
  100. %%% Background colors and images
  101. \def \do #1{\expandafter \def \csname advi@geom@#1@\endcsname {#1}}
  102. \do {center}
  103. \do {left}
  104. \do {right}
  105. \do {bottom}
  106. \do {top}
  107. \do {topleft}
  108. \do {topright}
  109. \do {bottomleft}
  110. \do {bottomright}
  111. \let \do \relax
  112. \def \advi@ifnine #1#2#3{\@ifundefined {advi@geom@#1@}{#3}{#2}}
  113. \let \advi@global \relax
  114. \def \advi@global@ {global}
  115. \newif \ifadvi@bgactive
  116. \def \advi@bg@do
  117. {\do\advi@bgcolor \do\advi@bgimage \do \advi@bgalpha \do\advi@bgblend}
  118. \def \advi@auto@ { fit=auto}
  119. \def \advi@bgreset
  120. {\def \do ##1{\expandafter \advi@global
  121. \expandafter \let \noexpand ##1\advi@empty}\advi@bg@do
  122. \advi@global \let \advi@bgfit \advi@auto@
  123. \advi@global \advi@bgactivefalse}
  124. \advi@bgreset
  125. \def \advi@none@ {none}
  126. \def \advi@ifnone #1{\def \@test{#1}\ifx \@test \advi@none@
  127. \let \@test \advi@empty \fi \ifx \@test \advi@empty
  128. \expandafter \@firstoftwo \else \expandafter \@secondoftwo \fi}
  129. \def \advi@setbg #1#2#3{\advi@ifnone {#1}
  130. {\advi@global \expandafter \let \noexpand #1\advi@empty}
  131. {\advi@global \expandafter \def \noexpand #1{ #2=#3}%
  132. \advi@global \advi@bgactivetrue}}
  133. \define@key {advi@bg}{color}[]{\advi@setbg{\advi@bgcolor}{color}{#1}}
  134. \define@key {advi@bg}{image}[]{\advi@setbg{\advi@bgimage}{image}{#1}}
  135. \define@key {advi@bg}{alpha}[]{\advi@setbg{\advi@bgalpha}{alpha}{#1}}
  136. \define@key {advi@bg}{blend}[]{\advi@setbg{\advi@bgblend}{blend}{#1}}
  137. \define@key {advi@bg}{fit}[auto]{\def \advi@bgfit {#1}%
  138. \ifx \advi@bgfit \advi@auto@ \else
  139. \advi@ifnine {\advi@bgfit}
  140. {\advi@global \def \advi@bgfit{ fit=#1}}
  141. {\advi@error {Ill formed background fit=#1}}%
  142. \fi}
  143. \def \advi@bgset #1{\advi@ifnone {#1}{\advi@bgreset}{\setkeys {advi@bg}{#1}}}
  144. %\define@key {advi@bg}{inherit}[]{\advi@special{setbg inherit}}
  145. \def \advi@bgemit
  146. {\advi@special
  147. {setbg \advi@bgcolor \advi@bgimage \advi@bgalpha \advi@bgblend
  148. \advi@bgfit
  149. }}
  150. \newif \ifadvi@bglocal
  151. \newcommand{\advi@bg}[2][]{%
  152. \begingroup
  153. \def \@test {#1}\ifx \@test \advi@global@ \let \advi@global \global
  154. \advi@bgset {#2}\else
  155. \ifx \@test \advi@empty \else \advi@warning
  156. {Optional argument [#1] to \string \advibg ignored}\fi
  157. \global \advi@bglocaltrue
  158. \advi@bgset{#2}\advi@bgemit \fi
  159. \endgroup}
  160. \def \advi@bgpage
  161. {\ifadvi@bgactive \ifadvi@bglocal\else \advi@bgemit \fi\fi
  162. \global \advi@bglocalfalse}
  163. \advi@export \advibg \advi@bg
  164. %%% Pausing and waiting
  165. \def\advi@pause {\advi@special{pause}}
  166. \def\advi@wait#1{\advi@special{wait sec=#1}}
  167. %% export
  168. \newcommand {\adviwait}[1][]%
  169. {\advi@ifempty {#1}{\advi@pause}{\advi@wait {#1}}}
  170. %%% Transparency and alpha blending
  171. %%% To be revisited.
  172. \def\advi@epstransparent
  173. {\advi@special{epstransparent push true}%
  174. \aftergroup \advi@resetepstransparent}
  175. \def\advi@epswhite
  176. {\advi@special{epstransparent push false}%
  177. \aftergroup \advi@resetepstransparent}
  178. \def\advi@setalpha#1%
  179. {\advi@special{alpha push #1}%
  180. \aftergroup \advi@resetalpha}
  181. \def\advi@setblend#1%
  182. {\advi@special{blend push #1}%
  183. \aftergroup\advi@resetblend}
  184. \def\advi@resetepstransparent {\advi@special{epstransparent pop}}
  185. \def\advi@resetalpha {\advi@special{alpha pop}}
  186. \def\advi@resetblend {\advi@special{blend pop}}
  187. \advi@export \epstransparent \advi@epstransparent
  188. \advi@export \epswhite \advi@epswhite
  189. \advi@export \setalpha \advi@setalpha
  190. \advi@export \setblend \advi@setblend
  191. %%% Animated transitions
  192. \def \advi@transfrom{}
  193. \def \advi@transsteps{}
  194. \def \advi@settrans {\advi@global \def}
  195. \define@key {advi@trans}{none} []{\advi@settrans \advi@transmode {none}}
  196. \define@key {advi@trans}{slide}[]{\advi@settrans \advi@transmode {slide}}
  197. \define@key {advi@trans}{block}[]{\advi@settrans \advi@transmode {block}}
  198. \define@key {advi@trans}{wipe} []{\advi@settrans \advi@transmode {wipe}}
  199. \define@key {advi@trans}{from} {\advi@settrans \advi@transfrom { from=#1}}
  200. \define@key {advi@trans}{steps}{\advi@settrans \advi@transsteps { steps=#1}}
  201. \def \advi@transemit
  202. {\advi@special{trans \advi@transmode \advi@transfrom \advi@transsteps}}
  203. \newif \ifadvi@translocal
  204. \newcommand {\advi@transition}[2][]{%
  205. \begingroup
  206. \def \@test {#1}\ifx \@test \advi@global@ \let \advi@global \global
  207. \setkeys {advi@trans}{#2}\else
  208. \ifx \@test \advi@empty \else \advi@warning
  209. {Optional argument [#1] to \string \advitransition ignored}\fi
  210. \global \advi@translocaltrue
  211. \setkeys {advi@trans}{#2}\advi@transemit \fi
  212. \endgroup}
  213. \def \advi@transpage
  214. {\@ifundefined {advi@transmode}{}
  215. {\ifadvi@translocal\else \advi@transemit \fi}%
  216. \global \advi@translocalfalse}
  217. %% Hook \advi@setpagesetyle at \@begindvi that run at every page
  218. \def \advi@setpagestyle {\advi@bgpage \advi@transpage}
  219. \def \endpage@hook {}
  220. \def \AtEndPage {\g@addto@macro \endpage@hook}
  221. \AtEndPage {\advi@setpagestyle}
  222. % We must patch \@begindvi to put out hook.
  223. % However, hyperref may patch it as well. So we should do it at begin
  224. % document to have the control (no one after us).
  225. % Howver, one must be careful, because \@begindvi redefines itself at the
  226. % first call to its prerecorded final value.
  227. % So our first patch will be overridden with the value that it was
  228. % meant to have after the first page.
  229. % Hence, we patch it a second time to put our hook to this final value.
  230. % we can use \g@addto@macro which redefines #1 to so that it procedes as
  231. % before and then execute #2 at the end.
  232. \def \advi@begindvi@patch
  233. {\g@addto@macro \@begindvi
  234. {\endpage@hook \g@addto@macro \@begindvi {\endpage@hook}}}
  235. \AtBeginDocument {\advi@begindvi@patch}
  236. % {\let \advi@begindvi@save \@begindvi %% value at begindocument
  237. % \def \@begindvi %% our new value
  238. % {\advi@begindvi@save %% may redefine \@begindvi
  239. % \global\let \advi@begindvi@save %% so we this new value
  240. % \@begindvi
  241. % \gdef \@begindvi %% now and forever
  242. % {\advi@begindvi@save \endpage@hook}%
  243. % \endpage@hook %% our hook for the
  244. % }}
  245. %% Transitions
  246. \def\advi@transbox@save#1#2#3{\advi@special
  247. {transbox save width=#1 height=#2 depth=#3}}
  248. \def\advi@transbox@go#1{\advi@special{transbox go #1}}
  249. \def \advi@transslide {slide}
  250. \def \advi@transbox #1{%
  251. \def \advi@afterbox
  252. {\hbox {\advi@transbox@save{\the\wd0 }{\the\ht0 }{\the\dp0}%
  253. \unhbox0\setkeys {advi@trans}{#1}%
  254. \advi@transbox@go
  255. {\advi@transmode \advi@transfrom \advi@transsteps}}}%
  256. \def \advi@@afterbox {\aftergroup \advi@afterbox}
  257. \afterassignment \advi@@afterbox \setbox0 \hbox }
  258. \advi@export \advitransition \advi@transition
  259. \advi@export \advitransbox \advi@transbox
  260. %%% For PS Tricks
  261. \def \advi@moveto {\advi@special {moveto}}
  262. \def\advi@psput@special#1{%
  263. \hbox{%
  264. \pst@Verb{{ \pst@coor }
  265. dup exec 2 copy moveto advi@Dict begin printpos end
  266. \tx@PutCoor
  267. \tx@PutBegin}
  268. \hbox {\advi@moveto \box#1}%
  269. \pst@Verb{\tx@PutEnd}}}
  270. \def\advi@ncput@iii{%
  271. \leavevmode
  272. \hbox{%
  273. \pst@Verb{%
  274. \pst@nodedict
  275. /t \psk@npos def
  276. tx@NodeDict /LPutPos known { LPutPos } { CP /Y ED /X ED /NAngle 0
  277. def } ifelse
  278. LPutCoor
  279. end
  280. \tx@PutBegin
  281. }%
  282. \hbox {\box\pst@hbox}%
  283. \pst@Verb{\tx@PutEnd}}}
  284. \def \advi@pstricks@patch
  285. {\@ifundefined {psput@special}{}
  286. {\let \psput@special \advi@psput@special
  287. %\@ifundefined {ncput@iii}{}{\let \ncput@iii \advi@ncput@iii}%
  288. \pstheader {advi.pro}}}
  289. \AtBeginDocument {\advi@pstricks@patch}
  290. %%% Active DVI
  291. \def \advi@over@ {over}
  292. \def \advi@click@ {click}
  293. \def \advi@null {\hbox {}}
  294. \newenvironment {advi@anchoring}[2][over]{%
  295. \begingroup
  296. \def \@test {#1}\ifx \@test \advi@over@
  297. \advi@special@ {html:<a advi="#2">}\else
  298. \ifx \@test \advi@click@
  299. \advi@special@ {html:<a hdvi="#2">}\else
  300. \advi@error {Incorect anchor mode #1}\fi \fi\endgroup}
  301. {\advi@special@ {html:</a>}}
  302. \newcommand {\advi@anchor}[3][over]%
  303. {\advi@anchoring[#1]{#2}#3\endadvi@anchoring}
  304. \def \advi@endanchor #1{#1\endadvi@anchor \endgroup}
  305. \advi@exportenv {advianchoring}{advi@anchoring}
  306. \advi@export \advianchor \advi@anchor
  307. \let \endadvianchor \advi@undefinedenv
  308. %%% Partial patch for overlays -- 0 will be shown > 0 will not be shown
  309. \def \advi@max {0}
  310. \def \advi@overlay #1{%
  311. \advi@ifadvi
  312. {%\advance \c@overlay by 1
  313. \ifnum \c@overlay>\advi@max \global \xdef \advi@max {\the \c@overlay}\fi
  314. \advi@recording {overlay@#1}\aftergroup \endadvi@recording}
  315. {\latex@overlay {#1}}}
  316. \def \advi@overlay@loop
  317. {\advi@ifadvi
  318. {\begingroup
  319. \c@overlay=0
  320. \@whilenum\c@overlay<\advi@max
  321. \do {\advance \c@overlay by 1%
  322. \adviwait \adviplay{overlay@\the\c@overlay}}%
  323. \endgroup
  324. \gdef \advi@max {0}}
  325. {\latex@overlay@loop}}
  326. \def \advi@end@slide
  327. {\advi@ifadvi {\overlay@loop}{}\latex@end@slide}
  328. \def \advi@overlay@patch {%
  329. \let \latex@overlay \@overlay
  330. \let \latex@end@slide \end@slide
  331. \let \latex@overlay@loop \overlay@loop
  332. \let \@overlay \advi@overlay
  333. \let \overlay@loop \advi@overlay@loop
  334. \let \end@slide \advi@end@slide
  335. }
  336. \@ifundefined {overlay}{}
  337. {\AtBeginDocument {\advi@overlay@patch}}
  338. \endinput