summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/ocgtools/examples/ocgtools-preview.tex
blob: 0cf2411c138641ba56a62b2bda336384e0e9fbd1 (plain)
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
\documentclass{article}
\usepackage[%latextoc,
noxcolor,
usetemplates,pdftex]{web}
%\usepackage{times}
\screensize{4.875in}{6.5in}
\margins{12pt}{24pt}{24pt}{24pt}

\definecolor{pozadi}{rgb}{1,1,0.9}
\pagecolor{pozadi}

%\scrollmode
\def\MyPersonalMacro{Hello world}

\title{OCGtools and preview} 

\optionalPageMatter{
  \begin{center}
    \colorbox{yellow}{\begin{minipage}{0.5\linewidth} This is a demo
        file to test cooperation between ocgtools and preview
        packages. Go to the Section \ref{page} on page \pageref{page}
        and put you mouse to the question marks following referrences
        to figure and equation. The figure and equation should appear
        in minilayer at the same page.

        The concept is DoItYourself, see the source
        \texttt{.tex} file and script \texttt{ocgtools-preview.sh}.
      \end{minipage}}
  \end{center}
}

\def\title#1{}
\usepackage[minimouseover]{ocgtools}


\ifx\ocgpreview\undefined\def\ocgpreview#1#2{#1}\fi

 \ocgpreview{\AtBeginDocument{
 \gdef\maplabeltopage#1#2{\expandafter\xdef\csname ocgtools@page@#1\endcsname{#2}
\message{^^J OCG: page #2}}
 \gdef\savemaplabels#1#2#3#4{\xdef\ocgtoolstemp{#2}}
 \gdef\maplabelstoall#1#2{\savemaplabels#2 \maplabeltopage{#1}{\ocgtoolstemp}}
 \input preview.labels
 \let\orieqref\eqref
 \let\oriref\ref
 \def\eqref#1{(\oriref{#1})%
 \expandafter\ifx\csname  ocgtools@page@#1\endcsname\relax\else
  \,{\ocgminitext{$^{\text{?}}$}%
  {\includegraphics[page=\csname ocgtools@page@#1\endcsname]{preview-temp}}}%
  \fi}%
 \def\ref#1{\oriref{#1}%
 \expandafter\ifx\csname  ocgtools@page@#1\endcsname\relax\else
    \,{\ocgminitext{$^{\text{?}}$}%
   {\includegraphics[page=\csname ocgtools@page@#1\endcsname]{preview-temp}}}%
  \fi}%
 }}{\AtBeginDocument{
 \newwrite\refsfile
 \pagecolor{lightblue}
 \immediate\openout\refsfile=preview.labels
 \let\orilabel\label
 \def\label#1{\orilabel{#1}\write\refsfile{\string\maplabeltopage{#1}{\thepage}}}
 }}

\input ocgtools-test.tex

\end{document}