答案1
基于ocgx2
模拟问题中示例的包的解决方案。它定义了一个命令\itemtoggle
,该命令带有两个参数,并将\item
在逐项列表中的可选参数中使用:
\item[\itemtoggle{<layer name>}{<internal id>}]
它插入一个旋转的、可点击的三角形作为项目符号,并创建一个新的、最初隐藏的 PDF 层 (OCG)。<layer name>
显示在 PDF 查看器的“图层”选项卡中,<internal id>
用于引用文档源中的图层。
然后可以通过<internal id>
和ocmd
环境将项目下方的附加文本变为可选的:
\begin{ocmd}{\AllOn{<internal id>}}
Additional information ...
\end{ocmd}
OCMD 是另一种 PDF 图层,其可见性不由用户直接设置(它没有名称,无法在查看器的“图层”选项卡中访问),而是取决于文档中 OCG 图层的可见性,具体取决于策略或布尔表达式。
完整示例:
\documentclass{article}
\usepackage{xcolor}
\usepackage{mathabx} % \blacktriangleright, \blacktriangledown
\usepackage{ocgx2}
% toggle switch with rotating item symbol; also defines Layer name and id
\NewDocumentCommand{\itemtoggle}{mm}{% #1 OCG name (as shown in Layer tab of the PDF viewer);
% #2 internal identifier
{\hypersetup{pdfborder=0 0 0}% suppresses link border around item if hyperref is loaded
\switchocg{#2}{%
\begin{ocg}{#1}{#2}{off}\rlap{$\blacktriangledown$}\end{ocg}%
\begin{ocmd}{\AllOff{#2}}$\blacktriangleright$\end{ocmd}%
}}%
}
\ProvideDocumentCommand{\hypersetup}{m}{}
\begin{document}
The relativity equation $E=mc^2$
\begin{itemize}
\item[\itemtoggle{Mass-Energy Equivalence}{emc2}]
{\color{cyan}%
In physics, mass-energy equivalence is the relationship between mass and energy in a system's rest frame, where the two values differ only by a constant and the units of measurement. The principle is described by Albert Einstein's famous formula.}
\begin{ocmd}{\AllOn{emc2}}
The formula defines the Energy ($E$) of a particle in its rest frame as the product of mass ($m$) and speed of light squared ($c^2$) \dots
\end{ocmd}
\end{itemize}
\end{document}
答案2
这实际上是有可能的。参见这例子。
需要注意的是,当内容被隐藏时,空白会出现在那里(见第 3 页,橙色的“点击我”文本这个文件)。
此外,并非所有 pdf 查看器都支持此类功能(很多都支持)。
上述链接中的部分代码粘贴如下(以防将来链接失效)
\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{url}
\usepackage{fullpage}
\usepackage{amsmath,stmaryrd}
\usepackage{color}
\usepackage{pf2} % annoying conflict with amsthm on environment proof
% renamed to structproof.
\beforePfSpace{0pt}
\usepackage{amsthm}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{corollary}[theorem]{Corollary}
\theoremstyle{definition} \newtheorem{definition}[theorem]{Definition}
\usepackage[normalem]{ulem}
\usepackage{hyperref} % do NOT set [ocgcolorlinks] here!
\usepackage[tikz,ocgcolorlinks]{ocgx2}
\usetikzlibrary{calc, shapes.callouts, shapes.symbols}
% Colourblind friendly colours
% http://jfly.iam.u-tokyo.ac.jp/color/#pallet
\definecolor{orange}{RGB}{230,159,0}
\definecolor{skyblue}{RGB}{86,180,230} % light blue
\definecolor{green}{RGB}{0,158,115} % blueish green
\definecolor{yellow}{RGB}{240,228,66}
\definecolor{blue}{RGB}{0,114,178}
\definecolor{red}{RGB}{213,94,0} % vermillon
\definecolor{pink}{RGB}{204,121,167} % reddish purple
%%% OCG handling commands
% #1: OCG name, #2: OCG refname, #3: OCG visibility, #4: colour
% \newcommand{\ocguline}[4]{\bgroup\markoverwith
% {\begin{ocg}{#1}{#2}{#3}\textcolor{#4}{\rule[-0.5ex]{2pt}{0.4pt}}\end{ocg}}\ULon}
\newcommand{\ocghline}[4]{\bgroup\markoverwith
{\begin{ocg}{#1}{#2}{#3}\textcolor{#4}{\rule[-0.65ex]{.1pt}{2.5ex}}\end{ocg}}\ULon}
\newcommand{\largeocghline}[4]{\bgroup\markoverwith
{\begin{ocg}{#1}{#2}{#3}\textcolor{#4}{\rule[-0.75ex]{.1pt}{3.2ex}}\end{ocg}}\ULon}
% We cannot put the OCGs in a radio button group because the
% \switchocg acts on each OCG in order of the list. When the off OCG
% is turned on, the radio button group automatically turn off the
% other, but then the \switchocg acts on it… and turn it on again!
% #1: OCG name, #2: OCG refname, #3: colour
\newcommand{\jymulhl}[3]{\bgroup%
\markoverwith{%
\rlap{%
\begin{ocg}{#1HL}{#2hl}{off}%
\textcolor{#3!50}{\rule[-0.65ex]{.1pt}{2.5ex}}%
\end{ocg}}%
\begin{ocg}{#1UL}{#2ul}{on}%
\textcolor{#3}{\rule[-0.5ex]{.1pt}{0.4pt}}%
\end{ocg}}\ULon}
% TikZ anchors in the text need to be \hbox-ed to allow the
% underlining to work correctly.
\newcommand{\jymanchor}[1]{%
\hbox{\tikz[remember picture]{\coordinate (anchor#1);}}}
\begin{document}
\begin{center}
{\Large Hypertext proofs}\\
Jean-Yves Moyen
\end{center}
\begin{abstract}
Using Optional Contents Group to hide and show parts of texts and to
structure proofs (following some of L.~Lamport's
ideas~\cite{LamportProof} and creating hypertext proofs).
\end{abstract}
In \cite{LamportProof}, L.~Lamport advocates the use of ``Structured
proofs'' instead of ``prose proofs'' in order to write 21\textup{th}
century mathematical proofs.
\vdots
The ``case of study'' proof that I use is the same as the one used by
Lamport, taken from M.~Spivak's calculus book~\cite{Spivak}.
\vdots
(skipped proof from Spivak)
\section{Lamport's structured proof}
\label{sec:lamport-proof}
I give here the formulation (naming the interval) and proof of
Corollary~\ref{cor:spivak} given by Lamport. The structured proof is
typeset using Lamport's \texttt{pf2} package\footnote{
\url{http://research.microsoft.com/en-us/um/people/lamport/latex/latex.html},
the package redefines a \texttt{proof} environment which I have
renamed as \texttt{structproof} to avoid conflict with the one from
the \texttt{amsthm} package\ldots}.
\begin{corollary}
\label{cor:lamport}
If $f'(x) > 0$ for all $x$ in an interval $I$, then $f$ is
increasing on $I$.
\end{corollary}
\pflongnumbers
\begin{proof}[Lamport's Proof]~\\[-.5cm]
\begin{structproof}
\step{1}{It suffices to assume
\begin{pfenum*}
\item $a$ and $b$ are points in $I$
\item $a < b$
\end{pfenum*}
and prove $f(b) > f(a)$.
}
\begin{structproof}
\pf\ By definition of an increasing function.
\end{structproof}
\step{2}{There is some $x$ in $]a;b[$ with $f'(x) = \frac{f(b) -
f(a)}{b-a}$.}
\begin{structproof}
\step{2.1}{$f$ is differentiable on $[a;b]$.}
\begin{structproof}
\pf\ By 1.1, since $f$ is differentiable on $I$ by
hypothesis.
\end{structproof}
\step{2.2}{$f$ is continuous on $[a;b]$.}
\begin{structproof}
\pf\ By \stepref{2.1} and Theorem~\ref{thm:diff-cont}.
\end{structproof}
\qedstep
\begin{structproof}
\pf\ By \stepref{2.1}, \stepref{2.2}, and the Mean Value
Theorem (Theorem~\ref{thm:mean-value}).
\end{structproof}
\end{structproof}
\step{3}{$f'(x) > 0$ for all $x$ in $]a;b[$.}
\begin{structproof}
\pf\ By the hypothesis of the corollary and assumption 1.1
\end{structproof}
\step{4}{$\frac{f(b) - f(a)}{b-a} > 0$.}
\begin{structproof}
\pf\ By \stepref{2} and \stepref{3}.
\end{structproof}
\qedstep
\begin{structproof}
\pf\ Assumption 1.2 implies $b-a>0$, so \stepref{4} implies
$f(b)-f(b) > 0$, which implies $f(b) > f(a)$. By \stepref{1}, this
proves the corollary.
\end{structproof}
\end{structproof}
\end{proof}
\newpage
\section{Hypertext prose proof}
\begin{corollary}
\label{cor:jym}
% some slanted/italic letters go out of their bounding box and a \,
% must be added to avoid the highlight of the space to 'eat' the
% letter.
If \ocghline{f' positive
HL}{derposhl}{off}{orange}{$f'(x) > 0$\jymanchor{derposhyp} for\,
all\, $x$ in an interval\, $I$}, then $f$ is increasing on $I$.
\end{corollary}
\begin{proof}[Hypertext prose proof]
\switchocg{increasingul
increasinghl}{\jymulhl{Increasing}{increasing}{green}{Let us
consider any two points in $I$, $a$ and $b$ , with $a < b$
and\jymanchor{increasing} show $f(a) < f(b)$.}}\\
\jymanchor{exists}There exists some $x$ in $]a;b[$ with
\[
f'(x) = \frac{f(b) - f(a)}{b-a}.
\]
\jymanchor{mean}But \switchocg{derposul derposhl}{\jymulhl{f'
positive}{derpos}{orange}{$f'(x) > 0$\jymanchor{derposused} for
all $x$ in $]a;b[$}}, so
\[
\frac{f(b) - f(a)}{b-a} > 0.
\]
\jymanchor{concl}Since $b-a>0$ it follows that $f(b)>f(a)$.
\end{proof}
% Extra decorations
\begin{tikzpicture}[remember picture, overlay]
\draw[blue, line width=.3ex] ($(anchorexists) + (-0.2ex,2ex)$) --
($(anchormean) + (-0.2ex,2.3ex)$);
\end{tikzpicture}
% OCGs
% a<b sufficient
\begin{tikzpicture}[remember picture, overlay, ocg={name=Increasing
proof, ref=increasinghl, status=invisible}]
\coordinate (anchorcallout) at ($(anchorincreasing) + (0,1.5ex)$);
\node[draw=green, fill=green!20, rectangle callout, rounded corners,
callout absolute pointer=(anchorcallout), text width=5cm, inner
sep=1ex]
(increasingexplanation) at ($(anchorincreasing) + (-0.5,1.8)$) {By
definition of an increasing function, this suffices to prove the
result.};
\coordinate (innernw) at ($(increasingexplanation.north west) +
(0.1,-0.1)$);
\coordinate (innersw) at ($(increasingexplanation.south west) +
(0.1,0.1)$);
\coordinate (innerne) at ($(increasingexplanation.north east) +
(-0.1,-0.1)$);
\coordinate (innerse) at ($(increasingexplanation.south east) +
(-0.1,0.1)$);
\coordinate (inneranchor) at ($(innernw)!0.6!(innersw)$);
\draw[red, line width=.3ex] (innernw) -- (innersw);
\path[switch ocg={nested1}] (innersw) rectangle (innerne);
\begin{scope}[ocg={name=Expanding def, ref=nested1,
status=invisible}]
\draw[red, line width=.3ex] (innersw) rectangle (innerne);
\node[draw=red, fill=red!30, rectangle callout, rounded corners,
callout absolute pointer=(inneranchor), text width = 7cm] at
($(inneranchor) + (-4,1)$) {By Definition~\ref{def:increasing},
$f$ is increasing on $I$ iff $\forall a, b \in I$ with $a < b$,
we have $f(a) < f(b)$. Thus, to prove that $f$ is increasing on
$I$, it is sufficient to consider any two $a$ and $b$ in $I$
with $a < b$ and show $f(a) < f(b)$.};
\end{scope}
\end{tikzpicture}
% button for the MVT application
\begin{tikzpicture}[remember picture, overlay]
\coordinate (existssw) at ($(anchormean) + (-0.2ex,2.3ex)$);
\coordinate (existsne) at ($(anchorexists) + (9.6cm,2ex)$);
\path[switch ocg={existshl}] (existssw) rectangle (existsne);
\end{tikzpicture}
% MVT details.
\begin{tikzpicture}[remember picture, overlay, ocg={name=Exists HL,
ref=existshl, status=invisible}]
\coordinate (existscallout) at ($(existsne) + (0,-0.2cm)$);
\fill[blue, opacity=.2] (existssw) rectangle (existsne);
\node[draw=blue, fill=blue!20, rectangle callout, rounded corners,
callout absolute pointer=(existscallout), text width=5cm, inner
sep=1ex] (existsexplanation) at ($(existscallout) + (3cm, -0.5cm)$)
{By the Mean Value Theorem (Theorem~\ref{thm:mean-value}).};
\coordinate (mvtnw) at ($(existsexplanation.north west) +
(0.1,-0.1)$);
\coordinate (mvtsw) at ($(existsexplanation.south west) +
(0.1,0.1)$);
\coordinate (mvtne) at ($(existsexplanation.north east) +
(-0.1,-0.1)$);
\coordinate (mvtse) at ($(existsexplanation.south east) +
(-0.1,0.1)$);
\coordinate (mvtanchor) at ($(mvtnw)!0.6!(mvtne)$);
\draw[red, line width=.3ex] (mvtnw) -- (mvtsw);
\path[switch ocg={mvtshort}] (mvtsw) rectangle (mvtne);
\begin{scope}[ocg={name=Mean Value, ref=mvtshort, status=invisible}]
\draw[red, line width=.3ex] (mvtsw) rectangle (mvtne);
\node[draw=red, fill=red!30, rectangle callout, rounded corners,
callout absolute pointer=(mvtanchor), text width = 6cm] at
($(mvtanchor) + (-0.5,2)$)
{\textcolor{pink}{$\bullet$}\jymanchor{diffclose}%
\switchocg{diffclose}{\ocghline{Foo}{diffclose}{off}{pink!20}{$f$
is differentiable on $[a;b]$.}}\\
\textcolor{pink}{$\bullet$}\jymanchor{diffopen}%
\switchocg{diffopen}{\ocghline{Foo}{diffopen}{off}{pink!20}{$f$
is differentiable on $]a;b[$.}}\\
\textcolor{pink}{$\bullet$}\jymanchor{cont}%
\switchocg{cont}{\ocghline{Foo}{cont}{off}{pink!20}{$f$
is continuous on $[a;b]$.}}\\
Therefore, by the Mean Value Theorem
(Theorem~\ref{thm:mean-value}), there exists such an $x$.};
\coordinate (calloutdiffclose) at ($(anchordiffclose) + (-1ex,0.7ex)$);
\coordinate (calloutdiffopen) at ($(anchordiffopen) + (-1ex,0.7ex)$);
\coordinate (calloutcont) at ($(anchorcont) + (-1ex,0.7ex)$);
\begin{scope}[ocg={name=Differentiable on close, ref=diffclose,
status=invisible}]
\node[draw=pink, fill=pink!20, rectangle callout, rounded
corners, callout absolute pointer=(calloutdiffclose), text
width=8cm] at ($(anchordiffclose) + (-5cm, 1.2cm)$) {Because
$[a;b] \subset I$ and $f$ is differentiable on $I$ by
hypothesis.};
\end{scope}
\begin{scope}[ocg={name=Differentiable on open, ref=diffopen,
status=invisible}]
\node[draw=pink, fill=pink!20, rectangle callout, rounded
corners, callout absolute pointer=(calloutdiffopen), text
width=8cm] at ($(anchordiffopen) + (-5cm, 0.15cm)$) {Because
$]a;b[ \subset I$ and $f$ is differentiable on $I$ by
hypothesis.};
\end{scope}
\begin{scope}[ocg={name=Continuous, ref=cont,
status=invisible}]
\node[draw=pink, fill=pink!20, rectangle callout, rounded
corners, callout absolute pointer=(calloutcont), text width=8cm]
at ($(anchorcont) + (-5cm, -0.9cm)$) {Because $f$ is
differentiable on $[a;b]$ by the previous points, thus it is
continuous on $[a;b]$ by Theorem~\ref{thm:diff-cont}.};
\end{scope}
\end{scope}
\end{tikzpicture}
% f' positive by hypothesis.
\begin{tikzpicture}[remember picture, overlay, ocg={name=f' positive HL,
ref=derposhl, status=invisible}]
\coordinate (calloutderposused) at ($(anchorderposused) +
(0,1.5ex)$);
\node[draw=orange, fill=orange!20, rectangle callout, rounded
corners, callout absolute pointer=(calloutderposused)] at
($(anchorderposused)!0.8!(anchorderposhyp)$) {By hypothesis, because
$]a;b[ \subset I$.};
\end{tikzpicture}
\textbf{Comments.} In short, all parts with a coloured line or dot
next to them are buttons that can be clicked to show (or hide) a more
detailed explanation of the assertion.
This is more a ``proof of concept'' than a real attempt at having an
hypertext proof. Especially, the proof has a lot of ``bells and
whistles'' that are probably useless. Moreover, various different ways
of indicating that an explanation exists are mixed and this is
probably not a good idea in general.
However, this shows that it is possible to have such added details to
a proof in a reasonable way. This can be useful in many academic
situations, including hiding solution of exercises in a textbook, or
preparing an article with both a short and a long version mixed
without resorting to appendices (that are often clumsy to navigate
back and forth).
Due to restrictions in \texttt{pdf} (or in my knowledge of it), it is
not possible to have the extra explanations ``push down'' the
following text when appearing. All the space for them must be reserved
in advance. This is why I chose to used multiple ``pop-ups'' to
display the explanations rather than having huge white gaps in the
text like the following (\switchocg{text}{\textcolor{red}{Click me!}})
\begin{ocg}{Hidden text}{text}{off}
This is a hidden text (e.g., paragraph).
\end{ocg}
The typesetting and (especially) positioning of all this is currently
done manually (and somewhat painfully).
\vdots
The manual positioning can be somewhat improved by using more relative
coordinates and the various ``\texttt{north east}'' and so on anchors
on Ti\emph{k}Z nodes, but this was not my main goal\ldots
\vspace{10cm}
\hspace{5cm} \jymanchor{toto}
% button
\begin{tikzpicture}[remember picture, overlay]
\coordinate (totosw) at ($(anchortoto) + (-1cm,-0.5cm)$);
\coordinate (totone) at ($(anchortoto) + (1cm,0.5cm)$);
\path[switch ocg={achievement}] (totosw) rectangle (totone);
\end{tikzpicture}
\begin{tikzpicture}[remember picture, overlay, ocg={name=Achievement,
ref=achievement, status=invisible}]
\node[starburst, draw, red,fill=yellow,line width=1.5pt, text
width=5cm] at (anchortoto) {\begin{center} \textsc{\Large
Achievement Unlocked!}\\
Click in the middle of nowhere.\\
\scriptsize \textcolor{orange}{Did you read the code to find
me?}
\end{center}
};
\end{tikzpicture}
\newpage
\section{Hypertext structured proof}
\begin{proof}[Hypertext structured proof]~\\[-.5cm]
\begin{structproof}
% Strange stuff happens if the anchor is placed before the 'It'
% (it is actually placed at the very start of the proof, before
% the first step). I assume strange behaviour of the \step
% command.
\step{1}{It\jymanchor{struct1} suffices to assume
\begin{pfenum*}
\item $a$ and $b$ are points in $I$\jymanchor{left1}
\item $a < b$
\end{pfenum*}
and prove $f(b) > f(a)$.\jymanchor{struct1bis}
}
\step{2}{\switchocg{struct2 struct2proof}{\largeocghline{Structure
2}{struct2}{off}{green!50}{There is some $x$ in $]a;b[$
with $f'(x) = \frac{f(b) - f(a)}{b-a}$.}}\jymanchor{left2}}
\step{3}{\switchocg{struct3}{\ocghline{Structure
3}{struct3}{off}{red!50}{$f'(x) > 0$ for all $x$ in
$]a;b[$.}}\jymanchor{left3}}
\step{4}{\switchocg{struct4}{\largeocghline{Structure
4}{struct4}{off}{blue!50}{$\frac{f(b) - f(a)}{b-a} >
0$.}}\jymanchor{left4}}
\step{5}{\switchocg{struct5}{\ocghline{Structure
5}{struct5}{off}{orange!50}{Q.E.D.}}\jymanchor{left5}}
% should use \qedPfkwd
\end{structproof}
\end{proof}
% button for 1
\begin{tikzpicture}[remember picture, overlay]
\coordinate (struct1nw) at ($(anchorstruct1) + (-2ex,2.3ex)$);
\coordinate (struct1se) at ($(anchorstruct1bis) + (5.2ex,-0.5ex)$);
\path[switch ocg={struct1hl}] (struct1nw) rectangle (struct1se);
\end{tikzpicture}
\begin{tikzpicture}[remember picture, overlay, ocg={name=Structure 1 HL,
ref=struct1hl, status=invisible}]
\fill[yellow, opacity=.3] (struct1nw) rectangle (struct1se);
\node[draw=yellow, fill=yellow!20, rectangle, rounded corners] at
($(anchorleft1) + (3cm,2cm)$) {\pf\ By definition of an increasing
function.};
\end{tikzpicture}
% Proof for 2
\begin{tikzpicture}[remember picture, overlay, ocg={name=Structure 2 Proof,
ref=struct2proof, status=invisible}]
\node[draw=green, fill=green!20, rectangle, rounded corners,
text width=7cm] at ($(anchorleft2) + (4cm, 1.15cm)$) {%
\begin{structproof}
\nostep{no1}
\nostep{no2}
\begin{noproof}
\step{2.1}{\switchocg{struct21}{$f$ is differentiable on
$[a;b]$.}}
\begin{ocg}{Structure 2.1}{struct21}{off}
\begin{structproof}
\pf\ By 1.1, since $f$ is differentiable on $I$ by
hypothesis.
\end{structproof}
\end{ocg}
\step{2.2}{\switchocg{struct22}{$f$ is continuous on
$[a;b]$.}}
\begin{ocg}{Structure 2.2}{struct22}{off}
\begin{structproof}
\pf\ By \stepref{2.1} and Theorem~\ref{thm:diff-cont}.
\end{structproof}
\end{ocg}
% \qedstep is not easy to OCG-ise…
% \qedstep
\step{2.3}{\switchocg{struct23}{Q.E.D.}} % should use \qedPfkwd
\begin{ocg}{Structure 2.3}{struct23}{off}
\begin{structproof}
\pf\ By \stepref{2.1}, \stepref{2.2}, and the Mean Value
Theorem (Theorem~\ref{thm:mean-value}).
\end{structproof}
\end{ocg}
\end{noproof}
\end{structproof}
};
\end{tikzpicture}
% Proof for 3
\begin{tikzpicture}[remember picture, overlay, ocg={name=Structure 3,
ref=struct3, status=invisible}]
\node[draw=red, fill=red!20, rectangle, rounded corners] at
($(anchorleft3) + (6cm,-0.6cm)$) {\pf\ By the hypothesis of the corollary
and assumption 1.1.};
\end{tikzpicture}
% Proof for 4
\begin{tikzpicture}[remember picture, overlay, ocg={name=Structure 4,
ref=struct4, status=invisible}]
\node[draw=blue, fill=blue!20, rectangle, rounded corners] at
($(anchorleft4) + (3cm,-0.7cm)$) {\pf\ By 2 and 3.};
\end{tikzpicture}
% Proof for 5
\begin{tikzpicture}[remember picture, overlay, ocg={name=Structure 5,
ref=struct5, status=invisible}]
\node[draw=orange, fill=orange!20, rectangle, rounded corners, text
width=15cm] at ($(anchorleft5) + (6.8cm,-1.2cm)$) {\pf\ Assumption 1.2
implies $b-a>0$, so 4 implies $f(b)-f(b) > 0$, which implies
$f(b) > f(a)$. By 1, this proves the corollary.};
\end{tikzpicture}
\vspace{-1.5cm}
\textbf{Comments.} The very good point about the structured hypertext
proof is that we can make use of the structure. On the reader point of
view, that means that every assumption (proof step) that is not proved
can be clicked to display its proof; there is no need to the somewhat
clumsy lines indicating ``details available'' in the prose proof. I
also find it easier to locate steps 2 and 3 when reading the proof of
step 4, because they are not interleaved with their proofs. On the
writer point of view, that means that the \verb+\step+ command of the
\texttt{pf2} package can be modified to automatically produce all the
needed buttons.
On the other hand, the structured proof might go into deeper level of
nesting of proofs. I do not imagine how it would be possible to
correctly lay out 4 or 6 nested levels of proof pop-ups. Well, likely
by actually not hiding all of them and considering that, say, the
first and second levels are the backbone of the proof, and should
always be displayed, and that the pop-ups should only start at the
third or so level\ldots
The other bad point, on a purely technical point of view, is that the
pop-ups are not part of the structured proof environment. That means
that commands like \verb+\stepref+ do not work. In this precise case,
I entered the number of the steps by hand but this is obviously not a
good idea. \verb+\pflabel+ and \verb+\pfref+ should be used
instead. However, on a ``logical structure'' point of view it is still
somewhat unsatisfactory that the subproofs are not really parts of the
proof.
On the good side, when both the statements and the proofs are short,
as this is the case here, the global positioning is easier with an
implicit splitting of the page in two.
\smallskip
This time, I chose to inline the proofs of the substeps 2.1, 2.2, and
2.3. I feel that because it is already part of a pop-up and because
they are short enough, the white space (well, green space, actually)
left when they are hidden is acceptable. Moreover, having separate
pop-ups for these would not have been easy to position without putting
them on top of the main step 2 itself and I do think that it is a bad
idea to prevent the reader from seeing both an assumption and its
complete proof.
I also chose not to add any ``callout'' pointers from the proof to the
assumption. I think that the differences in colours are sufficient to
avoid any mistake. Again, this is also a case display of what can be
done and how it looks like, hence it is good to have different layouts
to choose from.
Also, due to the shortness of the proofs, I was able to fan out all
the pop-ups without any covering another. This allows for a rather
nice result of the whole proof being visible if wanted.
\bigskip
As a closing word, I just want to mention that \switchocg{explul
explhl}{\jymulhl{Explanations}{expl}{blue}{this technique is
not\jymanchor{expl} restricted to proofs.}}
\begin{tikzpicture}[remember picture, overlay, ocg={name=Explanations HL,
ref=explhl, status=invisible}]
\coordinate (calloutexpl) at ($(anchorexpl) + (0,1.5ex)$);
\node[draw=blue, fill=blue!20, rectangle callout, rounded corners,
callout absolute pointer=(calloutexpl), text width=12cm] at
($(anchorexpl) + (-2cm,4cm)$) {Explanations in a running text can
also be provided, for example, to detail some arguments in a
discussion; or for parts of a text that are useful on the first
read but can be omitted when rereading because they go into a lot
of details to make a point but after being read once, one normally
can remember the idea and do not need the wordy explanation
again. Thus this technique is not restricted to sciences. It can
also be used, taking example from some of my hobby fields, for:
\begin{itemize}
\item \switchocg{history}{Writing history texts and have pop-ups
recalling dates or details of events mentioned in the
text.}\\
\begin{ocg}{History}{history}{off}
``After \switchocg{bartul barthl}{\jymulhl{St
Bartholomew}{bart}{red}{St Bartholomew's\jymanchor{bart}
day massacre}}, French protestants went into hiding.''%
\end{ocg}%
\item \switchocg{rule}{Writing game rules and recall some rule
when it is referenced.}\\
\begin{ocg}{Rule}{rule}{off}
``A stack with no \switchocg{losul loshl}{\jymulhl{Line of
Supply}{los}{pink}{Line of\,\jymanchor{los} Supply}} may not
besiege.''
\end{ocg}
\end{itemize}
};
\end{tikzpicture}
\begin{tikzpicture}[remember picture, overlay, ocg={name=St
Bartholomew HL, ref=barthl, status=invisible}]
\coordinate (calloutbart) at ($(anchorbart) + (0,1.5ex)$);
\node[draw=red, fill=red!20, rectangle, rounded corners, text
width=8cm] at ($(calloutbart) + (0,2.5cm)$) {\textbf{Wikipedia}: On
the night of 23–24 August 1572, two days after the attempted
assassination of Admiral Gaspard de Coligny, the military and
political leader of the Huguenots. The king ordered the killing of
a group of Huguenot leaders, including Coligny, and the slaughter
spread throughout Paris. Lasting several weeks, the massacre
expanded outward to other urban centres and the
countryside. Modern estimates for the number of dead across France
vary widely, from 5,000 to 30,000.};
\end{tikzpicture}
\begin{tikzpicture}[remember picture, overlay, ocg={name=Line of
Supply HL, ref=loshl, status=invisible}]
\coordinate (calloutlos) at ($(anchorlos) + (0,1.5ex)$);
\node[draw=pink, fill=pink!20, rectangle, rounded corners, text
width=5cm] at ($(calloutbart) + (0,-3cm)$) {A Line of Supply goes
from the Source of Supply to the stack and may not be more than
12MP. See IX.7 for details.};
\end{tikzpicture}
\begin{thebibliography}{Lam12}
\bibitem[Lam12]{LamportProof}
Leslie Lamport.
\newblock How to write a 21st century proof.
\newblock {\em Journal of Fixed Point Theory and Applications}, March 2012.
\bibitem[Spi67]{Spivak}
Michael Spivak.
\newblock {\em Calculus}.
\newblock W. A. Benjamin, Inc., New York, 1967.
\end{thebibliography}
\end{document}