From 30e9cda301125dbde368d7bba3331bfd0f8389a1 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Thu, 13 Jul 2017 09:26:18 +0900 Subject: add lmacs popupmenu rangen renditions richtext yt4pdf --- texmf-dist/source/latex/lmacs/lmacs.dtx | 138 ++ .../source/latex/popupmenu/examples/pumen_ex.pdf | Bin 0 -> 33971 bytes .../source/latex/popupmenu/examples/pumen_ex.tex | 108 ++ .../latex/popupmenu/examples/pumen_ex_pdftex.tex | 111 ++ texmf-dist/source/latex/popupmenu/popupmenu.dtx | 261 +++ texmf-dist/source/latex/popupmenu/popupmenu.ins | 59 + texmf-dist/source/latex/rangen/rangen.dtx | 1988 ++++++++++++++++++++ texmf-dist/source/latex/rangen/rangen.ins | 64 + texmf-dist/source/latex/renditions/renditions.dtx | 214 +++ texmf-dist/source/latex/renditions/renditions.ins | 59 + texmf-dist/source/latex/renditions/test_ren.tex | 27 + .../source/latex/richtext/doc/richtextman.tex | 1106 +++++++++++ texmf-dist/source/latex/richtext/richtext.dtx | 775 ++++++++ texmf-dist/source/latex/richtext/richtext.ins | 60 + texmf-dist/source/latex/yt4pdf/doc/yt4pdf_man.pdf | Bin 0 -> 347953 bytes texmf-dist/source/latex/yt4pdf/doc/yt4pdf_man.tex | 737 ++++++++ .../source/latex/yt4pdf/examples/config_intacc.def | 29 + .../source/latex/yt4pdf/examples/graphics/MIA9.eps | Bin 0 -> 290523 bytes .../source/latex/yt4pdf/examples/graphics/MIAX.eps | Bin 0 -> 400298 bytes .../yt4pdf/examples/graphics/trustmanager.eps | Bin 0 -> 845442 bytes .../latex/yt4pdf/examples/graphics/yt_icon_sm.eps | Bin 0 -> 558266 bytes .../source/latex/yt4pdf/examples/yt4pdf-1.tex | 93 + .../source/latex/yt4pdf/examples/yt4pdf-2.tex | 152 ++ .../source/latex/yt4pdf/examples/yt4pdf-3.tex | 88 + .../source/latex/yt4pdf/graphics/pdfyt_poster.eps | Bin 0 -> 850618 bytes .../source/latex/yt4pdf/swf/pdf_tube_basic.swf | Bin 0 -> 10470 bytes texmf-dist/source/latex/yt4pdf/yt4pdf.dtx | 629 +++++++ texmf-dist/source/latex/yt4pdf/yt4pdf.ins | 60 + 28 files changed, 6758 insertions(+) create mode 100644 texmf-dist/source/latex/lmacs/lmacs.dtx create mode 100644 texmf-dist/source/latex/popupmenu/examples/pumen_ex.pdf create mode 100644 texmf-dist/source/latex/popupmenu/examples/pumen_ex.tex create mode 100644 texmf-dist/source/latex/popupmenu/examples/pumen_ex_pdftex.tex create mode 100644 texmf-dist/source/latex/popupmenu/popupmenu.dtx create mode 100644 texmf-dist/source/latex/popupmenu/popupmenu.ins create mode 100644 texmf-dist/source/latex/rangen/rangen.dtx create mode 100644 texmf-dist/source/latex/rangen/rangen.ins create mode 100644 texmf-dist/source/latex/renditions/renditions.dtx create mode 100644 texmf-dist/source/latex/renditions/renditions.ins create mode 100644 texmf-dist/source/latex/renditions/test_ren.tex create mode 100644 texmf-dist/source/latex/richtext/doc/richtextman.tex create mode 100644 texmf-dist/source/latex/richtext/richtext.dtx create mode 100644 texmf-dist/source/latex/richtext/richtext.ins create mode 100644 texmf-dist/source/latex/yt4pdf/doc/yt4pdf_man.pdf create mode 100644 texmf-dist/source/latex/yt4pdf/doc/yt4pdf_man.tex create mode 100644 texmf-dist/source/latex/yt4pdf/examples/config_intacc.def create mode 100644 texmf-dist/source/latex/yt4pdf/examples/graphics/MIA9.eps create mode 100644 texmf-dist/source/latex/yt4pdf/examples/graphics/MIAX.eps create mode 100644 texmf-dist/source/latex/yt4pdf/examples/graphics/trustmanager.eps create mode 100644 texmf-dist/source/latex/yt4pdf/examples/graphics/yt_icon_sm.eps create mode 100644 texmf-dist/source/latex/yt4pdf/examples/yt4pdf-1.tex create mode 100644 texmf-dist/source/latex/yt4pdf/examples/yt4pdf-2.tex create mode 100644 texmf-dist/source/latex/yt4pdf/examples/yt4pdf-3.tex create mode 100644 texmf-dist/source/latex/yt4pdf/graphics/pdfyt_poster.eps create mode 100644 texmf-dist/source/latex/yt4pdf/swf/pdf_tube_basic.swf create mode 100644 texmf-dist/source/latex/yt4pdf/yt4pdf.dtx create mode 100644 texmf-dist/source/latex/yt4pdf/yt4pdf.ins (limited to 'texmf-dist/source') diff --git a/texmf-dist/source/latex/lmacs/lmacs.dtx b/texmf-dist/source/latex/lmacs/lmacs.dtx new file mode 100644 index 00000000..23c3d08a --- /dev/null +++ b/texmf-dist/source/latex/lmacs/lmacs.dtx @@ -0,0 +1,138 @@ +% \iffalse meta-comment +% http://www.texdev.net/2009/10/06/a-model-dtx-file/ +% !TEX program = pdfLaTeX +%<*internal> +\iffalse +% +%<*internal> +\fi +\def\nameofplainTeX{plain} +\ifx\fmtname\nameofplainTeX\else + \expandafter\begingroup +\fi +% +%<*install> +\input docstrip.tex +\keepsilent +\askforoverwritefalse +\preamble +\endpreamble +\ifx\fmtname\nameofplainTeX +\generate{ + \file{\jobname.sty}{\from{\jobname.dtx}{package}} +} +\fi +% +%\endbatchfile +%<*internal> +\ifx\fmtname\nameofplainTeX + \expandafter\endbatchfile\else + \expandafter\endgroup\fi +% +%\NeedsTeXFormat{LaTeX2e} +%\ProvidesPackage{lmacs} +% [2012/05/30 v1.1 Imports local macro files] +%<*driver> +\documentclass{ltxdoc} +%\usepackage{\jobname} +%\usepackage[numbered]{hypdoc} +%\EnableCrossrefs +%\CodelineIndex +%\RecordChanges +\begin{document} + \DocInput{\jobname.dtx} +\end{document} +% +% \fi +% +%\GetFileInfo{\jobname.sty} +% +%\title{The \textsf{\jobname} Package} +%\author{D. P. Story} +%\date{Released \today} +% +%\maketitle +% +%\StopEventually{^^A +% \PrintChanges +% \PrintIndex +%} +% +% \begin{macrocode} +%<*package> +% \end{macrocode} +% \paragraph*{Description.} This package is used to clean up the +% preamble of {\LaTeX} files. Some preambles have a (large) number of definitions +% in them. To clean up the preamble, move the definitions in the preamble into a separate file, and +% use this package in import them into your preamble. Normally, +% \textsf{lmacs} would have a position that follows all packages for the +% document. +% +% \textsf{lmacs} stands for \underbar{l}ocal \underbar{mac}ro\underbar{s}. Normally, the files referenced are in the same folder +% as the main source file; they should not (but can) be in the search path of {\LaTeX}. +% +% \paragraph*{Demo files:} \texttt{lmacs\_tst.tex} (a simple latex source) +% and \texttt{lmacs\_aeb.tex} (a file that uses the \textsf{web} and \textsf{exerquiz} packages). +% These are found in the \texttt{examples} folder. +% +% \paragraph*{Documentation and Code.} +% We begin by requiring \texttt{kvoptions}, this package does not test for the presence +% of a class file, so we can use it. It allows us to define key-values as options of the +% package. +% \begin{macrocode} +\RequirePackage{kvoptions}[2009/07/21] +% \end{macrocode} +% \begin{macrocode} +% \end{macrocode} +% \begin{macro}{cfg} +% \begin{macro}{def} +% \begin{macro}{js} +% With these keys, you can specify the file with the specified extension be imported. +% For example, the following line +%\begin{verbatim} +% \usepackage[cfg=myconf,def=mydef,js=myjs]{lmacs} +%\end{verbatim} +% will import (using \cs{InputIfFileExists}) the files \texttt{myconf.cfg}, +% \texttt{mydef.def}, and \texttt{myjs.js}. Multiple specifications of the same +% extension is permitted, for example, +%\begin{verbatim} +% \usepackage[def=mydef1,def=mydef2]{lmacs} +%\end{verbatim} +% \begin{macrocode} +\let\LM@inputlist\@empty +% \end{macrocode} +% \cmd{\LM@input} inputs \texttt{\#1.\#2}, while \cmd{\LM@warning} issues +% a package warning if \texttt{\#1.\#2} is not found. +% \begin{macrocode} +\newcommand{\LM@input}[2]{\InputIfFileExists{#1.#2}{}% + {\LM@warning{#1}{#2}}} +\newcommand{\LM@warning}[2]{\PackageWarning{lmacs} + {The file #1.#2 cannot be found}} +% \end{macrocode} +% \DescribeMacro{!cfg}\DescribeMacro{!def}\DescribeMacro{!js}For each of these options, we add the specified file to +% \cs{LM@inputlist}, this will be executed at the end of the package. The three options +% \texttt{!cfg}, \texttt{!def}, \texttt{!js} do nothing, making it easy to include, or +% not include a file. +% \begin{macrocode} +\define@key{lmacs}{cfg}{\g@addto@macro\LM@inputlist{\LM@input{#1}{cfg}}} +\define@key{lmacs}{!cfg}{} +\define@key{lmacs}{def}{\g@addto@macro\LM@inputlist{\LM@input{#1}{def}}} +\define@key{lmacs}{!def}{} +\define@key{lmacs}{js}{\g@addto@macro\LM@inputlist{\LM@input{#1}{js}}} +\define@key{lmacs}{!js}{} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \begin{macrocode} +\ProcessKeyvalOptions{lmacs} +% \end{macrocode} +% Once the options have been process, we execute the command +% \cs{LM@inputlist} which contains a list of the files to be input. +% \begin{macrocode} +\LM@inputlist +% \end{macrocode} +% \begin{macrocode} +% +% \end{macrocode} +%\Finale diff --git a/texmf-dist/source/latex/popupmenu/examples/pumen_ex.pdf b/texmf-dist/source/latex/popupmenu/examples/pumen_ex.pdf new file mode 100644 index 00000000..c576f284 Binary files /dev/null and b/texmf-dist/source/latex/popupmenu/examples/pumen_ex.pdf differ diff --git a/texmf-dist/source/latex/popupmenu/examples/pumen_ex.tex b/texmf-dist/source/latex/popupmenu/examples/pumen_ex.tex new file mode 100644 index 00000000..6f0acc7a --- /dev/null +++ b/texmf-dist/source/latex/popupmenu/examples/pumen_ex.tex @@ -0,0 +1,108 @@ +\documentclass{article} +\usepackage[designv]{web} +\usepackage{eforms} +\usepackage{popupmenu} + +\title{The \texorpdfstring{\textsf{popupmenu}}{popupmenu} Package Test File} +\author{D. P. Story} +\subject{Test file for the popupmenu Package} +\keywords{LaTeX, popupmenu, Acrobat JavaScript, AcroTeX} + +\university{NORTHWEST FLORIDA STATE COLLEGE\\ + Department of Mathematics} +\email{dpstory@acrotex.net} +\version{1.0} + +%\nocopyright +\norevisionLabel + +% +% This package can be used by users of pdftex, dvipdfm, dvips (with distiller) +% + +\urlPath{\aebhome}{http://www.math.uakron.edu/~dpstory} + +\begin{popupmenu}{AeBMenu} + \item{title=AeB, return=\aebhome/webeq.html} + \item{title=-} + \begin{submenu}{title=AeB Pro Family} + \item{title=Home page,return=\aebhome/aeb_pro.html} + \item{title=Graphicxsp,return=\aebhome/graphicxsp.html} + \end{submenu} + \item{title=eqExam,return=\aebhome/eqexam.html} +\end{popupmenu} + +\begin{popupmenu}{AeBMenuLocal} + \item{title=AeB, return=\aebhome/webeq.html} + \item{title=-} + \begin{submenu}{title=AeB Pro Family,enabled=false} + \item{title=Home page,return=\aebhome/aeb_pro.html} + \item{title=Graphicxsp,return=\aebhome/graphicxsp.html} + \end{submenu} + \item{title=eqExam,return=\aebhome/eqexam.html} +\end{popupmenu} + +% +% This menu was taken from the Acrobat JavaScript API Reference +% as a test of the new popupmenu and submenu environments. +% +\begin{popupmenu}{myMenu} + \item{title=Item 1, marked, enabled=false} + \item{title=-} + \begin{submenu}{title=Item 2} + \item{title={Item 2, Submenu 1}} + \begin{submenu}{title={Item 2, Submenu 2}} + \item{title={Item 2, Submenu 2, Subsubmenu 1}} + \end{submenu} + \end{submenu} + \item{title=Item 3} + \item{title=Item 4} +\end{popupmenu} + +\begin{insDLJS}[AeBMenu]{md}{Menu Data} +\AeBMenu +\myMenu +\end{insDLJS} + +\parindent0pt\parskip6pt + +\begin{document} + +\maketitle + +This file uses the \textsf{eforms} package to create push buttons, +the push button of \textsf{hyperref} can also be used. + +Here is an example taken from the Acrobat JavaScript API Reference: +\pushButton[\CA{My Menu}\AA{\AAMouseEnter{\JS{% +var cChoice = \popUpMenu(myMenu);\r +if ( cChoice != null ) app.alert("You chose the \\""+cChoice+"\\" menu item"); +}}}]{mymenu}{}{11bp} + +We can add a push button with a rollover effect +\pushButton[\CA{Packages}\AA{\AAMouseEnter{\JS{% +var cChoice = \popUpMenu(AeBMenu);\r +if ( cChoice != null ) app.launchURL(cChoice); +}}}]{menu}{}{11bp} + +You can also open the menu with a link: +\setLinkText[\A{\JS{% +var cChoice = \popUpMenu(AeBMenu);\r +if ( cChoice != null ) app.launchURL(cChoice); +}}]{Package}. Links do not have a rollover effect, however, you can use buttons like so: {\setbox0=\hbox{\textcolor{red}{Packages}}% +\makebox[0pt][l]{\pushButton[\W0\BG{}\BC{}\S{S}\AA{\AAMouseEnter{\JS{% +var cChoice = \popUpMenu(AeBMenu);\r if ( cChoice != null ) +app.launchURL(cChoice); }}}]{menu}{\wd0}{\ht0+\dp0}}\unhbox0}. + +This is a version that has a local version of the menu array: +{\setbox0=\hbox{\textcolor{red}{Packages}}% +\makebox[0pt][l]{\pushButton[\W0\BG{}\BC{}\S{S}\AA{\AAMouseEnter{\JS{% +\AeBMenuLocal\r +var cChoice = \popUpMenu(AeBMenuLocal);\r if ( cChoice != null ) +app.launchURL(cChoice);}}}]{menu}{\wd0}{\ht0+\dp0}}\unhbox0} +\end{document} + +This is a version that has a local version of the menu array: +\PushButton[name=hyperbutton,onmouseover={\AeBMenuLocal +var cChoice = \popUpMenu(AeBMenuLocal); if ( cChoice != null ) +app.launchURL(cChoice); }]{Packages} diff --git a/texmf-dist/source/latex/popupmenu/examples/pumen_ex_pdftex.tex b/texmf-dist/source/latex/popupmenu/examples/pumen_ex_pdftex.tex new file mode 100644 index 00000000..3254570d --- /dev/null +++ b/texmf-dist/source/latex/popupmenu/examples/pumen_ex_pdftex.tex @@ -0,0 +1,111 @@ +\documentclass{article} +\usepackage[designv,pdftex]{web} +\usepackage{eforms} +\usepackage{popupmenu} + +\title{The \texorpdfstring{\textsf{popupmenu}}{popupmenu} Package Test File} +\author{D. P. Story} +\subject{Test file for the popupmenu Package} +\keywords{LaTeX, popupmenu, Acrobat JavaScript, AcroTeX} + +\university{NORTHWEST FLORIDA STATE COLLEGE\\ + Department of Mathematics} +\email{dpstory@acrotex.net} +\version{1.0} + +%\nocopyright +\norevisionLabel + +% +% This package can be used by users of pdftex, dvipdfm, dvips (with distiller) +% + +\urlPath{\aebhome}{http://www.math.uakron.edu/~dpstory} + +\begin{popupmenu}{AeBMenu} + \item{title=AeB, return=\aebhome/webeq.html} + \item{title=-} + \begin{submenu}{title=AeB Pro Family} + \item{title=Home page,return=\aebhome/aeb_pro.html} + \item{title=Graphicxsp,return=\aebhome/graphicxsp.html} + \end{submenu} + \item{title=eqExam,return=\aebhome/eqexam.html} +\end{popupmenu} + +\begin{popupmenu}{AeBMenuLocal} + \item{title=AeB, return=\aebhome/webeq.html} + \item{title=-} + \begin{submenu}{title=AeB Pro Family,enabled=false} + \item{title=Home page,return=\aebhome/aeb_pro.html} + \item{title=Graphicxsp,return=\aebhome/graphicxsp.html} + \end{submenu} + \item{title=eqExam,return=\aebhome/eqexam.html} +\end{popupmenu} + +% +% This menu was taken from the Acrobat JavaScript API Reference +% as a test of the new popupmenu and submenu environments. +% +\begin{popupmenu}{myMenu} + \item{title=Item 1, marked, enabled=false} + \item{title=-} + \begin{submenu}{title=Item 2} + \item{title={Item 2, Submenu 1}} + \begin{submenu}{title={Item 2, Submenu 2}} + \item{title={Item 2, Submenu 2, Subsubmenu 1}} + \end{submenu} + \end{submenu} + \item{title=Item 3} + \item{title=Item 4} +\end{popupmenu} + +\begin{insDLJS}[AeBMenu]{md}{Menu Data} +\AeBMenu +\myMenu +\end{insDLJS} + +\newcommand{\cs}[1]{\texttt{\char`\\#1}} + + +\parindent0pt\parskip6pt + +\begin{document} + +\maketitle + +This file uses the \textsf{hyperref} package to create push buttons, +the push button of \textsf{eforms} can also be used. + + +Here is an example taken from the Acrobat JavaScript API Reference, it uses +the \cs{PushButton} command of \textsf{hyperref}. The script is implemented as +a mouse up event, rather than a rollover event as it appears \cs{PushButton} does not +support rollover. There is a \texttt{onmouseover} key that is supposed to work, but it doesn't. +\PushButton[name=mymenu, +onclick={var cChoice = \popUpMenu(myMenu); +if ( cChoice != null ) app.alert("You chose the \eqbs\eqbs""+cChoice+"\eqbs\eqbs" menu item"); +}]{My Menu} + + +Here is the same example, but using \cs{pushButton}, the button command from the eforms package. +It is implemented as a rollover event. +\pushButton[\CA{My Menu}\AA{\AAMouseEnter{\JS{% +var cChoice = \popUpMenu(myMenu);\r +if ( cChoice != null ) app.alert("You chose the \\""+cChoice+"\\" menu item"); +}}}]{mymenu}{}{11bp} + +We can add a push button with a rollover effect +\pushButton[\CA{Packages}\AA{\AAMouseEnter{\JS{% +var cChoice = \popUpMenu(AeBMenu);\r +if ( cChoice != null ) app.launchURL(cChoice); +}}}]{menu}{}{11bp} + +This is a version that has a local version of the \texttt{AeBMenuLocal} array. +If we place the array as field-level JavaScript, we don't need the \textsf{eforms} package. +Again, this is an \texttt{onclick} event. +\PushButton[name=mymenu,onclick={\AeBMenuLocal; +var cChoice = \popUpMenu(AeBMenuLocal); +if ( cChoice != null ) app.launchURL(cChoice);}]{AeB Local Menu} + +Fancier examples can be found at the \textcolor{blue}{AeB Blog} (\url{www.math.uakron.edu/~dpstory/aebblog.html}). +\end{document} diff --git a/texmf-dist/source/latex/popupmenu/popupmenu.dtx b/texmf-dist/source/latex/popupmenu/popupmenu.dtx new file mode 100644 index 00000000..4ca46a31 --- /dev/null +++ b/texmf-dist/source/latex/popupmenu/popupmenu.dtx @@ -0,0 +1,261 @@ +% \iffalse +%<*copyright> +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% popupmenu.sty package, 2009-10-15 %% +%% Copyright (C) 2009 D. P. Story %% +%% dpstory@acrotex.net %% +%% storyd@nwfsc.edu %% +%% %% +%% This program can redistributed and/or modified under %% +%% the terms of the LaTeX Project Public License %% +%% Distributed from CTAN archives in directory %% +%% macros/latex/base/lppl.txt; either version 1 of the %% +%% License, or (at your option) any later version. %% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +%\NeedsTeXFormat{LaTeX2e} +%\ProvidesPackage{popupmenu} +% [2010/09/18 v1.0 Provides support for popup menus (dps)] +%<*driver> +\documentclass{ltxdoc} +\usepackage[colorlinks,hyperindex]{hyperref} +\pdfstringdefDisableCommands{\let\\\textbackslash}% +\EnableCrossrefs \CodelineIndex +\OnlyDescription % comment out for implementation details +\begin{document} + \GetFileInfo{popupmenu.sty} + \title{The \textsf{popupmenu} Package} + \author{D. P. Story\\ + Email: \texttt{dpstory@acrotex.net}} + \date{processed \today} + \maketitle + \tableofcontents + \let\Email\texttt + \DocInput{popupmenu.dtx} + \PrintIndex +\end{document} +% +% \fi +% \begin{macrocode} +%<*package> +% \end{macrocode} +% This is a short package that provides environments and commands for building +% a popup menu using JavaScript. The command \cs{popUpMenu} uses the Acrobat JavaScript +% method \texttt{app.popUpMenuEx}. This latter method requires you to pass to it a +% structured menu listing of the menu items to be displayed in the popup menu, and the actions +% to be taken when a menu item is selected. The environments \texttt{popupmenu} and +% \texttt{submenu} are defined for the purpose of creating this hierarchical structure. +% \begin{macrocode} +\RequirePackage{xkeyval} +% \end{macrocode} +% According to the JavaScript manual, the \texttt{app.popUpMenuEx} method takes +% one or more \texttt{MenuItem} objects. The {\LaTeX} access to the properties of this object are documented +% as follows (taken verbatim from the JavaScript reference): +% \begin{macro}{title} +% The menu item name, which is the string to appear on the menu item. The value of +% \texttt{"-"} is reserved to draw a separator line in the menu. +% \begin{macro}{marked} +% (optional) A Boolean value specifying whether the item is to be marked with a +% check. The default is \texttt{false} (not marked). +% \begin{macro}{enabled} +% (optional) A Boolean value specifying whether the item is to appear enabled or +% grayed out. The default is \texttt{true} (enabled). +% \begin{macro}{return} +% (optional) A string to be returned when the menu item is selected. The default is the +% value of cName. +% \begin{macrocode} +\define@key{menustruct}{title}[]{\def\menustruct@title{#1}} +\define@boolkey{menustruct}{marked}[true]{} +\define@boolkey{menustruct}{enabled}[true]{} +\define@key{menustruct}{return}[]{\def\menustruct@return{#1}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% We use the command \cs{pum@holdtoks} to hold the menu items as they are processed +% in the environment, and use \cs{@AddToMenuToks} to add to the items. +% \begin{macrocode} +\let\pum@holdtoks\@empty +\newcommand{\@AddToMenuToks}{\g@addto@macro\pum@holdtoks} +% \end{macrocode} +% \begin{environment}{popupmenu} +% We begin by defining our menu structure using the +% \texttt{popupmenu} environment. Within this environment, +% we list the items in the menu using \cs{item} and +% the \texttt{submenu} menu if there are sub menus. +% +% The \texttt{popupmenu} command requires one parameter, this command is +% used to create both a command and a JavaScript variable. The name is +% passed to the \cs{popUpMenu} command, while the command version of the +% name expands to the menu structure. The menu structure can be placed +% at the document level, or as part of a push button action. +% Here is an example of usage:\par +% \begin{verbatim} +%\urlPath{\aebhome}{http://www.math.uakron.edu/~dpstory} +%\begin{popupmenu}{myMenu} +% \item{title=AeB,return=\aebhome/webeq.html} +% \item{title=-} +% \begin{submenu}{title=AeB Pro Family} +% \item{title=Home page, return=\aebhome/aeb_pro.html} +% \item{title=Graphicxsp, return=\aebhome/graphicxsp.html} +% \end{submenu} +% \item{title=eqExam, return=\aebhome/eqexam.html} +%\end{popupmenu} +%\end{verbatim} +%The above definition can be conveniently placed in the preamble, though it can +% appear anywhere before it is used, obviously. Now to use the menu structure, +% all we need is a push button or link to create a JavaScript action: +%\begin{verbatim} +% \pushButton[\CA{Packages}\AA{\AAMouseEnter{\JS{% +% \myMenu\r +% var cChoice = \popUpMenu(myMenu);\r +% if ( cChoice != null ) app.launchURL(cChoice); +% }}}]{menu}{}{11bp} +%\end{verbatim} +% The above example uses the \textsf{eforms} package, but a push button from \textsf{hyperref} will do too. +% The \texttt{app.popUpMenuEx} method returns the return value, which we, in turn, process. In this +% case, the return is a URL, which we launch. +% +% If we have placed \cs{myMenu} at the document level, the line \verb!\myMenu\r! would not be needed. +% If you are using the same menu several times in the document, put it at the document level to reduce +% file size. +% +% Also, in the above example, you see how the name, \texttt{myMenu}, passed as an argument +% of the popupmenu environment is used as a name and as a command: The name is passed to +% \cs{popUpMenu}, while the command expands to the menu structure that is referenced by the name. +% \begin{macrocode} +% \end{macrocode} +% \begin{macro}{\itemindex} +% We generate the index of each menu item. \cs{itemindex} is +% the index of the menu structure array; for example, +% \cs{itemindex} might expand to \texttt{[0]}, \texttt{[1].oSubMenu[3]}, or \texttt{[2].oSubMenu[3].oSubMenu[0]}. +% If \cs{itemindex} is included in the return value (possibly as an array entry), we can +% know the item the use selected +%\begin{verbatim} +%var aChoice=processMenu(AeBMenu); +%if (aChoice!=null) { +% var thisChoice=aChoice[0]; // this is a string +% var thistitle=eval("AeBMenu"+thisChoice+".cName"); +% app.alert(thistitle); +%} +%\end{verbatim} +% The above code gets the return array, then uses it to get the title of the item +% selected, +% \begin{macrocode} +\newcount\pum@cnt +\def\pum@updateindex{\global\advance\pum@cnt\@ne + \edef\pum@rc{\pum@topindex[\the\pum@cnt]}\edef\itemindex{'\pum@rc'}} +\def\pum@initIndexMenu#1{\global\pum@cnt=-1\relax\edef\pum@rc{#1}% + \edef\pum@topindex{\pum@rc}} +% \end{macrocode} +% \end{macro} +% We are now ready to define the \texttt{popupmenu} environment. The environment +% takes one required parameter, a name that is used as a JavaScript variable. +% This name is also used to create a command. +% \begin{macrocode} +\newenvironment{popupmenu}[1]{\pum@initIndexMenu{}% + \let\pum@holdtoks\@empty + \toks@={\pum@mytab}\@makeother\~ +% \end{macrocode} +% We initialize with a \cs{@gobble}, which eats up the leading comma (,) +% that is placed there by the code below. +% \begin{macrocode} + \gdef\msarg{#1}\@AddToMenuToks{\@gobble}% + \let\item\pum@item +}{% + \expandafter\xdef\csname\msarg\endcsname{% + var \msarg\space = [ \pum@holdtoks^^J];}% +} +% \end{macrocode} +% \end{environment} +% \begin{macro}{\pum@item} +% At the startup of the \texttt{popupmenu} environment, we \verb|\let\item\pum@item|. +% The definition of \cs{pum@item} takes one argument, the properties described above. +% \begin{macrocode} +\newcommand{\pum@item}[1]{\pum@updateindex + \edef\tmp@exp{\noexpand + \setkeys{menustruct}{title,marked=false,enabled,return,#1}}\tmp@exp + \edef\tmp@exp{,^^J\the\toks@ + {cName: "\menustruct@title"% + \ifKV@menustruct@marked, bMarked: true\fi% + \ifKV@menustruct@enabled\else, bEnabled: false\fi% + \ifx\menustruct@return\@empty\else, + cReturn: "\menustruct@return"\fi}}% + \expandafter\@AddToMenuToks\expandafter{\tmp@exp}% +} +% \end{macrocode} +% \end{macro} +% Some technical matters, we need unmatched braces, so we define +% \cs{pum@lbrace} and \cs{pum@rbrace}. +% \begin{macrocode} +\begingroup +\catcode`<=1 \catcode`\>=2 \@makeother\{ \@makeother\} +\gdef\pum@lbrace<{>\gdef\pum@rbrace<}> +\endgroup +\def\pum@mytab{\space\space\space\space} +% \end{macrocode} +% \begin{environment}{submenu} +% Used to create a submenu of a menu item. The top level menu item has no return value, +% it can be marked but cannot be dis-enabled (\texttt{enabled=false}). +% +% The argument of \texttt{submenu} are any of the menu item properties, however, only +% \texttt{title} and \texttt{marked} will be recognized. +% +% The JavaScript property, \texttt{oSubMenu}, of the menu structure passed to +% the method \texttt{app.popUpMenuEx} has no {\LaTeX} counterpart. This property +% key-value pair is automatically inserted by the \texttt{submenu} +% environment. +% \begin{macrocode} +\newenvironment{submenu}[1]{\pum@updateindex + \xdef\saved@pum@cnt{\the\pum@cnt}% + \pum@initIndexMenu{\pum@rc.oSubMenu}\edef\temp@toks{\the\toks@}% + \toks@=\expandafter{\temp@toks\pum@mytab}% + \setkeys{menustruct}{title,marked=false,enabled,return,#1}% + \edef\tmp@exp{,^^J\the\toks@ + \noexpand\pum@lbrace cName: "\menustruct@title"% + \ifKV@menustruct@marked, bMarked: true\fi% + \ifKV@menustruct@enabled\else, bEnabled: false\fi, + oSubMenu:^^J\the\toks@[}% +% \end{macrocode} +% Again, we \cs{@gobble} up the leading comma (,). +% \begin{macrocode} + \expandafter\@AddToMenuToks\expandafter{\tmp@exp\@gobble}% +}{% + \edef\tmp@exp{^^J\the\toks@ ]\pum@rbrace}% + \expandafter\@AddToMenuToks\expandafter{\tmp@exp}% + \global\pum@cnt\saved@pum@cnt +} +% \end{macrocode} +% \end{environment} +% \begin{macro}{\popUpMenu} +% The \cs{popUpMenu} command takes one argument, the name pass to a +% popupmenu environment. The command expands to the \texttt{app.popUpMenuEx} +% method. The document author must then process the return value in some way. +% The argument is enclosed in parentheses, this is so we can use \cs{popUpMenu} +% at the document level, we can pass it an argument there. +% \begin{macrocode} +\def\popUpMenu(#1){app.popUpMenuEx.apply( app, #1 )} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\urlPath} +% A convenience command to save a url path. The string is normalized using +% the \textsf{hyperref} command \cs{hyper@normalise}. Though we don't require +% any other packages, you can't do much unless you use \textsf{hyperref} as well. +% \begin{macrocode} +\providecommand{\urlPath}[1]{\def\pum@urlName{#1}% + \hyper@normalise\pum@urlPath} +\def\pum@urlPath#1{\expandafter\xdef\pum@urlName{#1}} +% \end{macrocode} +% \end{macro} +% \begin{macrocode} +% +% \end{macrocode} +% \Finale +\endinput +History: + (2010/09/18 v.8) Replaced \count\z@ by \pun@cnt, and change the + increment to global. The index was not correct when there were several + submenus. + (2009/10/20 v.7) Added \itemindex, which calculates the index of the menu item + selected. Can be passed to the handling code as part of the return value. diff --git a/texmf-dist/source/latex/popupmenu/popupmenu.ins b/texmf-dist/source/latex/popupmenu/popupmenu.ins new file mode 100644 index 00000000..1223d03e --- /dev/null +++ b/texmf-dist/source/latex/popupmenu/popupmenu.ins @@ -0,0 +1,59 @@ +%% +%% This file will generate fast loadable files and documentation +%% driver files from the doc files in this package when run through +%% LaTeX or TeX. +%% +%% Copyright 1999-2006 D. P. Story +%% +%% This file is part of the `AcroTeX eDucation Bundle'. +%% ------------------------------------------- +%% +%% It may be distributed under the conditions of the LaTeX Project Public +%% License, either version 1.2 of this license or (at your option) any +%% later version. The latest version of this license is in +%% http://www.latex-project.org/lppl.txt +%% and version 1.2 or later is part of all distributions of LaTeX +%% version 1999/12/01 or later. +%% +%% --------------- start of docstrip commands ------------------ +%% +\def\filedate{2009/10/15} +\def\batchfile{popupmenu.ins} +% +\input docstrip +\ifx\generate\undefined + \Msg{**********************************************} + \Msg{*} + \Msg{* This installation requires docstrip} + \Msg{* version 2.4 or later.} + \Msg{*} + \Msg{* An older version of docstrip has been input} + \Msg{*} + \Msg{**********************************************} + \errhelp{Move or rename old docstrip.tex and get a newer one.} + \errmessage{Old docstrip in input path} + \batchmode + \csname @@end\endcsname\end +\fi + +\keepsilent +\askforoverwritefalse +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\preamble +\endpreamble +\generate +{% + \file{popupmenu.sty}{\from{popupmenu.dtx}{copyright,package}} +} + +\Msg{***************************************************************} +\Msg{*} +\Msg{* \space To finish the installation you have to copy the files } +\Msg{*} +\Msg{* \space *.sty, *.cfg and *.def into a directory searched by TeX} +\Msg{*} +\Msg{***************************************************************} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\endinput diff --git a/texmf-dist/source/latex/rangen/rangen.dtx b/texmf-dist/source/latex/rangen/rangen.dtx new file mode 100644 index 00000000..637775f9 --- /dev/null +++ b/texmf-dist/source/latex/rangen/rangen.dtx @@ -0,0 +1,1988 @@ +%\iffalse +%<*copyright> +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Rangen.sty package, 2016-02-19 %% +%% Copyright (C) 1999-2016 D. P. Story %% +%% dpstory@uakron.edu %% +%% %% +%% This program can redistributed and/or modified under %% +%% the terms of the LaTeX Project Public License %% +%% Distributed from CTAN archives in directory %% +%% macros/latex/base/lppl.txt; either version 1 of the %% +%% License, or (at your option) any later version. %% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +%\NeedsTeXFormat{LaTeX2e}[1997/12/01] +%\ProvidesPackage{rangen} +% [2014/10/17 v1.4 Rangen: Generate Random Questions (dps)] +%<*driver> +\documentclass{ltxdoc} +\usepackage[colorlinks,hyperindex]{hyperref} +%\pdfstringdefDisableCommands{\let\\\textbackslash} +%\EnableCrossrefs \CodelineIndex +\begin{document} + \GetFileInfo{rangen.sty} +% \settowidth{\oddsidemargin}{0pt}% +% \setlength{\evensidemargin}{0pt} +% \setlength{\marginparsep}{0pt} +% \setlength{\marginparwidth}{0pt} +% \setlength\textwidth{6in} +% \hoffset=.5in +% \hsize = 6in + \title{\textsf{Rangen}\texorpdfstring{\\}{:} Random Generation of Integer, Rational, and Real Numbers with + Applications to the \texttt{exercise}, \texttt{quiz}, and \texttt{shortquiz} environments of \textsf{Exerquiz}} + \author{D. P. Story\\ + Email: \texttt{dpstory@uakron.edu}} + \date{processed \today} + \maketitle + \tableofcontents + \let\Email\texttt + \DocInput{rangen.dtx} + \PrintIndex +\end{document} +% +% \fi +% \MakeShortVerb{|} +% \StopEventually{} +% +% \DoNotIndex{\def,\edef,\gdef,\xdef,\global,\long,\let} +% \DoNotIndex{\expandafter,\string,\the,\ifx,\else,\fi} +% \DoNotIndex{\csname,\endcsname,\relax,\begingroup,\endgroup} +% \DoNotIndex{\DeclareTextCommand,\DeclareTextCompositeCommand} +% \DoNotIndex{\space,\@empty,\special} +% +% \begin{macrocode} +%<*package> +% \end{macrocode} +% \section{Introduction} +% +% This package provides some commands for creating randomly generated integers, rational, +% and real numbers. There are options for specifying constraints on the generation of the numbers. +% Companion JavaScript functions are developed to use these random numbers as part of a +% question in a \texttt{shortquiz} or \texttt{quiz}. The syntax of this package can be used +% to pose number-related questions, the JavaScript can be used to create the answer to the +% question based on a formula. You'll have to see it to believe it. +% +% \section{The Main Code} +% +% \subsection{Declare Options} +% +% This package has one option, other options are passed to the really nice \textsf{lcg} Package, +% by Erich Janka (\texttt{janka@utanet.at}). +% \begin{macrocode} +\newcount\seedCnt +\DeclareOption{testmode}{% + \InputIfFileExists{\jobname.seed}{}{\def\thisseed{1}}% + \PassOptionsToPackage{seed=\thisseed}{lcg}% + \AtEndOfPackage{\reseedEachRun}% +} +\def\reseedEachRun{% + \seedCnt=\thisseed + \advance\seedCnt1\relax + \newwrite \rngWrite + \immediate\openout\rngWrite \jobname.seed + \immediate\write\rngWrite{\string\def\string\thisseed{\the\seedCnt}} + \immediate\closeout\rngWrite +} +\def\RNG@Dec{.} +\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{lcg}} +\ProcessOptions +\RequirePackage{lcg}[2008/09/10] +% \end{macrocode} +% Save the seed value so we can reproduce the same pseudo-random number sequence. +% \begin{macrocode} +\edef\rng@saveSeed{\the\cr@nd} +% \end{macrocode} +% There are three data types: Integer, Rational, and Real. The following macros +% gives each of these types a numerical value, 0, 1 and 2, respectively. +% \begin{macrocode} +\newcount\loopCnt +\def\maxLoopLimit{10} +\def\typeCodeForz{0} +\def\typeCodeForq{1} +\def\typeCodeForr{2} +% \end{macrocode} +% Some scratch count registers +% \begin{macrocode} +\newcount\rng@cnta +\newcount\rng@cntb +% \end{macrocode} +% A random variable is specified using a control sequence, e.g. \cs{a}. The following macro +% extracts the underlying name of the command, e.g. \verb+\@gtVarName{\a}+ expands to \texttt{a}, +% and returns the name as the expansion of the macro \cs{@varName}. +% \begin{macrocode} +\def\@getVarName#1{% + \edef\@varName{\expandafter\@gobble\string#1}% +} +% \end{macrocode} +% The command \cs{@getVarType} takes one argument, a random variable, e.g., \cs{a}. This +% command defines a macro \cs{varType} which expands to the data type the random variable is. +% \begin{macrocode} +\def\@getVarType#1{% + \@getVarName{#1}\edef\varType{\csname typeof@\@varName\endcsname}} +% \end{macrocode} +% \subsection{GCD and Rational Reduction Commands} +% \begin{macro}{\gcd} +% Here we use Euclid's Algorithm to find the greatest common divisor of two integers. +% \begin{macrocode} +\def\gcd#1#2{{% #1 = a, #2 = b + \ifnum#2=0 \edef\next{#1}\else + \@tempcnta=#1 \@tempcntb=#2 \divide\@tempcnta by\@tempcntb + \multiply\@tempcnta by\@tempcntb % q*b + \@tempcntb=#1 + \advance\@tempcntb by-\@tempcnta % remainder in \@tempcntb + \ifnum\@tempcntb=0 + \@tempcnta=#2 + \ifnum\@tempcnta < 0 \@tempcnta=-\@tempcnta\fi + \xdef\gcd@next{\noexpand% + \def\noexpand\thegcd{\the\@tempcnta}}% + \else + \xdef\gcd@next{\noexpand\gcd{#2}{\the\@tempcntb}}% + \fi + \fi}\gcd@next +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\lcm} +% Now compute the least common multiple +% \begin{macrocode} +\def\lcm#1#2{% #1 = a, #2 = b + \gcd{#1}{#2}% + {\@tempcnta=#1 + \multiply\@tempcnta by#2 + \divide\@tempcnta by\thegcd + \xdef\thelcm{\the\@tempcnta}}% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\amodb} +% Modular arithmetic \texttt{a mod b}, returns its results +% as a macro \cs{retnmod}. +% \begin{macrocode} +\def\amodb#1#2{% #1 = a, #2 = b + {\@tempcnta=#1 + \divide\@tempcnta by#2 + \multiply\@tempcnta by#2 + \@tempcntb=#1 + \advance\@tempcntb by-\@tempcnta + \xdef\retnmod{\the\@tempcntb}}% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\reduceFrac} +% Reduce a fraction to lowest terms. The first argument is the numerator and the second +% argument is the denominator. This command computes the \texttt{gcd} of the two integers, +% divides each by the \texttt{gcd}, and returns the results in the two scratch count +% registers \cs{@tempcnta} and \cs{@tempcntb}. +% \begin{macrocode} +\newcommand\reduceFrac[2] +{% + \gcd{#1}{#2}{\@tempcnta=#1 \divide\@tempcnta by\thegcd + \@tempcntb=#2 \divide\@tempcntb by\thegcd + \ifnum\@tempcntb<0\relax +% \end{macrocode} +% Always have the denominator as positive. +% \begin{macrocode} + \@tempcntb=-\@tempcntb + \@tempcnta=-\@tempcnta + \fi + \xdef\rfNumer{\the\@tempcnta}\xdef\rfDenom{\the\@tempcntb}}% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\convertRatTo} +% Converts a fraction \texttt{a/b} (\texttt{\#1/\#2}) to a denominator of \texttt{\#3}. Will return +% new numerator in \cs{rnd@Cnta} register. This will be exact if +% \texttt{\#2} divides \texttt{\#3}. +% \begin{macrocode} +\def\convertRatTo#1#2#3{{% + \@tempcnta=#3 + \multiply\@tempcnta by#1 + \divide\@tempcnta by#2 + \xdef\rng@retn@num{\the\@tempcnta}% +}} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\RNGadd} +% This is the support for rational arithmetic (addition and subtraction). +% Adds two rational numbers, \texttt{\#1} and \texttt{\#2} together. These two rational numbers must have been defined +% already, possibly by \cs{defineQ}. Usage: \verb+\RNGadd\a\b+. This macro returns a rational number: +% the numerator in the \cs{rfNumer} command, and the denominator in the \cs{rfDenom} command. +% For example, +%\begin{verbatim} +%\defineQ\a{1}{3}\defineQ\b{3}{5}\RNGadd\a\b +%\makeatletter +%The sum of $\frac{\nOf\a}{\dOf\a} + \frac{\nOf\b}{\dOf\b} +% = \frac{\rfNumer}{\rfDenom}$ +%\makeatother +%\end{verbatim} +%This code typesets as $\frac{1}{3}+\frac{3}{5}=\frac{14}{15}$. +% \begin{macrocode} +\newcommand\RNGadd[2]{% + \rng@cnta=\nOf#1 \multiply\rng@cnta by\dOf#2 + \rng@cntb=\nOf#2 \multiply\rng@cntb by\dOf#1 + \advance\rng@cnta by\the\rng@cntb + \rng@cntb=\dOf#1 \multiply\rng@cntb by\dOf#2 + \reduceFrac{\the\rng@cnta}{\the\rng@cntb} +} +% \end{macrocode} +% \end{macro} +% This is a simple macro for detecting if the argument \texttt{\#1} +% is a macro or not. Used when interval definitions of the +% \cs{RandomZ/Q/R} macros. +% \begin{macrocode} +\def\rng@isControl#1{\@ifundefined{\expandafter\@gobble\string#1}% + {\let\rng@isC@ntrol=0}{\let\rng@isC@ntrol=1}} +% \end{macrocode} +% This command determines if its argument has an \texttt{*} +% prefixed or post-fixed to its argument. +% If \cs{rng@isStariii} equals \texttt{*}, then an \texttt{*} exists. +% \begin{itemize} +% \item If there is no \texttt{*}, then the argument is \texttt{\#1} +% \item \cs{rng@isStariii} equals \texttt{*}, there is \texttt{*}, +% If the argument has the form \cs{*a}, then \cs{rng@isStari} is \cs{@empty} +% and the argument, stripped of the \texttt{*}, is given as \cs{rng@isStarii} +% \item \cs{rng@isStariii} equals \texttt{*}, there is \texttt{*}, +% If the argument has the form \cs{a*}, then \cs{rng@isStarii} is \cs{@empty} +% and the argument, stripped of the \texttt{*}, is given as \cs{rng@isStari} +%\end{itemize} +% \begin{macrocode} +\def\rng@existStar#1{\rng@existSt@r#1**\@nil} +\def\rng@existSt@r#1*#2*#3\@nil{\def\rng@isStari{#1}% + \def\rng@isStarii{#2}\def\rng@isStariii{#3}% +} +\def\rng@NameEndpoint#1{% + \ifx\rng@isStari\@empty + \edef#1{\expandafter\noexpand\rng@isStarii}% + \else\ifx\rng@isStarii\@empty + \edef#1{\expandafter\noexpand\rng@isStari}% + \fi\fi +} +% \end{macrocode} +% \subsection{Define an Integer and a Rational} +% \begin{macro}{\defineZ} +% Define a integer for use in other macros. +% \begin{macrocode} +\newcommand\defineZ[2] +{% + \@getVarName#1\relax + \expandafter\def\csname typeof@\@varName\endcsname{0}% + \expandafter\edef\csname n@\@varName\endcsname{#2}% + \expandafter\edef\csname d@\@varName\endcsname{1}% + \edef\display@TeXfmt{#2}\edef\inline@TeXfmt{#2}% + \ifnum#2=1\relax\rng@makeOneFmtDefns + \else\ifnum#2=-1\relax\rng@makeMinusOneFmtDefns + \else\rng@makeOtherFmtDefns\fi\fi + \expandafter\let\csname\@varName*\endcsname\display@TeXfmt + \expandafter\let\csname\@varName!\endcsname\inline@TeXfmt + \expandafter\edef\csname\@varName\endcsname{#2}% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\defineQ} +% The following macro defines a rational number. Usage +% \verb+\defineQ\a{1}{2}+. This defines the rational number 1/2 and +% gives it a name, \cs{a}. +% \begin{macrocode} +\newcommand\defineQ[3] +{% + \@getVarName#1\relax + \expandafter\def\csname typeof@\@varName\endcsname{1}% + \expandafter\edef\csname n@\@varName\endcsname{#2}% + \expandafter\edef\csname d@\@varName\endcsname{#3}% + \edef\display@TeXfmt{\frac{#2}{#3}}\edef\inline@TeXfmt{#2/#3}% + \ifnum#2=#3\relax\rng@makeOneFmtDefns + \else\ifnum#2=-#3\relax\rng@makeMinusOneFmtDefns + \else\rng@makeOtherFmtDefns\fi\fi + \expandafter\let\csname\@varName*\endcsname\display@TeXfmt + \expandafter\let\csname\@varName!\endcsname\inline@TeXfmt + \expandafter\edef\csname\@varName\endcsname{#2/#3}% + \simplifyCurrentQ +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\defineR} +% This macro computes: (1) \cs{rng@intpart}; (2) \cs{rng@fracpart}; +% (3) \cs{rndnDec} (the number of decimals of the fractional part); +% (4) \cs{rndPower} (the power of ten determined by \cs{rndnDec}). +% \begin{macrocode} +\newcommand{\defineR}[2]{% + \@getVarName{#1}\RNGparseDec{#2}% + \expandafter\def\csname typeof@\@varName\endcsname{2}% + \reduceFrac{\rng@intpart\rng@fracpart}{\rndPower}% + \expandafter\edef\csname n@\@varName\endcsname{\rfNumer}% + \expandafter\edef\csname d@\@varName\endcsname{\rfDenom}% + \edef\display@TeXfmt{#2}\edef\inline@TeXfmt{#2}% + \ifnum\rfNumer=1\relax\rng@makeOneFmtDefns + \else\ifnum\rfNumer=-1\relax\rng@makeMinusOneFmtDefns + \else\rng@makeOtherFmtDefns\fi\fi + \expandafter\let\csname\@varName*\endcsname\display@TeXfmt + \expandafter\let\csname\@varName!\endcsname\inline@TeXfmt + \expandafter\edef\csname\@varName\endcsname{#2}% + \simplifyCurrentR +} +\newcommand{\simplifyCurrentR}{% + \ifnum\csname d@\@varName\endcsname=1 + \expandafter\defineZ + \csname\@varName\endcsname{\csname n@\@varName\endcsname}\fi +} +% \end{macrocode} +% \end{macro} +% \begin{macrocode} +\def\rng@makeOneFmtDefns{% +% inline + \expandafter\def\csname\@varName!e\endcsname{}% + \expandafter\def\csname\@varName!c\endcsname{}% +% display + \expandafter\def\csname\@varName*e\endcsname{}% + \expandafter\def\csname\@varName*c\endcsname{}% +} +\def\rng@makeMinusOneFmtDefns{% +% inline + \expandafter\def\csname\@varName!e\endcsname{-1}% + \expandafter\def\csname\@varName!c\endcsname{-}% +% display + \expandafter\def\csname\@varName*e\endcsname{-1}% + \expandafter\def\csname\@varName*c\endcsname{-}% +} +\def\rng@makeOtherFmtDefns{% +% inline + \expandafter\let\csname\@varName!e\endcsname\inline@TeXfmt + \expandafter\let\csname\@varName!c\endcsname\inline@TeXfmt +% display + \expandafter\let\csname\@varName*e\endcsname\display@TeXfmt + \expandafter\let\csname\@varName*c\endcsname\display@TeXfmt +} +% \end{macrocode} +% +% \subsection{Parse a Number} +% +% \subsubsection{Parsing a Rational} +% +% \begin{macro}{\RNGparseRat} +% \begin{macrocode} +\def\RNGparseRat#1{\expandafter\@chkslash#1//\@nil} +\def\@chkslash#1/#2/#3\@nil{% + \def\rng@num{#1}\def\rng@denom{#2}% + \def\rng@parseQ@iii{#3}% + \ifx\rng@denom\@empty\def\rng@denom{1}\fi +} +% \end{macrocode} +% \end{macro} +% +% \subsubsection{Parsing a Real} +% +% \begin{macro}{\RNGparseDec} +% The argument \texttt{\#1} is a decimal number (or integer) +% This macro computes: (1) \cs{rng@intpart}; (2) \cs{rng@fracpart}; +% (3) \cs{rndnDec} (the number of decimals of the fractional part); +% (4) \cs{rndPower} (the power of ten determined by \cs{rndnDec}). +% These variables will be overwritten the next time this command +% is executed. +% \begin{macrocode} +\newcommand{\RNGparseDec}[1]{\edef\parse@argi{#1}% + \expandafter\@chkdec\parse@argi..\@nil} +\def\@chkdec#1.#2.#3\@nil{% + \def\rng@intpart{#1}\def\rng@fracpart{#2}% + \def\rng@parseR@iii{#3}\rng@getnDec} +\def\rng@getnDec{% + \begingroup + \ifx\rng@fracpart\@empty\gdef\rndnDec{0}\gdef\rndPower{1}\else + \count0=0\relax\count2=1\relax + \expandafter\cntNumDec\rng@fracpart\end\fi + \endgroup} +\def\cntNumDec#1#2\end{% + \advance\count0by1 + \def\rng@arg{#2}% + \ifx\rng@arg\@empty + \xdef\rndnDec{\the\count0}% + \xdef\rndPower{1\@nameuse{rng@tz\the\count0}}% + \let\rng@next\relax + \else + \def\rng@next{\cntNumDec#2\end}% + \fi\rng@next +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\nDivisionsPowerOfTen} +% This is a control of how many nodes to create in an interval +% of real numbers, as defined by \cs{RandomR}. The argument is +% an integer between 1 and 4 inclusive. +% \begin{macrocode} +\newcommand{\nDivisionsPowerOfTen}[1]{% + \begingroup + \count0=#1\relax + \ifnum\count0>4\relax + \PackageError{rangen}{Number of subdivisions too large}% + {Reduce the argument of \string\nDivisionsPowerOfTen.}% + \else + \ifnum\count0<1\relax + \PackageError{rangen}{Number of subdivisions too large}% + {Increase the argument of \string\nDivisionsPowerOfTen.}% + \fi\fi + \xdef\RNGpowerOfTen{1\@nameuse{rng@tz#1}}% + \endgroup +} +\nDivisionsPowerOfTen{2} +% \end{macrocode} +% \end{macro} +%\subsection{Creating Random Things} +%\subsubsection{Random Integer} +% \begin{macro}{\RandomZ} +% Randomly generates an integer in the specified range of values. +%\begin{verbatim} +%[#1] Optional parameter to modify the variable. +% #2 The random variable being defined, e.g., \a +% #3 lower limit of random integer +% #4 upper limit of random integer +%\end{verbatim} +% \begin{macrocode} +\newcommand\RandomZ[4][] +{% + \def\rng@ne@values{}% + \setkeys{rangen}{ne,#1}% +% \end{macrocode} +% Now see if there is an \texttt{*}, and get un-stripped +% argument. +% +% The \cs{rng@isControl} lets \cs{rng@isC@ntrol} to 0 if the arg is undefined, +% and lets \cs{rng@isC@ntrol} to 1 if it is defined. +% Check the left endpoint: +% \begin{macrocode} + \let\rng@CtrlLEP=0\let\rng@CtrlUEP=0% + \let\rng@makeLEPStrict=0\let\rng@makeUEPStrict=0% +% \end{macrocode} +% \paragraph*{Left endpoint.} +% \begin{macrocode} + \rng@existStar{#3}\rng@NameEndpoint{\rng@LEP}% + \if\rng@isStariii*\edef\tmp@exp{% + \noexpand\rng@isControl{\expandafter\noexpand\rng@LEP}}\tmp@exp + \if\rng@isC@ntrol1% a control sequence + \let\rng@CtrlLEP=1\let\rng@makeLEPStrict=1% +% \end{macrocode} +% The LEP is a control sequence with a star, we need to increment the value +% of \cs{rng@LEP} to the next largest integer. +% \begin{macrocode} + \edef\tmp@exp{\noexpand% + \@getVarType{\expandafter\noexpand\rng@LEP}}\tmp@exp + \ifcase\varType % integer + \rng@cnta=\rng@LEP + \or % rational + \rng@dima=\expandafter\nOf\rng@LEP pt + \divide\rng@dima by\expandafter\dOf\rng@LEP + \defineR{\rng@LEP}{\strip@pt\rng@dima}% + \RNGparseDec{\rng@LEP}% + \rng@cnta=\rng@intpart + \or % real + \defineR{\rng@LEP}{\rng@LEP}% + \RNGparseDec{\rng@LEP}% + \rng@cnta=\rng@intpart + \fi + \advance\rng@cnta by1\relax + \defineZ{\rng@LEP}{\the\rng@cnta}% + \else +% \end{macrocode} +% Not a control sequence but has a star +% \begin{macrocode} + \defineZ{\rng@LEP}{\rng@LEP}% + \fi + \else +% \end{macrocode} +% No star, control sequence or not? +% \begin{macrocode} + \rng@isControl{#3}% + \if\rng@isC@ntrol1% control sequence + \let\rng@CtrlLEP=1% + \def\rng@LEP{#3}% + \@getVarType{#3}% + \ifcase\varType % integer + \defineZ{\rng@LEP}{#3}% + \or % rational + \rng@dima=\nOf{#3}pt + \divide\rng@dima by\dOf{#3}% + \defineR{\rng@LEP}{\strip@pt\rng@dima}% + \RNGparseDec{\rng@LEP}% + \defineZ{\rng@LEP}{\rng@intpart}% + \or % real + \defineR{\rng@LEP}{\rng@LEP}% + \RNGparseDec{\rng@LEP}% + \defineZ{\rng@LEP}{\rng@intpart}% + \fi + \else +% \end{macrocode} +% A number, no star +% \begin{macrocode} + \defineZ{\rng@LEP}{#3}% + \fi + \fi +% \end{macrocode} +% \paragraph*{Right endpoint.} +% \begin{macrocode} + \rng@existStar{#4}\rng@NameEndpoint{\rng@UEP}% + \if\rng@isStariii*\edef\tmp@exp{% + \noexpand\rng@isControl{\expandafter\noexpand\rng@UEP}}\tmp@exp + \if\rng@isC@ntrol1% a control sequence + \let\rng@CtrlUEP=1\let\rng@makeUEPStrict=1% +% \end{macrocode} +% The UEP is a control sequence with a star, we need to increment the value +% of \cs{rng@UEP} to the next largest integer. +% \begin{macrocode} + \edef\tmp@exp{\noexpand% + \@getVarType{\expandafter\noexpand\rng@UEP}}\tmp@exp + \ifcase\varType % integer + \rng@cnta=\rng@UEP + \or % rational + \rng@dima=\expandafter\nOf\rng@UEP pt + \divide\rng@dima by\expandafter\dOf\rng@UEP + \defineR{\rng@UEP}{\strip@pt\rng@dima}% + \RNGparseDec{\rng@UEP}% + \rng@cnta=\rng@intpart + \or % real + \defineR{\rng@UEP}{\rng@UEP}% + \RNGparseDec{\rng@UEP}% + \rng@cnta=\rng@intpart + \fi + \advance\rng@cnta by-1\relax + \defineZ{\rng@UEP}{\the\rng@cnta}% + \else +% \end{macrocode} +% Not a control sequence but has a star +% \begin{macrocode} + \defineZ{\rng@UEP}{\rng@UEP}% + \fi + \else +% \end{macrocode} +% No star, control sequence or not? +% \begin{macrocode} + \rng@isControl{#4}% + \if\rng@isC@ntrol1% control sequence + \let\rng@CtrlUEP=1% + \def\rng@UEP{#4}% + \@getVarType{#4}% + \ifcase\varType % integer + \defineZ{\rng@UEP}{#4}% + \or % rational + \rng@dima=\nOf{#4}pt + \divide\rng@dima by\dOf{#4}% + \defineR{\rng@UEP}{\strip@pt\rng@dima}% + \RNGparseDec{\rng@UEP}% + \defineZ{\rng@UEP}{\rng@intpart}% + \or % real + \defineR{\rng@UEP}{\rng@UEP}% + \RNGparseDec{\rng@UEP}% + \defineZ{\rng@UEP}{\rng@intpart}% + \fi + \else +% \end{macrocode} +% A number, no star, assume it is an integer +% \begin{macrocode} + \defineZ{\rng@UEP}{#4}% + \fi + \fi +% \end{macrocode} +% \textbf{To Do.} Check if LEP is less than UEP, if not, notify user. +% Save the random variable, e.g., \cs{a} +% \begin{macrocode} + \def\@currentName{#2}% +% \end{macrocode} +% Record the variable type +% \begin{macrocode} + \@getVarName{#2}% + \expandafter\def\csname typeof@\@varName\endcsname{0}% +% \end{macrocode} +% Save the range of this variable +% \begin{macrocode} + \expandafter\edef\csname first@\@varName\endcsname{\rng@LEP}% + \expandafter\edef\csname last@\@varName\endcsname{\rng@UEP}% +% \end{macrocode} +% Now get a value for the variable using \cs{rand}, defined in \texttt{lcg} +% \begin{macrocode} + \rng@chgrand[first=\rng@LEP,last=\rng@UEP]\rand +% \end{macrocode} +% Now define the integer. +% \begin{macrocode} + \defineZ{#2}{\arabic{rand}}% +% \end{macrocode} +% \paragraph*{Constraints} +% We have a random Z, we now try to satisfy the \texttt{ne} condition. +% +% The macro \cs{rangen@ne} can be of the form \verb!{1,3,4,5}!. We try to +% satisfy all the conditions specified by \cs{rangen@ne} +% \begin{macrocode} + \ifx\rangen@ne\@empty\else\loopCnt=0\relax +% \end{macrocode} +% We will try a total number of \cs{maxLoopLimit} to meet the required +% conditions. +% \begin{macrocode} + \@whilenum\loopCnt<\maxLoopLimit\do{% +% \end{macrocode} +% Set \cs{rng@cnta=1}, if \cs{rng@cnta} is still 1 at the end of this +% loop, the condition is satisfied. +% conditions. +% \begin{macrocode} + \rng@cnta=1\relax +% \end{macrocode} +% We use a \cs{@for} loop to run through all the NE values +% \begin{macrocode} + \@for\ne@@tmp:=\rangen@ne\do{% +% \end{macrocode} +% If the current RV is equal to the current NE value, we fail, so we +% ``and'' a zero into the \cs{rng@cnta} register. +% \begin{macrocode} + \ifnum\value{rand}=\ne@@tmp\relax + \multiply\rng@cnta0\relax + \else +% \end{macrocode} +% \dots otherwise, we ``and'' a one. +% \begin{macrocode} + \multiply\rng@cnta1\relax + \fi + }% +% \end{macrocode} +% If \cs{rng@cnt} is still equal to 1, all conditions have been met, +% in this case we set \verb!\loopCnt=\maxLoopLimit! so we can exit the outer loop. +% \begin{macrocode} + \ifnum\rng@cnta=1\relax % all conditions met + \loopCnt=\maxLoopLimit + \else % if \rng@cnta \ne 1, try again +% \end{macrocode} +% Otherwise, we increment the loop, see if we have gone the limit, if +% not, loop back with a new random choice. +% \begin{macrocode} + \advance\loopCnt1\relax + \ifnum\loopCnt=\maxLoopLimit + \PackageWarning{rangen}{Not all conditions met + after \maxLoopLimit\space tries}% + \else + \rng@chgrand[first=\rng@LEP,last=\rng@UEP]\rand + \fi + \fi + }% + \fi +% \end{macrocode} +% Whether we fail or succeed, we'll go with the last RV. Hopefully, the +% author is aware of the log file, and re-compile, possibly with a +% wider range for the variable, or with a larger value of \cs{maxLoopLimit}. +% +% \begin{macrocode} + \defineZ{#2}{\arabic{rand}}% +} +% \end{macrocode} +% \end{macro} +% \begin{macrocode} +\def\updateZ#1#2{% + \@getVarName#1\relax + \expandafter\edef\csname\@varName\endcsname{#2}% + \expandafter\edef\csname n@\@varName\endcsname{#2}% + \expandafter\edef\csname d@\@varName\endcsname{1}% +} +% \end{macrocode} +%\subsubsection{Random Rational} +% \begin{macro}{\RandomQ} +% Randomly generate a rational number. The parameters for \cs{RandomQ} are +%\begin{verbatim} +%[#1] Optional parameter to modify the variable. +% #2 The random variable being defined, e.g., \a +%[#3] maximum denominator permitted (optional) +% #4 rational number for lower endpoint of range +% #5 rational number for upper endpoint of range +%\end{verbatim} +% Here, it is assume that the first rational number is less than the second. This macro +% will randomly generate a rational number between rat1 and rat2, with a maximum denominator +% specified in \texttt{\#3}. +% +% \medskip\noindent\textbf{Note: }To allow for random endpoints, if one or both are real numbers, we convert +% them to rational numbers in \cs{@RandomQ}. +% +% We begin by getting the first two parameters: +%\begin{verbatim} +%[#1] Optional parameter to modify the variable. +% #2 The random variable being defined, e.g., \a +%\end{verbatim} +% \begin{macrocode} +\newcommand{\RandomQ}[2][] +{% + \setkeys{rangen}{ne,#1}% + \def\rq@currentName{#2}% + \@RandomQ +} +% \end{macrocode} +% We use \cs{@RandomQ} to get the last three parameters of \cs{RandomQ}. +% If the endpoints are not rational, they are converted to rationals. +%\begin{verbatim} +%[#1] maximum denominator permitted (optional) +% #2 rational number for lower endpoint of range +% #3 rational number for upper endpoint of range +%\end{verbatim} +% \begin{macrocode} +\newcommand{\@RandomQ}[3][] +{% +% \end{macrocode} +% Now see if there is an \texttt{*}, and get un-stripped +% argument. +% +% The \cs{rng@isControl} lets \cs{rng@isC@ntrol} to 0 if the arg is undefined, +% and lets \cs{rng@isC@ntrol} to 1 if it is defined. +% Check the left endpoint: +% \begin{macrocode} + \let\rng@CtrlLEP=0\let\rng@CtrlUEP=0% + \let\rng@makeLEPStrict=0\let\rng@makeUEPStrict=0% +% \end{macrocode} +% \paragraph*{Left endpoint} +% \begin{macrocode} + \rng@existStar{#2}\rng@NameEndpoint{\rng@LEP}% + \if\rng@isStariii*\edef\tmp@exp{\noexpand% + \rng@isControl{\expandafter\noexpand\rng@LEP}}\tmp@exp + \if\rng@isC@ntrol1% a control sequence + \let\rng@CtrlLEP=1\let\rng@makeLEPStrict=1% +% \end{macrocode} +% The LEP is a control sequence we get its type and convert to rational +% \begin{macrocode} + \edef\tmp@exp{\noexpand% + \@getVarType{\expandafter\noexpand\rng@LEP}}\tmp@exp + \ifcase\varType % integer + \defineQ{\rng@LEP}{\rng@LEP}{1}% + \or % rational + \edef\tmp@exp{\noexpand% + \defineQ{\noexpand\rng@LEP}{\expandafter\nOf\rng@LEP}% + {\expandafter\dOf\rng@LEP}}\tmp@exp + \or % real + \defineR{\rng@LEP}{\rng@LEP}% + \RNGparseDec{\rng@LEP}% + \defineQ{\rng@LEP}{\rng@intpart}{\rng@fracpart}% + \fi + \else +% \end{macrocode} +% Not a control sequence but has a star, a number, we assume rational +% \begin{macrocode} + \RNGparseRat{\rng@LEP}% + \defineQ{\rng@UEP}{\rng@intpart}{\rng@fracpart}% + \fi + \else +% \end{macrocode} +% No star, is it a control sequence or not? +% \begin{macrocode} + \rng@isControl{#2}% + \if\rng@isC@ntrol1% a control sequence + \@getVarType{#2}% + \ifcase\varType % integer + \defineQ{\rng@LEP}{#2}{1}% + \or % rational + \defineQ{\rng@LEP}{\nOf{#2}}{\dOf{#2}}% + \or % real + \defineR{\rng@LEP}{#2}% + \RNGparseDec{\rng@LEP}% + \defineQ{\rng@LEP}{\rng@intpart}{\rng@fracpart}% + \fi + \else % a number, required to be rational + \RNGparseRat{#2}% + \defineQ{\rng@LEP}{\rng@num}{\rng@denom}% + \fi + \fi +% \end{macrocode} +% \paragraph*{Right endpoint} +% \begin{macrocode} + \rng@existStar{#3}\rng@NameEndpoint{\rng@UEP}%% + \if\rng@isStariii*% + \edef\tmp@exp{\noexpand% + \rng@isControl{\expandafter\noexpand\rng@UEP}}\tmp@exp + \if\rng@isC@ntrol1% a control sequence + \let\rng@CtrlUEP=1\let\rng@makeUEPStrict=1% +% \end{macrocode} +% The UEP is a control sequence we get its type and convert to rational +% \begin{macrocode} + \edef\tmp@exp{\noexpand% + \@getVarType{\expandafter\noexpand\rng@UEP}}\tmp@exp + \ifcase\varType % integer + \defineQ{\rng@UEP}{\rng@UEP}{1}% + \or % rational + \edef\tmp@exp{\noexpand% + \defineQ{\noexpand\rng@UEP}{\expandafter\nOf\rng@UEP}% + {\expandafter\dOf\rng@UEP}}\tmp@exp + \or % real + \defineR{\rng@UEP}{\rng@UEP}% + \RNGparseDec{\rng@UEP}% + \defineQ{\rng@UEP}{\rng@intpart}{\rng@fracpart}% + \fi + \else +% \end{macrocode} +% Not a control sequence but has a star, a number, we assume rational +% \begin{macrocode} + \RNGparseRat{\rng@UEP}% + \defineQ{\rng@UEP}{\rng@intpart}{\rng@fracpart}% + \fi + \else +% \end{macrocode} +% No star, is it a control sequence or not? +% \begin{macrocode} + \rng@isControl{#3}% + \if\rng@isC@ntrol1% a control sequence + \@getVarType{#3}% + \ifcase\varType % integer + \defineQ{\rng@UEP}{#3}{1}% + \or % rational + \defineQ{\rng@UEP}{\nOf{#3}}{\dOf{#3}}% + \or % real + \defineR{\rng@UEP}{#3}% + \RNGparseDec{\rng@UEP}% + \defineQ{\rng@UEP}{\rng@intpart}{\rng@fracpart}% + \fi + \else % a number, required to be rational + \RNGparseRat{#3}% + \defineQ{\rng@UEP}{\rng@num}{\rng@denom}% + \fi + \fi + \@@RandomQ{#1}{\nOf{\rng@LEP}}{\dOf{\rng@LEP}}% + {\nOf{\rng@UEP}}{\dOf{\rng@UEP}}% +} +% \end{macrocode} +% Once all the parameters have been acquired, and +% any needed conversions are made, we call \cs{@@RandomQ} which +% actually generates the random rational. +%\begin{verbatim} +% #1 maximum denominator permitted +% #2 numerator of first rational +% #3 denominator of first rational +% #4 numerator of second rational +% #5 denominator of second rational +%\end{verbatim} +% \begin{macrocode} +\newcommand{\@@RandomQ}[5] +{% +% \end{macrocode} +% Now take parameters \texttt{\#2}--\texttt{\#5}, and make into two rationals +% \begin{macrocode} + \updateQ\@rqi{#2}{#3}\updateQ\@rqii{#4}{#5}% +% \end{macrocode} +% Find least common multiple between \texttt{\#3}, \texttt{\#5} and \texttt{\#1} +% \begin{macrocode} + \lcm{#3}{#5}\edef\@thelcm{\thelcm}% + \def\@maxDenom{#1}% + \ifx\@maxDenom\@empty\edef\@maxDenom{\@thelcm}\else + \lcm{\@thelcm}{#1}\edef\@thelcm{\thelcm}\fi +% \end{macrocode} +% Now convert all rationals to have a denominator of \cs{@thelcm} +% \begin{macrocode} + \convertRatTo{\nOf\@rqi}{\dOf\@rqi}{\@thelcm}% + \updateQ\@@rqi{\rng@retn@num}{\@thelcm}% + \convertRatTo{\nOf\@rqii}{\dOf\@rqii}{\@thelcm}% + \updateQ\@@rqii{\rng@retn@num}{\@thelcm}% +% \end{macrocode} +% get divisor +% \begin{macrocode} + \rng@cnta=\@thelcm \divide\rng@cnta by\@maxDenom + \edef\@divisor{\the\rng@cnta}% +% \end{macrocode} +% Round up lower limit +% \begin{macrocode} + \rng@cnta=\nOf\@@rqi + \divide\rng@cnta by\@divisor + \advance\rng@cnta by1 +% \end{macrocode} +% Round down the upper limit +% \begin{macrocode} + \rng@cntb=\nOf\@@rqii\divide\rng@cntb by\@divisor +% \end{macrocode} +% If a strict inequality is requested, we creep in a little. +% \begin{macrocode} + \if\rng@makeLEPStrict1\advance\rng@cnta1\relax\fi + \if\rng@makeUEPStrict1\advance\rng@cntb-1\relax\fi +% \end{macrocode} +% construct numerator +% \begin{macrocode} + \expandafter\@getVarName\rq@currentName + \let\save@varName\@varName + \expandafter\edef\csname first@n@\@varName\endcsname{\the\rng@cnta}% + \expandafter\edef\csname last@n@\@varName\endcsname{\the\rng@cntb}% + \expandafter\edef\csname first@d@\@varName\endcsname{\@maxDenom}% + \expandafter\edef\csname last@d@\@varName\endcsname{\@maxDenom}% + \edef\rng@LEP{\csname first@n@\@varName\endcsname}% + \edef\rng@UEP{\csname last@n@\@varName\endcsname}% +%\typeout{\@varName: first=\rng@LEP,last=\rng@UEP}% + \rng@chgrand[first=\rng@LEP,last=\rng@UEP]\rand +% \end{macrocode} +% Record the random variable name, e.g., \cs{a}, ... +% \begin{macrocode} + \let\@currentName\rq@currentName + \expandafter\@getVarName\rq@currentName + \expandafter\defineQ\@currentName{\arabic{rand}}{\@maxDenom}% + \simplifyCurrentQ + \expandafter\defineQ\@currentName{\expandafter\nOf\@currentName}% + {\expandafter\dOf\@currentName}% +% \end{macrocode} +% +% \paragraph*{Constraints} +% +% We now attempt to satisfy the NE constraints. +% \begin{macrocode} + \ifx\rangen@ne\@empty\else\loopCnt=0\relax + \@whilenum\loopCnt<\maxLoopLimit\do{% + \rng@cnta=1\relax + \@for\ne@@tmp:=\rangen@ne\do{% +% \end{macrocode} +% Define a rational by the name of \cs{cmp@Name}, then make it have +% the same denominator as \cs{@currentName}. +% \begin{macrocode} + \let\save@currentName\rq@currentName + \RNGparseRat{\ne@@tmp}% + \defineQ{\cmp@Name}{\rng@num}{\rng@denom}% + \let\@varName\save@varName + \syncronizeQs{\@varName}% + \ifnum\csname n@\@varName\endcsname=\n@cmp@Name + \multiply\rng@cnta0\relax + \else + \multiply\rng@cnta1\relax + \fi + }% + \ifnum\rng@cnta=1\relax % all conditions met + \loopCnt=\maxLoopLimit + \else % if \rng@cnta \ne 1, try again + \advance\loopCnt1\relax + \ifnum\loopCnt=\maxLoopLimit + \PackageWarning{rangen}{Not all conditions met + after \maxLoopLimit\space tries}% + \else + \rng@chgrand[first=\rng@LEP,last=\rng@UEP]\rand + \expandafter\@getVarName\rq@currentName + \expandafter\defineQ\@currentName{\arabic{rand}}% + {\@maxDenom}% + \fi + \fi + }% + \fi + \simplifyCurrentQ + \expandafter\defineQ\@currentName{\expandafter\nOf\@currentName}% + {\expandafter\dOf\@currentName}% +% \end{macrocode} +% If the denominator is equal to 1, let's change the data type to an integer. +% \begin{macrocode} + \let\@currentName\rq@currentName + \expandafter\@getVarName\rq@currentName + \ifnum\csname d@\@varName\endcsname=1\relax\expandafter + \defineZ\@currentName{\expandafter\nOf\@currentName}% + \fi + \simplifyCurrentQ +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\updateQ} +% Updates the value of a rational number, its numerator and denominator +% without changing any of the format macros. +% \begin{macrocode} +\newcommand\updateQ[3] +{% + \@getVarName#1\relax + \expandafter\edef\csname\@varName\endcsname{#2/#3}% + \expandafter\edef\csname n@\@varName\endcsname{#2}% + \expandafter\edef\csname d@\@varName\endcsname{#3}% +} +% \end{macrocode} +% \end{macro} +% A macro for performing routine adjustments on a rational number. +% \begin{macrocode} +\def\simplifyCurrentQ +{% +% \end{macrocode} +% Reduce fraction: Reduce the fraction to its lowest terms. +% \begin{macrocode} + \reduceFrac{\csname n@\@varName\endcsname}% + {\csname d@\@varName\endcsname}% +% \end{macrocode} +% \cs{reduceFrac} returns results in \cs{@tempcnta} and \cs{@tempcntb}, now +% update the numerator and denominator +% \begin{macrocode} + \expandafter\edef\csname n@\@varName\endcsname{\rfNumer}% + \expandafter\edef\csname d@\@varName\endcsname{\rfDenom}% +% \end{macrocode} +% If the numerator is zero, then zero out \cs{@varName} and special format +% \begin{macrocode} + \ifnum\csname n@\@varName\endcsname=0 + \expandafter\edef\csname\@varName\endcsname{0}% + \edef\display@TeXfmt{0}\edef\inline@TeXfmt{0}% + \else +% \end{macrocode} +% If numerator equals denominator, just replace by 1 +% \begin{macrocode} + \ifnum\csname n@\@varName\endcsname=\csname d@\@varName\endcsname + \expandafter\defineZ\csname\@varName\endcsname{1}% + \else +% \end{macrocode} +% If numerator equals -denominator, just replace by -1 +% \begin{macrocode} + \ifnum\csname n@\@varName\endcsname + =-\csname d@\@varName\endcsname + \expandafter\defineZ\csname\@varName\endcsname{-1}% + \else +% \end{macrocode} +% If denominator equals 1, modify value; otherwise, ok. +% \begin{macrocode} + \ifnum\csname d@\@varName\endcsname=1 + \expandafter\defineZ\csname\@varName\endcsname + {\csname n@\@varName\endcsname}% + \else + \expandafter\edef\csname \@varName\endcsname{% + \csname n@\@varName\endcsname/% + \csname d@\@varName\endcsname}% + \edef\display@TeXfmt{% + \frac{\csname n@\@varName\endcsname} + {\csname d@\@varName\endcsname}}% + \edef\inline@TeXfmt{% + \csname n@\@varName\endcsname/% + \csname d@\@varName\endcsname}% + \expandafter\let + \csname\@varName*\endcsname\display@TeXfmt + \fi + \fi + \fi + \fi +} +% \end{macrocode} +% \begin{macro}{\nOf} +% \begin{macro}{\dOf} +% \begin{macro}{\iOf} +% \begin{macro}{\typeOf} +% User access to numerator and denominator of random variables. +% \begin{macrocode} +\newcommand\nOf[1]{\csname n@\expandafter\@gobble\string#1\endcsname} +\newcommand\dOf[1]{\csname d@\expandafter\@gobble\string#1\endcsname} +% \end{macrocode} +% For a variable created by \cs{RandomL}, the index of the number chosen (1-based) +% can be accessed through the \cs{iOf} command. +% \begin{macrocode} +\newcommand{\iOf}[1]{\csname i@\expandafter\@gobble\string#1\endcsname} +% \end{macrocode} +% Get the type of a RV, \cs{ifnum}\cs{typeOf}\cs{a}=0 (integer), 1 (rational), 2 (real), +% 3 (literal, created by \cs{RandomP}). +% \begin{macrocode} +\newcommand\typeOf[1]{% + \csname typeof@\expandafter\@gobble\string#1\endcsname} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +%\subsubsection{Random Real} +% +% We attempt to generate a random real number, in a given interval of real numbers. +% +% The following are some data and switches used by \cs{RandomReal}. +% \begin{macrocode} +\newif\iftrailingzeros\trailingzerosfalse +\@namedef{rng@tz1}{0} +\@namedef{rng@tz2}{00} +\@namedef{rng@tz3}{000} +\@namedef{rng@tz4}{0000} +\@namedef{rng@tz5}{00000} +\@namedef{rng@tz6}{000000} +\@namedef{rng@tz7}{0000000} +\@namedef{rng@tz8}{00000000} +\def\rng@true{true}\def\rng@false{false} +\newdimen\rng@dima +\newdimen\rng@dimb +\newdimen\rng@dimc +% \end{macrocode} +% \begin{macro}{\RandomR} +% Create a real number at random within the given interval. For example, +%\begin{verbatim} +% \RandomR[]{\a}{3.45}{6.45} +%\end{verbatim} +% \begin{macro}{round} +% \begin{macro}{showzeros} +% The key-value pairs recognized by \cs{RandomZ|Q|R}. +% \begin{macrocode} +\define@key{rangen}{ne}[]{\edef\rangen@ne{#1}} +\define@key{rangen}{round}[]{\def\rangen@round{#1}} +\define@key{rangen}{showzeros}[]{\def\rangen@showzeros{#1}% + \ifx\rangen@showzeros\@empty\global\trailingzerostrue\else + \ifx\rangen@showzeros\rng@true\global\trailingzerostrue\else + \global\trailingzerosfalse\fi\fi} +\define@key{rangen}{index}[]{\edef\rangen@index{#1}} +% \end{macrocode} +% \end{macro} +% \end{macro} +%\begin{verbatim} +%[#1] = options +% #2 = name of real to correct +% #3 = lower endpoint of interval +% #4 = upper endpoint of interval +%\end{verbatim} +% \begin{macrocode} +\newcommand{\RandomR}[4][]{% + \setkeys{rangen}{ne,round,showzeros=false,#1}% +% \end{macrocode} +% Now see if there is an \texttt{*}, and get un-stripped +% argument. +% +% The \cs{rng@isControl} lets \cs{rng@isC@ntrol} to 0 if the arg is undefined, +% and lets \cs{rng@isC@ntrol} to 1 if it is defined. +% Check the left endpoint: +% \begin{macrocode} + \let\rng@CtrlLEP=0\let\rng@CtrlUEP=0% + \let\rng@makeLEPStrict=0\let\rng@makeUEPStrict=0% + \def\rng@lcg@first{0}\edef\rng@lcg@last{\RNGpowerOfTen}% +% \end{macrocode} +% \paragraph{Left endpoint.} Check the left endpoint: +% \begin{macrocode} + \rng@existStar{#3}\rng@NameEndpoint{\rng@LEP}% + \if\rng@isStariii*\edef\tmp@exp{\noexpand% + \rng@isControl{\expandafter\noexpand\rng@LEP}}\tmp@exp + \if\rng@isC@ntrol1% a control sequence + \let\rng@CtrlLEP=1\let\rng@makeLEPStrict=1% + \def\rng@lcg@first{1}% +% \end{macrocode} +% The LEP is a control sequence with a star. Convert LEP to a real +% number as needed. +% \begin{macrocode} + \edef\tmp@exp{\noexpand% + \@getVarType{\expandafter\noexpand\rng@LEP}}\tmp@exp + \ifcase\varType % integer + \defineR{\rng@LEP}{\rng@LEP\RNG@Dec}% + \or % rational + \rng@dima=\expandafter\nOf\rng@LEP pt + \divide\rng@dima by\expandafter\dOf\rng@LEP + \defineR{\rng@LEP}{\strip@pt\rng@dima}% + \or % real + \defineR{\rng@LEP}{\rng@LEP}% + \fi +% \end{macrocode} +% Not a control sequence, but has a star +% \begin{macrocode} + \else + \defineR{\rng@LEP}{\rng@LEP}% + \fi + \else +% \end{macrocode} +% No star, control sequence or not? +% \begin{macrocode} + \rng@isControl{#3}% + \if\rng@isC@ntrol1% control sequence + \let\rng@CtrlLEP=1\def\rng@LEP{#3}% + \@getVarType{#3}% + \ifcase\varType % integer + \defineR{\rng@LEP}{\rng@LEP\RNG@Dec}% + \or % rational + \rng@dima=\nOf{#3}pt + \divide\rng@dima by\dOf{#3}% + \defineR{\rng@LEP}{\strip@pt\rng@dima}% + \or % real + \defineR{\rng@LEP}{\rng@LEP}% + \fi + \else +% \end{macrocode} +% A number, no star, number is required to be real +% \begin{macrocode} + \defineR{\rng@LEP}{#3}% + \fi + \fi +% \end{macrocode} +% \paragraph{Right endpoint.} Check the right endpoint: +% \begin{macrocode} + \rng@existStar{#4}\rng@NameEndpoint{\rng@UEP}% + \if\rng@isStariii*\edef\tmp@exp{\noexpand% + \rng@isControl{\expandafter\noexpand\rng@UEP}}\tmp@exp + \if\rng@isC@ntrol1% a control sequence + \let\rng@CtrlUEP=1\let\rng@makeUEPStrict=1% + \rng@cnta=\rng@lcg@last\advance\rng@cnta-1\relax + \edef\rng@lcg@last{\the\rng@cnta}% +% \end{macrocode} +% The UEP is a control sequence with a star. Convert UEP to a real +% number as needed. +% \begin{macrocode} + \edef\tmp@exp{\noexpand% + \@getVarType{\expandafter\noexpand\rng@UEP}}\tmp@exp + \ifcase\varType % integer + \defineR{\rng@UEP}{\rng@UEP\RNG@Dec}% + \or % rational + \rng@dima=\expandafter\nOf\rng@UEP pt + \divide\rng@dima by\expandafter\dOf\rng@UEP + \defineR{\rng@UEP}{\strip@pt\rng@dima}% + \or % real + \defineR{\rng@UEP}{\rng@UEP}% + \fi +% \end{macrocode} +% Not a control sequence, but has a star +% \begin{macrocode} + \else + \defineR{\rng@UEP}{\rng@UEP}% + \fi + \else +% \end{macrocode} +% No star, control sequence or not? +% \begin{macrocode} + \rng@isControl{#4}% + \if\rng@isC@ntrol1% control sequence + \let\rng@CtrlUEP=1\def\rng@UEP{#4}% + \@getVarType{#4}% + \ifcase\varType % integer + \defineR{\rng@UEP}{\rng@UEP\RNG@Dec}% + \or % rational + \rng@dima=\nOf{#4}pt + \divide\rng@dima by\dOf{#4}% + \defineR{\rng@UEP}{\strip@pt\rng@dima}% + \or % real + \defineR{\rng@UEP}{\rng@UEP}% + \fi + \else +% \end{macrocode} +% A number, no star, number is required to be real +% \begin{macrocode} + \defineR{\rng@UEP}{#4}% + \fi + \fi +% \end{macrocode} +% Prepare to generate the random real +% \begin{macrocode} + \def\@currentName{#2}\@getVarName{#2}% +% \end{macrocode} +% Save upper and lower endpoints where they are expected to be. +% \begin{macrocode} + \expandafter\edef\csname first@\@varName\endcsname{\rng@LEP}% + \expandafter\edef\csname last@\@varName\endcsname{\rng@UEP}% +% \end{macrocode} +% Get a random real, and declare it to be a real number using \cs{defineR}. +% \begin{macrocode} + \rng@getRandomR + \defineR{#2}{\strip@pt\rng@dima}% +% \end{macrocode} +% Round and remove trailing zeros. +% \begin{macrocode} + \ifx\rangen@round\@empty\else + \RNGround{#2}{#2}{\rangen@round}% + \rng@dima=#2pt\relax + \defineR{#2}{\strip@pt\rng@dima}% + \fi +% \end{macrocode} +% \paragraph{Constraints.} Let's try to apply constraints. We only allow one constraint. +% \begin{macrocode} + \ifx\rangen@ne\@empty\else\loopCnt=0\relax + \@whilenum\loopCnt<\maxLoopLimit\do{% + \rng@cnta=1\relax + \@for\ne@@tmp:=\rangen@ne\do{% + \rng@dima=#2pt + \ifdim\rng@dima=\ne@@tmp pt\relax + \multiply\rng@cnta0\relax\else + \multiply\rng@cnta1\relax\fi + }% + \ifnum\rng@cnta=1\relax % all conditions met + \loopCnt=\maxLoopLimit + \else % if \rng@cnta \ne 1, try again + \advance\loopCnt1\relax + \ifnum\loopCnt=\maxLoopLimit + \PackageWarning{rangen}{Not all conditions met + after \maxLoopLimit\space tries}% + \else + \rng@getRandomR + \defineR{#2}{\strip@pt\rng@dima}% +% \end{macrocode} +% Round and remove trailing zeros. +% \begin{macrocode} + \ifx\rangen@round\@empty\else + \RNGround{#2}{#2}{\rangen@round}% + \rng@dima=#2pt\relax + \defineR{#2}{\strip@pt\rng@dima}% + \fi + \fi + \fi + }% + \fi +% \end{macrocode} +% \paragraph{Formatting.} Begin formatting of the real, keys recognized are +% \texttt{round} and \texttt{showzeros}. +% \begin{macrocode} + \rnd@ProcessRealFormat{#2}% +% \end{macrocode} +% We declare our number. +% \begin{macrocode} + \def\@currentName{#2}% + \defineR{#2}{#2}% +} +% \end{macrocode} +% Get a new random real and return it in the \cs{rng@dima} +% \begin{macrocode} +\def\rng@getRandomR{% +% \end{macrocode} +% Put the endpoints in dimension registers so we can subtract them. +% \begin{macrocode} + \rng@dima=\rng@LEP pt + \rng@dimb=\rng@UEP pt +% \end{macrocode} +% Compute the difference between upper and lower, then strip off the \texttt{pt}, +% to make it a decimal number. +% \begin{macrocode} + \advance\rng@dimb-\rng@dima +% \edef\r@getDiff{\strip@pt\rng@dimb}% +% \end{macrocode} +% Get a random integer from the interval 0 to \cs{RNGpowerOfTen}. +% the default value of the latter command is 100, and it can be changed +% using \cs{nDivisionsPowerOfTen}. The idea is to divide the interval +% from the lower bound to the upper bound into \cs{RNGpowerOfTen} nodes, +% and we choose one of these nodes are random. +% +% If the endpoints where strict, then we changed \cs{rng@lcg@first} +% from 0 to 1 (if the lower endpoint is strict); and changed +% \cs{rng@lcg@last} from \cs{RNGpowerOfTen} to \texttt{\string\RNGpowerOfTen-1} +% (if the upper end point is strict). +% \begin{macrocode} + \rng@chgrand[first=\rng@lcg@first,last=\rng@lcg@last]\rand +% \end{macrocode} +% Divide the length of the interval by \cs{RNGpowerOfTen}, +% and store the result in \cs{rng@dimb}, then multiply +% that by \verb!\arabic{rand}!. +% \begin{macrocode} + \divide\rng@dimb by\RNGpowerOfTen\relax + \rng@dimb=\arabic{rand}\rng@dimb +% \end{macrocode} +% Finally, the left-end point is still in \cs{rng@dima} +% we add the result in \cs{rng@dimb} to \cs{rng@dima} +% to compute our random rational. +% \begin{macrocode} + \advance\rng@dima by\rng@dimb +} +\def\rnd@ProcessRealFormat#1{% + \ifx\rangen@round\@empty + \rng@dima=#1pt\relax + \defineR{#1}{\strip@pt\rng@dima}% + \else + \RNGround{#1}{#1}{\rangen@round}% + \rng@dima=#1pt\relax + \defineR{#1}{\strip@pt\rng@dima}% + \iftrailingzeros + {\RNGparseDec{#1}\count0=\decPls\relax + \advance\count0-\rndnDec\relax + \ifnum\count0>0\relax\xdef#1{% + \rng@intpart\RNG@Dec\rng@fracpart% +\@nameuse{rng@tz\the\count0}}% + \fi}% + \defineR{#1}{#1}% + \fi + \fi +} +% \end{macrocode} +% \end{macro} +% +% \subsubsection{Random Sign} +% \begin{macro}{\RandomS} +% We randomly generate a \texttt{+} or \texttt{-} sign +% for addition and subtraction. The first optional argument +% is a rational number between 0 and 1. The default is \texttt{1/2}. +% This number represents the probably of a \texttt{+} sign. +% \begin{macrocode} +\newcommand{\RandomS}[2][1/2]{% + \RNGparseRat{#1}% + \ifnum\rng@num<0\relax + \PackageError{rangen}{A positive numerator is required}% + {The rational number must be between 0 and 1}\fi + \ifnum\rng@denom<0\relax + \PackageError{rangen}{A positive denominator is required}% + {The rational number must be between 0 and 1}\fi + \ifnum\rng@num>\rng@denom\relax + \PackageError{rangen}{The rational must be between 0 and 1}% + {The rational number must be between 0 and 1}\fi + \rng@chgrand[first=1,last=\rng@denom]\rand + \@getVarName{#2}% + \ifnum\value{rand}>\rng@num\relax\def#2{-}% + \rng@makeMinusOneFmtDefns + \def\display@TeXfmt{-}\def\inline@TeXfmt{-}% + \else\def#2{+}\rng@makeOneFmtDefns + \def\display@TeXfmt{}\def\inline@TeXfmt{}\fi + \expandafter\let\csname\@varName*\endcsname\display@TeXfmt + \expandafter\let\csname\@varName!\endcsname\inline@TeXfmt +} +% \end{macrocode} +% \end{macro} +% +% \subsubsection{Random Number from a List} +% +% \begin{macro}{\RandomL} +% Select a number of any type from a comma-delimited list. +%\begin{verbatim} +% \RandomL[key-values]{\RV}{} +%\end{verbatim} +% Currently, the only key recognized is the \texttt{index} key. +% If the \texttt{index} key is specified, the number whose index is specified +% is retrieved from the list. +% \begin{macrocode} +\newcommand{\RandomL}[3][]{% + \let\rangen@index\@empty + \setkeys{rangen}{#1}% + \rng@cnta=0\relax\@for\@@tmp:=#3\do{% + \advance\rng@cnta1\relax}\edef\n@rng@listItems{\the\rng@cnta}% + \ifx\rangen@index\@empty + \rng@chgrand[first=1,last=\n@rng@listItems]\rand + \else + \rng@cnta=\rangen@index + \advance\rng@cnta-1\relax + \amodb{\rng@cnta}{\n@rng@listItems}% + \rng@cnta=\retnmod + \advance\rng@cnta1\relax + \value{rand}=\rng@cnta + \fi + \@getVarName{#2}% + \expandafter\edef\csname i@\@varName\endcsname{\arabic{rand}}% + \rng@cnta=0\relax\@for\@@tmp:=#3\do{% + \advance\rng@cnta1\relax\ifnum\rng@cnta=\arabic{rand}% + \edef\rng@choice{\@@tmp}\fi}% + \def\@currentName{#2}% +% \end{macrocode} +% Now, determine the type of this choice, and make appropriate +% data type definition. +% \begin{macrocode} + \RNGparseDec{\rng@choice}% + \if\rng@parseR@iii\RNG@Dec\defineR{#2}{\rng@choice}% + \else\RNGparseRat{\rng@choice}% + \if\rng@parseQ@iii/\defineQ{#2}{\rng@num}{\rng@denom}% + \else\defineZ{#2}{\rng@choice}\fi\fi +} +% \end{macrocode} +% \end{macro} + +% \subsubsection{Random Problem from a List} +% +% \begin{macro}{\RandomP} +% Select a literal from a comma-delimited list of literals. +%\begin{verbatim} +% \RandomP[key-values]{\RV}{} +%\end{verbatim} +% Currently, the only key recognized is the \texttt{index} key. +% If the \texttt{index} key is specified, the number whose index is specified +% is retrieved from the list. +% \begin{macrocode} +\newcommand{\RandomP}[3][]{% + \let\rangen@index\@empty + \setkeys{rangen}{#1}% + \rng@cnta=0\relax\@for\@@tmp:=#3\do{% + \advance\rng@cnta1\relax}\edef\n@rng@listItems{\the\rng@cnta}% + \ifx\rangen@index\@empty + \rng@chgrand[first=1,last=\n@rng@listItems]\rand + \else + \rng@cnta=\rangen@index + \advance\rng@cnta-1\relax + \amodb{\rng@cnta}{\n@rng@listItems}% + \rng@cnta=\retnmod + \advance\rng@cnta1\relax + \value{rand}=\rng@cnta + \fi + \@getVarName{#2}% + \expandafter\edef\csname i@\@varName\endcsname{\arabic{rand}}% + \rng@cnta=0\relax\@for\@@tmp:=#3\do{% + \advance\rng@cnta1\relax\ifnum\rng@cnta=\arabic{rand}% + \rng@toks=\expandafter{\@@tmp}\edef#2{\the\rng@toks}% + \expandafter\def\csname typeof@\@varName\endcsname{3}\fi}% +} +% \end{macrocode} +% \end{macro} +% +% \subsubsection{Random Index} +% +% \begin{macro}{\RandomI} +% This command creates an implied list of \verb!{1, 2, 3,...,n}!, +% and randomly selects a number from this list. The result is +% defined as an integer, and held in the macro \texttt{\#1}. +%\begin{verbatim} +% \Random{\i}{n} --> select \i from {1, 2, 3,...,n} at random +%\end{verbatim} +%A random index, \cs{i}, created by \cs{RandomI}, can be used +%in the \cs{RandomL} command; for example, +%\begin{verbatim} +% \RandomL[index=\i]{\a}{17,\rPI,3/4,\rE,88,1/2} +%\end{verbatim} +%The value of \cs{a} is determined by the index \cs{i}. +% \begin{macrocode} +\newcommand{\RandomI}[2]{% + \rng@chgrand[first=1,last=#2]\rand + \defineZ{#1}{\arabic{rand}}% + \expandafter\edef\csname i@\@varName\endcsname{\arabic{rand}}% +} +% \end{macrocode} +% \end{macro} +% +% \subsection{Some Constants} +% +% \begin{macro}{\zZero} +% \begin{macro}{\zOne} +% \begin{macro}{\zMinusOne} +% \begin{macro}{\rPI} +% \begin{macro}{\rE} +% Define three convenience integers corresponding to $0$, $1$, and $-1$. +% \begin{macrocode} +\defineZ{\zZero}{0} +\defineZ{\zOne}{1} +\defineZ{\zMinusOne}{-1} +\defineR{\rPI}{3.1415927} +\defineR{\rE}{2.7182818} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% This macro takes \cs{@varName} and \cs{cmp@Name} and converts to the same common +% denominator. This makes it easy to make comparisons between two rational numbers. +% \begin{macrocode} +\def\syncronizeQs#1{\edef\sync@arg{#1}% + \lcm{\csname d@\sync@arg\endcsname}{\d@cmp@Name}% + \edef\@thelcm{\thelcm}% + \convertRatTo{\n@cmp@Name}{\d@cmp@Name}{\@thelcm}% + \updateQ\cmp@Name{\rng@retn@num}{\@thelcm}% + \convertRatTo{\csname n@\sync@arg\endcsname}% + {\csname d@\sync@arg\endcsname}{\@thelcm}\expandafter + \defineQ\csname\sync@arg\endcsname{\rng@retn@num}{\@thelcm}% +} +% \end{macrocode} +% \subsection{Formatting Commands} +% \begin{macro}{\ds} +% \begin{macro}{\eds} +% \begin{macro}{\cds} +% Displays an alternate representation (\textbf display\textbf style) of the random variable. Usage \cs{ds}\cs{a}. +% This displays the contents of \cs{display@TeXfmt} for this variable. The value of \cs{display@TeXfmt} +% is effected by the formatting commands above. +% +% For a rational number \cs{a}, the expression \cs{ds}\cs{a} expands either to the special format representation, or +% to a rational of the form $\frac{p}{q}$. +% \begin{macrocode} +\newcommand\ds[1]{% + \expandafter\csname\expandafter\@gobble\string#1*\endcsname +} +\newcommand\eds[1]{% + \expandafter\csname\expandafter\@gobble\string#1*e\endcsname +} +\newcommand\cds[1]{% + \expandafter\csname\expandafter\@gobble\string#1*c\endcsname +} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \begin{macro}{\fmt} +% \begin{macro}{\efmt} +% \begin{macro}{\cfmt} +% Displays a special format for the random variable. Usage \cs{ds}\cs{a}. +% This displays the contents of \cs{display@TeXfmt} for this variable. +% Same as \cs{ds}, but does not display a display style if there is not +% special formatting. +% +% For a rational number \cs{a}, the expression \cs{ds}\cs{a} expands either to the special format representation, or +% to a rational of the form $p/q$. +% \begin{macrocode} +\newcommand\fmt[1]{% + \expandafter\csname\expandafter\@gobble\string#1!\endcsname +} +\newcommand\efmt[1]{% + \expandafter\csname\expandafter\@gobble\string#1!e\endcsname +} +\newcommand\cfmt[1]{% + \expandafter\csname\expandafter\@gobble\string#1!c\endcsname +} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \begin{macro}{\js} +% Used within \cs{CorrAnsButton} to get a more precise expansion of a variable. Used with variables +% that have been defined using \cs{defineDepVar}. When you say \verb+\js\m+, for example, +% the \cs{eval@JSfmt} is expanded. +% \par\medskip\noindent +% \textbf{Usage:} \verb+\CorrAnsButton*{y = \js\m\space x }+ +% \begin{macrocode} +\newcommand\js[1]{% + \expandafter\csname\expandafter\@gobble\string#1!*\endcsname +} +% \end{macrocode} +% \end{macro} +% +% \subsection{Commands specialized to Reals} + +% \begin{macro}{\RNGround} +% Round \texttt{\#1} to \texttt{\#3} decimal places, and leave result in \texttt{\#2}. +% \begin{macrocode} +\def\RNGround#1#2#3{% + \begingroup + \def\rng@ctrlName{#1}% + \def\rng@sourceName{#2}% + \def\rng@nDecPl{#3}% + \RNGparseDec{#2}% + \ifnum\rndnDec<#3\relax + \xdef\theseDigits{\rng@fracpart}% + \let\rng@next\relax + \else + \count0=0\relax + \gdef\theseDigits{}% + \def\rng@next{\expandafter\@rng@round\rng@fracpart\end}% + \fi + \rng@next + \xdef\decPls{\@ifundefined{save@rng@nDecPl}% + {\rng@nDecPl}{\save@rng@nDecPl}}% + \ifx\theseDigits\@empty + \xdef#1{\rng@intpart}\else + \xdef#1{\rng@intpart\RNG@Dec\theseDigits}\fi + \endgroup +} +\def\@rng@round#1{% + \ifx#1\end\let\rng@next\relax + \else + \ifnum\rng@nDecPl=0\relax + \ifnum#1>4\relax + \count0=\rng@intpart\relax + \ifnum\rng@intpart<0\relax + \advance\count0by-1\relax + \else + \advance\count0by1\relax + \fi + \xdef\rng@intpart{\the\count0}% + \fi + \gdef\theseDigits{}% + \let\rng@next\rng@gobbletoend + \else + \advance\count0by1\relax + \ifnum\count0=\rng@nDecPl\relax + \def\rng@next{\@@rng@round#1}% + \else + \xdef\theseDigits{\theseDigits#1}% + \let\rng@next\@rng@round + \fi + \fi + \fi + \rng@next +} +\def\rng@gobbletoend#1\end{} +\def\@@rng@round#1#2{% + \ifx#2\end% + \xdef\theseDigits{\theseDigits#1}% + \let\rng@next\relax + \else + \ifnum#2>4\relax\count2=#1\relax + \ifnum\count2=9\relax + \count0=\rng@nDecPl\relax + \ifnum\count0=1\relax + \count0=\rng@intpart\relax + \ifnum\rng@intpart<0\relax + \advance\count0by-1\relax + \else + \advance\count0by1\relax + \fi + \xdef\rng@intpart{\the\count0}% + \let\rng@next\rng@gobbletoend + \else + \advance\count0by-1\relax\expandafter + \xdef\rng@sourceName{% + \rng@intpart\RNG@Dec\theseDigits#1}% + \edef\save@rng@nDecPl{\rng@nDecPl}% + \edef\rng@next{\noexpand\RNGround{% + \expandafter\noexpand\rng@ctrlName}% + {\expandafter\noexpand\rng@sourceName}% + {\the\count0}\noexpand\rng@gobbletoend}% + \fi + \else + \advance\count2by1\relax + \xdef\theseDigits{\theseDigits\the\count2}% + \let\rng@next\rng@gobbletoend + \fi + \else % \ifnum#2<=4 + \xdef\theseDigits{\theseDigits#1}% + \let\rng@next\rng@gobbletoend + \fi + \fi + \rng@next +} +% \end{macrocode} +% \end{macro} +% Used with \cs{CorrAnsButton} and \texttt{rngCorrAnsButton}, like so, +%\begin{verbatim} +% \CorrAnsButton{rEval(\strAns)}*{rngCorrAnsButton\RNGprintf{\%.2f}} +%\end{verbatim} +% \begin{macrocode} +\def\RNGprintf#1{("#1",\@gobble} +% \end{macrocode} +% +% \subsection{User Defined Dependent Variables for JavaScript} +% \begin{macro}{\defineDepQJS} +% Define a rational as a function of other integers. This macro defines +% \cs{fmt} and \cs{ds} for the variable, but its primary use it +% for \cs{js}. This command is aimed at the JavaScript side of things +%\begin{verbatim} +%#1 = name of rational to be defined, e.g., \a +%#2 = numerator +%#3 = denominator +%#4 = \js expression for #1 +%\end{verbatim} +% Usage: +%\begin{verbatim} +% \defineDepQJS{\m}{\d-\b}{\c-\a} +% {rFrac(rEval(\nOf\m)/rEval(\dOf\m))} +% ... +% \CorrAnsButton{y = \js\m\space x}*{rngCorrAnsButton}% +%\end{verbatim} +% The above example would calculate equation of the line passing through +% the two points \verb!P(\a,\b)! and \verb!Q(\c,\d)!. The code is used +% in the \cs{CorrAnsButton} to have the answer appear. +% \begin{macrocode} +\newcommand\defineDepQJS[4]{% + \@getVarName#1 + \expandafter\edef\csname\@varName\endcsname{(#2)/(#3)}% + \expandafter\edef\csname n@\@varName\endcsname{(#2)}% + \expandafter\edef\csname d@\@varName\endcsname{(#3)}% + \edef\display@TeXfmt{\csname\@varName\endcsname}% + \edef\inline@TeXfmt{\csname\@varName\endcsname}% + \def\dv@argiv{#4}\ifx\dv@argiv\@empty + \edef\eval@JSfmt{\csname\@varName\endcsname}\else + \edef\eval@JSfmt{#4}\fi + \expandafter\let\csname\@varName!*\endcsname\eval@JSfmt +} +% \end{macrocode} +% \end{macro} +% +% \subsection{Writing RVs to Solution Files} +% \begin{macrocode} +\def\rng@writeCurrentSeed#1{\immediate\write#1{\string\makeatletter + \string\global\string\cr@nd=\the\cr@nd\string\relax + \string\makeatother}} +% \end{macrocode} +% Token register to hold the verbatim contents of the \texttt{writeRVsTo} environment. +% \begin{macrocode} +\newtoks\rng@toks +\def\wrv@ex@solns{exercises}% +\def\wrv@ex@quiz{quizzes}% +% \end{macrocode} +% \begin{environment}{writeRVsTo} +% This environment takes its environment contents and writes it to +% two files, one file is \cs{jobname\_rvs.cut} which is input back +% into the source file immediately. The second parameter +% accepts the string \texttt{exercises} or \texttt{quizzes}, or a write +% handle to write to an auxiliary file. The environment was designed for +% use with the \texttt{exercise}, \texttt{quiz}, and \texttt{shortquiz} environments +% of \textsf{exerquiz}. +% \begin{macrocode} +\newenvironment{writeRVsTo}[2][] +{% + \def\wrv@argii{#2}% + \ifx\wrv@argii\wrv@ex@quiz\let\wrv@out\quiz@solns + \else\ifx\wrv@argii\wrv@ex@solns\let\wrv@out\ex@solns\else + \let\wrv@out#2\fi\fi + \rng@writeCurrentSeed\wrv@out + \rng@toks={}% + \def\verbatim@processline{% + \xdef\rng@temp{\the\rng@toks\the\verbatim@line}% + \global\rng@toks=\expandafter{\rng@temp}}% + \let\do\@makeother\dospecials\catcode`\^^M\active + #1% + \verbatim@start +}{ \immediate\write\wrv@out{\the\rng@toks}% + \newwrite\rng@writeRVs + \immediate\openout\rng@writeRVs\jobname_rvs.cut + \immediate\write\rng@writeRVs{\the\rng@toks}% + \immediate\closeout\rng@writeRVs + \aftergroup\rng@Input@RVs +} +% \end{macrocode} +% \end{environment} +% After the \texttt{writeRVsTo} environment writes the RVs to +% \cs{jobname\_rvs.cut}. The environment executes +% \cs{rng@Input@RVs} to input the file back into the source file. +% \begin{macrocode} +\def\rng@Input@RVs{\InputIfFileExists{\jobname_rvs.cut}{}{}} +% \end{macrocode} +% \subsection{Redefine lcg Package Macro} +% \begin{macrocode} +\def\rng@p@stkeysr@nd{% + \@rderr@nd% last < first -> swap + \cutr@nger@nd% range too big -> cut +} % end of \def\p@stkeysr@nd +\def\rng@chgrand{\@ifnextchar[\rng@chgr@nd{\rng@chgr@nd[]}} +\def\rng@chgr@nd[#1]{% + \@tempcnta=\z@ + \@tempcntb=\z@ + \setkeys{Init}{#1}% + \rng@p@stkeysr@nd% + \@utputr@nd% +} % end of \def\rng@chgrand +% \end{macrocode} +% \subsection{DLJS Support} +% \begin{macrocode} +\begin{insDLJS}[partialExpand]{partial}{Rangen} +var partre = /rEval|rFrac/; +% \end{macrocode} +% The arguments for this function take two forms +% (1) \texttt{fieldname}, \texttt{theanswer} (the default); (2) +% \texttt{theformat}, \texttt{fieldname}, \texttt{theanswer}. The later case +% is created by using the \cs{RNGprintf} command that inserts allows the +% document author to insert a \texttt{printf} formatting template. For example, +%\begin{verbatim} +% \CorrAnsButton{rEval(\strAns)}*{rngCorrAnsButton\RNGprintf{\%.4f}} +%\end{verbatim} +% \begin{macrocode} +function rngCorrAnsButton() +{ + var theprecision,fieldname,theanswer; + if (arguments.length==4) { + var theformat=arguments[0]; + var fieldname=arguments[1]; + var theanswer=arguments[2]; + var thequiz=arguments[3]; + } else { + var fieldname=arguments[0]; + var theanswer=arguments[1]; + var thequiz=arguments[2]; + } + theanswer = partialExpand(0,theanswer); + if (arguments.length==4) + theanswer=util.printf(theformat,eval(theanswer)); + DisplayAnswer(fieldname,theanswer,thequiz); +} +% \end{macrocode} +% The JavaScript function \texttt{partialExpand} searches through \texttt{Ans} in search of +% \texttt{rEval} and \texttt{rFrac}. It calls itself recursively to search for the inner most +% appearances of these two functions. It evaluates these two functions starting with the inner +% most and working its way outward. +% \begin{macrocode} +function partialExpand(level,Ans) +{ + Ans = correctPlusMinus(Ans) + level += 1; +\db console.println("Enter level = " + level +": Ans: " + Ans);\db% + var n=0, m, bP, eP, subExp; + while ( true ) { +\db console.println("Searching a level " + level);\db% + try { m = Ans.match(partre); } + catch (e) { break; } + if ( m != null ) { + bP = m.index + m[0].length; + eP = FindBalP(Ans, bP, true); +\db console.println("bP = " + bP + " : eP = " + eP);\db% + var subExp = Ans.substring(bP+1, eP); +\db console.println("Found \'" + subExp% + + "\' at level = " + level);\db% +% subExp = partialExpand(level, subExp); + // n = beginning of "rEval", + // eP = beginning of balanced parens, + // bP = end of balanced parens + Ans = Ans.substring(0, m.index) + + eval(m[0]+"(level,subExp)") + Ans.substring(eP+1); +\db console.println("level = " + level% + +": New Ans: " + Ans);\db % + } else { + if ( level == 1 ) { +\db console.println("Level 1 break");\db % + break; + } + } + } +\db console.println("Return Ans: " + Ans);\db% + Ans = correctPlusMinus(Ans); + return Ans; +} +% \end{macrocode} +% Evaluates the value of \texttt{Ans}. +% \begin{macrocode} +function rEval(level, Ans) +{ + level += 1; +\db console.println("Enter rEval: level = "% + + level +": Ans: " + Ans);\db% + var n=0, m, bP, eP, subExp; + while ( true ) + { +\db console.println("Searching a level " + level);\db% + try { m = Ans.match(partre); } + catch (e) { break; } + if ( m != null ) { + bP = m.index + m[0].length; + eP = FindBalP(Ans, bP, true); +\db console.println("bP = " + bP + " : eP = " + eP);\db% + var subExp = Ans.substring(bP+1, eP); +\db console.println("Found \'" + subExp% + + "\' at level = " + level);\db% + // n = beginning of "rEval", + // eP = beginning of balanced parens, + // bP = end of balanced parens + Ans = Ans.substring(0, m.index) + +eval(m[0]+"(level,subExp)")+Ans.substring(eP+1); +\db console.println("level = "% + + level +": New Ans: " + Ans);\db % + } else { + Ans = ParseInput(Ans); +\db console.println("Ready to eval at level = "% + + level + ": Ans = " + Ans);\db% + with(Math) { Ans = eval( Ans ) }; +\db console.println("After eval at level = "% + + level + ": Ans = " + Ans);\db% + break; + } + } +\db console.println("Return Ans: " + Ans);\db% + return Ans; +} +% \end{macrocode} +% Evaluates an rational number by evaluating the value of the numerator and denominator separately. +% \begin{macrocode} +function rFrac(level, Ans) +{ + level += 1; +\db console.println("Enter rFrac level = "% + + level +": Ans: " + Ans);\db% + var n=0, m, bP, eP, subExp; + while ( true ) { +\db console.println("Searching a level " + level);\db% + try { m = Ans.match(partre); } + catch (e) { break; } + if ( m != null ) { + bP = m.index + m[0].length; + eP = FindBalP(Ans, bP, true); +\db console.println("bP = "% + + bP + " : eP = " + eP);\db% + var subExp = Ans.substring(bP+1, eP); +\db console.println("Found \'" + subExp% + + "\' at level = " + level);\db% + // n = beginning of "rEval", + // eP = beginning of balanced parens, + // bP = end of balanced parens + Ans = Ans.substring(0, m.index) + + eval(m[0]+"(level,subExp)") + Ans.substring(eP+1); +\db console.println("level = " + level% + +": New Ans: " + Ans);\db % + } else { + var numDenom = Ans.split("/"); + numDenom[0] = eval(numDenom[0]); + numDenom[1] = eval(numDenom[1]); + var g = gcd(numDenom[0], numDenom[1]); + numDenom[0] /= g; + numDenom[1] /= g; + if ( numDenom[1] == 1) + Ans = numDenom[0]; + else + Ans = numDenom.join("/"); +\db console.println("Reduce: " + numDenom.join("/"));\db% + break; + } + } +\db console.println("Return Ans: " + Ans);\db% + return Ans; +} +function correctPlusMinus(Ans) +{ + Ans = "" + Ans; + Ans = Ans.replace(/\s*([\+-])\s*\1\s*/g, " + "); + Ans = Ans.replace(/\s*\+\s*-\s*/g, " - "); +% Ans = Ans.replace(/\s*\+\s*\+\s*/g, " + "); +% Ans = Ans.replace(/\s*-\s*-\s*/g, " + "); + Ans = Ans.replace(/\s*-\s*\+\s*/g, " - "); + return Ans; +} +function gcd(a,b) +{ + var x = a, y = b, r; + while (true) + { + r = x \% y; + if ( r == 0 ) break; + x = y; + y = r; + } + return Math.abs(y); +} +function lcm (a,b) { return (a*b)/gcd(a,b); } +\end{insDLJS} +% +% \end{macrocode} +\endinput diff --git a/texmf-dist/source/latex/rangen/rangen.ins b/texmf-dist/source/latex/rangen/rangen.ins new file mode 100644 index 00000000..c9335e7f --- /dev/null +++ b/texmf-dist/source/latex/rangen/rangen.ins @@ -0,0 +1,64 @@ +%% +%% This file will generate fast loadable files and documentation +%% driver files from the doc files in this package when run through +%% LaTeX or TeX. +%% +%% Copyright 1999-2002 D. P. Story +%% +%% This file is part of the `Web and Exerquiz Distribution'. +%% ------------------------------------------- +%% +%% It may be distributed under the conditions of the LaTeX Project Public +%% License, either version 1.2 of this license or (at your option) any +%% later version. The latest version of this license is in +%% http://www.latex-project.org/lppl.txt +%% and version 1.2 or later is part of all distributions of LaTeX +%% version 1999/12/01 or later. +%% +%% --------------- start of docstrip commands ------------------ +%% +\def\filedate{2001/05/26} +\def\batchfile{rangen.ins} +% +% If you can assume that the target audience for the document all have +% Acrobat Reader 5.0 or later, then chance the following switch to true, +% else, leave it as false. + +\input docstrip +\ifx\generate\undefined + \Msg{**********************************************} + \Msg{*} + \Msg{* This installation requires docstrip} + \Msg{* version 2.4 or later.} + \Msg{*} + \Msg{* An older version of docstrip has been input} + \Msg{*} + \Msg{**********************************************} + \errhelp{Move or rename old docstrip.tex and get a newer one.} + \errmessage{Old docstrip in input path} + \batchmode + \csname @@end\endcsname\end +\fi + +\keepsilent +\askforoverwritefalse +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\preamble +\endpreamble + +\generate +{% + \file{rangen.sty}{\from{rangen.dtx}{copyright,package}} +} + +\Msg{***************************************************************} +\Msg{*} +\Msg{* \space To finish the installation you have to copy the files } +\Msg{*} +\Msg{* \space *.sty, *.cfg and *.def into a directory searched by TeX} +\Msg{*} +\Msg{***************************************************************} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\endinput diff --git a/texmf-dist/source/latex/renditions/renditions.dtx b/texmf-dist/source/latex/renditions/renditions.dtx new file mode 100644 index 00000000..e5ec3639 --- /dev/null +++ b/texmf-dist/source/latex/renditions/renditions.dtx @@ -0,0 +1,214 @@ +%\iffalse +%<*copyright> +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Renditions.sty package, 2010-1-29 %% +%% Copyright (C) 1999-2002 D. P. Story %% +%% dpstory@uakron.edu %% +%% %% +%% This program can redistributed and/or modified under %% +%% the terms of the LaTeX Project Public License %% +%% Distributed from CTAN archives in directory %% +%% macros/latex/base/lppl.txt; either version 1 of the %% +%% License, or (at your option) any later version. %% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% +%% History: Noel Vaillant began developing a better renditions.sty +%% based on my earlier published renditions.sty. Many thanks +%% to him for starting me off. +%%--------------------------------------------------------- +% +%\NeedsTeXFormat{LaTeX2e}[1997/12/01] +%\ProvidesPackage{rendition} +% [2010/01/29 v0.1 rendition: Package for creating multiple renditions from the same source (dps)] +%<*driver> +\documentclass{ltxdoc} +\usepackage{amsmath} +\usepackage[colorlinks,hyperindex]{hyperref} +\usepackage{calc} +%\pdfstringdefDisableCommands{\let\\\textbackslash} +%\EnableCrossrefs \CodelineIndex +\begin{document} +\def\CMD#1{\textbackslash#1} + \GetFileInfo{renditions.sty} + \title{The \textsf{rendition} Package\texorpdfstring{\\[1ex]}{: }Creating multiple renditions (versions)\texorpdfstring{\\[1ex]}{} + from the same source file} + \author{D. P. Story\\ + Email: \texttt{dpstory@uakron.edu}} + \date{processed \today} + \maketitle + \tableofcontents + \let\Email\texttt + \DocInput{renditions.dtx} + \PrintIndex +\end{document} +% +% \fi +% \MakeShortVerb{|} +% \StopEventually{} +% +% \DoNotIndex{\def,\edef,\gdef,\xdef,\global,\long,\let} +% \DoNotIndex{\expandafter,\string,\the,\ifx,\else,\fi} +% \DoNotIndex{\csname,\endcsname,\relax,\begingroup,\endgroup} +% \DoNotIndex{\DeclareTextCommand,\DeclareTextCompositeCommand} +% \DoNotIndex{\space,\@empty,\special} +% +% \begin{macrocode} +%<*package> +% \end{macrocode} +% \section{The \textsf{renditions} Package} +% This is a short package sets up comment environments, called \emph{renditions}. These +% renditions can be included or excluded according to the value of the +% \texttt{rendition} option. The basic options of this package are \texttt{max} and \texttt{rendition} +%\begin{verbatim} +% \usepackage[max=4,rendition=3]{renditions} +%\end{verbatim} +% In the above example, \texttt{max=4} declares that there are 4 renditions in the +% document, the option \texttt{rendition=3} causes the package to include +% \texttt{rendition3}, and to exclude all the others \texttt{rendition1}, \texttt{rendition2}, and \texttt{rendition4}. +% +%The \textsf{renditions} package is a stand-alone package, but it was designed for use with the \textsf{AeB Builder} utility. +% +%Below is an example of a document that uses the \textsf{renditions} package. +% +%\bigskip\noindent\begin{minipage}[t]{.4\linewidth-5pt} +%\begin{verbatim} +%\documentclass{article} +%\usepackage[% +% max=4, +% rendition=3 +%]{renditions} +%\end{verbatim} +%\verb!%\rendition{2}! +%\begin{verbatim} +%\parindent0pt\parskip6pt +% +%\begin{document} +%This is a test file for +%renditions. +% +%\begin{rendition1} +%Rendition 1 +%\end{rendition1} +% +%\begin{rendition2} +%Rendition 2 +%\end{rendition2} +% +%\begin{rendition3} +%Rendition 3 +%\end{rendition3} +% +%\begin{rendition4} +%Rendition 4 +%\end{rendition4} +% +%\end{document} +%\end{verbatim} +%\end{minipage}\hfill +%\begin{minipage}[t]{.6\linewidth-5pt}\parskip\medskipamount +%There are two options for the \textsf{renditions} package: \texttt{max} and \texttt{rendition}. The value of \texttt{max} sets the maximum number of renditions in the document; the value of the \texttt{rendition} key determines which of the renditions is to be typeset. You can also select the rendition using the \cs{rendition} command, as illustrated to the left. (The \cs{rendition} command in the preamble would override the value of the \texttt{rendition} key.) +% +%The various renditions are defined with the \texttt{rendition} environment. +%These environments are just comment environments created by the \textsf{comments} %package, and they are selectively included or excluded depending on the value of %the rendition defined by either the \texttt{rendition} key or the \cs{rendition} command. +% +%The \textsf{rendition} package does modular arithmetic in the case when $\text{rendition} > %\text{max}$. For example, if \texttt{max=4}, and \texttt{rendition=6}, then the rendition %displayed is \texttt{rendition=2}. +% +%There is a third way of setting the value of the rendition parameter, and that is %through the \texttt{rendition.cfg} file. If you create a file with the code +%\begin{verbatim} +% \ExecuteOptionsX{rendition=3} +%\end{verbatim} +%Then \texttt{rendition=3} is used. +%\end{minipage} +% +%\paragraph*{Default values.}The default value of \texttt{max}, if it is not specified is %3, and the default value of \texttt{rendition} if it is not specified is 1. +% +% There should not be a \texttt{rendition} environment with a number, \texttt{}, greater than that specified by \texttt{max}; however, +% if the value of \texttt{rendition} is greater than \texttt{max}, modular arithmetic +% is performed, and the rendition numbered \texttt{rendition} Mod \texttt{max} is used. +% +%\paragraph*{History.} The core of this package was originally developed +% for my online testing system TAOAS (The {Acro\negthinspace\TeX} Online +% Assessment System). In that system, the \texttt{rendition.cfg} approach was used +% to select a rendition to be used. +% +%\section{The Main Code} +% We use xkeyval to create the two options \texttt{max} and \texttt{rendition}. +% \begin{macrocode} +\RequirePackage{xkeyval} +% \end{macrocode} +% \begin{macro}{max} +% The maximum number of renditions present in this file. The value of max +% must be a positive integer, no checking takes place. The default number is +% 3. +% \begin{macro}{rendition} +% The number of the rendition what you want to use for this run of the latex +% compiler. The default number is 1. +% \begin{macrocode} +\DeclareOptionX{max}{\def\ren@numberOf{#1}} +\def\ren@numberOf{3} +\DeclareOptionX{rendition}{\def\thisrendition{#1}} +\def\thisrendition{1} +% \end{macrocode} +% \end{macro} +% \end{macro} +% Input the configuration file, if it exists. This file normally contains +% the line of {\LaTeX} code \verb!\ExecuteOptions{rendition=}! +% \begin{macrocode} +\InputIfFileExists{rendition.cfg}{}{} +% \end{macrocode} +% Process the options. +% \begin{macrocode} +\ProcessOptionsX +% \end{macrocode} +% The comment package is required. +% \begin{macrocode} +\RequirePackage{comment} +% \end{macrocode} +% Based on the value of \texttt{max}, we create the requested number +% of rendition environments: \texttt{rendition1}, \texttt{rendition2},\dots, +% \texttt{rendition}. +% \begin{macrocode} +\let\save@message\message\let\message\@gobble +\@tempcnta=0 +\@whilenum\@tempcnta<\ren@numberOf\do{% + \@tempcntb=\@tempcnta\advance\@tempcntb1 + \edef\temp@exp{\noexpand\excludecomment{rendition\the\@tempcntb}}% + \temp@exp + \expandafter\let\csname Afterver\the\@tempcntb Comment\endcsname\relax + \advance\@tempcnta1 +}\let\message\save@message +% \end{macrocode} +% We include the selected version at the beginning of the document. +% \begin{macrocode} +\AtBeginDocument{\includecomment{rendition\thisrendition}} +% \end{macrocode} +% \begin{macro}{\rendition} +% A convenience macro for setting the current renditions. This +% command defines the command \cs{thisrendition}, which expands +% to the selected rendition number. If the value of \cs{thisredition} +% is greater than \texttt{max} (\cs{ren@numberOf}), modular arithmetic +% is performed, and \cs{thisrendition} is redefined. +% \begin{macrocode} +\def\rendition#1{\def\thisrendition{#1}% + \ifnum\thisrendition>\ren@numberOf + \@tempcnta=\thisrendition + \@tempcntb=\@tempcnta + \advance\@tempcnta-1 \divide\@tempcnta\ren@numberOf + \multiply\@tempcnta\ren@numberOf + \advance\@tempcntb-\@tempcnta + \edef\thisrendition{\the\@tempcntb}% + \typeout{Modular arithmetic applied: ren=\thisrendition}% + \fi +} +\@onlypreamble{\rendition} +% \end{macrocode} +% We execute \cs{rendition} for the selected rendition. +% \begin{macrocode} +\expandafter\rendition\expandafter{\thisrendition} +% \end{macrocode} +% \end{macro} +% \begin{macrocode} +% +% \end{macrocode} +% \Finale +\endinput \ No newline at end of file diff --git a/texmf-dist/source/latex/renditions/renditions.ins b/texmf-dist/source/latex/renditions/renditions.ins new file mode 100644 index 00000000..65cdc4b5 --- /dev/null +++ b/texmf-dist/source/latex/renditions/renditions.ins @@ -0,0 +1,59 @@ +%% +%% This file will generate fast loadable files and documentation +%% driver files from the doc files in this package when run through +%% LaTeX or TeX. +%% +%% Copyright 2010 D. P. Story +%% +%% ------------------------------------------- +%% +%% It may be distributed under the conditions of the LaTeX Project Public +%% License, either version 1.2 of this license or (at your option) any +%% later version. The latest version of this license is in +%% http://www.latex-project.org/lppl.txt +%% and version 1.2 or later is part of all distributions of LaTeX +%% version 1999/12/01 or later. +%% +%% --------------- start of docstrip commands ------------------ +%% +\def\filedate{2010/02/01} +\def\batchfile{renditions.ins} + +\input docstrip +\ifx\generate\undefined + \Msg{**********************************************} + \Msg{*} + \Msg{* This installation requires docstrip} + \Msg{* version 2.4 or later.} + \Msg{*} + \Msg{* An older version of docstrip has been input} + \Msg{*} + \Msg{**********************************************} + \errhelp{Move or rename old docstrip.tex and get a newer one.} + \errmessage{Old docstrip in input path} + \batchmode + \csname @@end\endcsname\end +\fi + +\keepsilent +\askforoverwritefalse +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\preamble +\endpreamble + +\generate +{% + \file{renditions.sty}{\from{renditions.dtx}{copyright,package}} +} + +\Msg{***************************************************************} +\Msg{*} +\Msg{* \space To finish the installation you have to copy the files } +\Msg{*} +\Msg{* \space *.sty, *.cfg and *.def into a directory searched by TeX} +\Msg{*} +\Msg{***************************************************************} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\endinput diff --git a/texmf-dist/source/latex/renditions/test_ren.tex b/texmf-dist/source/latex/renditions/test_ren.tex new file mode 100644 index 00000000..169af9e8 --- /dev/null +++ b/texmf-dist/source/latex/renditions/test_ren.tex @@ -0,0 +1,27 @@ +\documentclass{article} +\usepackage[max=4, rendition=2]{renditions} + +%\rendition{3} + +\parindent0pt\parskip6pt + +\begin{document} +This is a test file for renditions. + +\begin{rendition1} +Rendition 1 +\end{rendition1} + +\begin{rendition2} +Rendition 2 +\end{rendition2} + +\begin{rendition3} +Rendition 3 +\end{rendition3} + +\begin{rendition4} +Rendition 4 +\end{rendition4} + +\end{document} \ No newline at end of file diff --git a/texmf-dist/source/latex/richtext/doc/richtextman.tex b/texmf-dist/source/latex/richtext/doc/richtextman.tex new file mode 100644 index 00000000..7526f9ad --- /dev/null +++ b/texmf-dist/source/latex/richtext/doc/richtextman.tex @@ -0,0 +1,1106 @@ +% makeindex < aebpro_man.idx > aebpro_man.ind +\documentclass[12pt]{article} +\usepackage[fleqn]{amsmath} +\usepackage[ + web={centertitlepage,designv,forcolorpaper,latextoc,pro,addtoHyOpts={pagebackref=false}}, + eforms, +% linktoattachments, + aebxmp +]{aeb_pro} +\usepackage{richtext} +\usepackage{graphicx,array} +%\usepackage{myriadpro} +%\usepackage{calibri} +\usepackage[altbullet]{lucidbry} + +%\previewtrue +%\usepackage{makeidx} +%\makeindex +\usepackage{acroman} +\usepackage[active]{srcltx} + +\setcounter{secnumdepth}{4} +\setcounter{tocdepth}{5} +\makeatletter +\renewcommand*{\theparagraph}{\texorpdfstring{\protect\P\protect\ }{\textparagraph}} +\renewcommand{\paragraph} + {\renewcommand{\@seccntformat}[1]{\theparagraph}% + \@startsection{paragraph}{4}{0pt}{6pt}{-3pt}{\color{\aeb@subsubsectioncolor}\bfseries}} +\renewcommand*\l@paragraph{\@dottedtocline{4}{5.0em}{1em}} %{7.0em}{4.1em}} +\def\chgCurrLblName#1{\def\@currentlabelname{#1}} +\def\echgCurrLblName#1{\edef\@currentlabelname{#1}} +\makeatother + +\getDimsFromGraphic{graphics/dpsweb}{\dpswebW}{\dpswebH} + + +%\urlstyle{rm} +\urlstyle{sf} +\let\uif\textsf +\let\app\textsf +\def\psf#1{\textbf{\textsf{#1}}} +\let\amtIndent\leftmargini + +\convertcolorspec{named}{red}{RGB}{\rgbRed} +\convertcolorspec{named}{blue}{RGB}{\rgbBlue} +\convertcolorspec{named}{red}{HTML}{\htmlRed} +\convertcolorspec{named}{blue}{HTML}{\htmlBlue} +\convertcolorspec{named}{magenta}{RGB}{\rgbMagenta} +\convertcolorspec{named}{magenta}{HTML}{\htmlMagenta} +\convertcolorspec{named}{webbrown}{HTML}{\htmlWebBrown} + +\renewcommand*\descriptionlabel[1]{\hspace\labelsep + \normalfont #1} + + +\DeclareDocInfo +{ + university={Acro\negthinspace\TeX.Net}, + title={\textsf{richtext}: A method of creating rich text strings}, + author={D. P. Story}, + email={dpstory@acrotex.net}, + subject={Documentation for the richtext package from AcroTeX}, + talksite={\url{www.acrotex.net}}, + version={v1.0c, 2016/10/03}, + keywords={AcroTeX, rich text strings}, + copyrightStatus=True, + copyrightNotice={Copyright (C) \the\year, D. P. Story}, + copyrightInfoURL={http://www.acrotex.net} +} + +\def\dps{$\hbox{$\mathfrak D$\kern-.3em\hbox{$\mathfrak P$}% + \kern-.6em \hbox{$\mathcal S$}}$} + +\universityLayout{fontsize=Large} +\titleLayout{fontsize=LARGE} +\authorLayout{fontsize=Large} +\tocLayout{fontsize=Large,color=aeb} +\sectionLayout{indent=-62.5pt,fontsize=large,color=aeb} +\subsectionLayout{indent=-31.25pt,color=aeb} +\subsubsectionLayout{indent=0pt,color=aeb} +\subsubDefaultDing{\texorpdfstring{$\bullet$}{\textrm\textbullet}} + +\widestNumber{0.00.} +%\pagestyle{empty} +%\parindent0pt\parskip\medskipamount + +\def\dps{$\mbox{$\mathfrak D$\kern-.3em\mbox{$\mathfrak P$}% + \kern-.6em \hbox{$\mathcal S$}}$} + +\newcount\fldCnt \fldCnt=0 +\def\incFldCnt{\global\advance\fldCnt1\relax} + +\frenchspacing + +\chngDocObjectTo{\newDO}{doc} +\begin{docassembly} +var titleOfManual="The AeB RichText MANUAL"; +var manualfilename="Manual_BG_Print_richtext.pdf"; +var manualtemplate="Manual_BG_Brown.pdf"; // Blue, Green, Brown +var _pathToBlank="C:/Users/Public/Documents/ManualBGs/"+manualtemplate; +var doc; +var buildIt=false; +if ( buildIt ) { + console.println("Creating new " + manualfilename + " file."); + doc = \appopenDoc({cPath: _pathToBlank, bHidden: true}); + var _path=this.path; + var pos=_path.lastIndexOf("/"); + _path=_path.substring(0,pos)+"/"+manualfilename; + \docSaveAs\newDO ({ cPath: _path }); + doc.closeDoc(); + doc = \appopenDoc({cPath: manualfilename, oDoc:this, bHidden: true}); + f=doc.getField("ManualTitle"); + f.value=titleOfManual; + doc.flattenPages(); + \docSaveAs\newDO({ cPath: manualfilename }); + doc.closeDoc(); +} else { + console.println("Using the current "+manualfilename+" file."); +} +var _path=this.path; +var pos=_path.lastIndexOf("/"); +_path=_path.substring(0,pos)+"/"+manualfilename; +\addWatermarkFromFile({ + bOnTop:false, + bOnPrint:false, + cDIPath:_path +}); +\executeSave(); +\end{docassembly} + +\begin{document} + +\maketitle + +\selectColors{linkColor=black} +\tableofcontents +\selectColors{linkColor=webgreen} + +\def\AcroT{Acro\!\TeX}\def\cAcroT{\textcolor{blue}{\AcroT}} +\def\AcroEB{\AcroT{} eDucation Bundle}\def\cAcroEB{\textcolor{blue}{\AcroEB}} +\def\AcroB{\AcroT{} Bundle}\def\cAcroB{\textcolor{blue}{\AcroB}} +\def\bUrl{http://www.math.uakron.edu/~dpstory} + +\hypersetup{linktocpage} + + +%FreeText +%/C[1.0 1.0 1.0]/Contents(This is test If there a real test, we would all be in trouble.) +%/CreationDate(D:20160909063701-05'00') +%/DA(0.898 0.1333 0.2157 rg /Helv 12 Tf) +%/DS(font: Helvetica,sans-serif 12.0pt; text-align:left; color:#E52237 ) +%/F 4/M(D:20160909065147-05'00')/NM(f8e9e6b1-1651-4c47-9169-8a47c7af23ff) +%/RC( +%

+% +% This is +% +% test +% +%If there a real test, we would all be in trouble. +%

)/Rect[30.1092 174.763 181.964 251.345]/Subj(Text Box)/Subtype/FreeText/T(dpstory)/Type/Annot>> + + +\section{Introduction} + +Rich text contents for variable text (text fields and editable combo boxes) +and markup annotations was introduced into the PDF specification beginning +with PDF 1.5 (\app{Acrobat} and \app{Adobe Reader} version~6). The rich text +strings are difficult to create for it requires reading from a number of +sources. The \pkg{richtext} package provides commands and documentation +needed to ``easily'' produce such rich strings. We demonstrate the results +using the \pkg{eforms} package (the text field produced by \pkg{hyperref} +does not support rich text). + +References for this material includes the \textsl{PDF +Reference}~\cite{book:pdfspec}, the XFA specification~\cite{webpage:XFASpec}, +and the CSS2 specification~\cite{webpage:CSS2}. Additionally, the \textsl{JavaScript for +Acrobat API Reference}~\cite{tech:AcroJS} covers the JavaScript API for +handling rich text content. + +\section{Preamble: Required packages and options} + +The package has no options and only requires \pkg{xkeyval} and \pkg{ifxetex} packages. +The package can produce rich text strings, but to actually use them, you'll need +the \pkg{eforms} package. + +The package works for all drivers \app{dvips}, \app{pdflatex}, \app{xelatex}, +and \app{luatex}. The \pkg{eforms} package can automatically detect all +drivers except \pkg{dvips}, and that is used by default. + +\section{Creating rich text strings}\label{s:CreateRTS} + +We begin by illustrating the result of the \pkg{richtext} package, consider the rich text field below. + +\rtpara[indent=first]{para1}{Now is the time for +\span{style={bold,italic,strikeit},color=ff0000}{J\374rgen} and all +good men to come to the aid of \it{their} \bf{country}. Now is the time for +\span{style=italic}{all good} women to do the same.} +\rtpara[indent=first]{para2}{With rich text, we can format the text within +the text field. As a reader of this rich text field, you can edit the +contents of the box, feel free to do so.} +\rtpara[halign=right]{para3}{D. P. Story \span{url=http://www.acrotex.net}{AcroTeX.Net}} + +\setRVVContent{myContent}{{para1}{para2}{skipline}{para3}} + +\begin{center} +%\previewtrue +\incFldCnt +\textField[\Ff{\FfRichText}\Ff{\FfMultiline} +\DS{\useDefaultDS}%\DS{\useDS{myDS}}% +\RV{\useRVContent{myContent}}\V{\useVContent{myContent}}]{rtFld\the\fldCnt}{4in}{10\baselineskip} +\end{center} + +To edit the field above, click in the field, press \uif{Ctrl+E} or \uif{Cmd+E} (for \app{Mac OS}) to obtain +the \uif{Form Field Text Properties} toolbar. By pressing the \uif{More} button, you can see the additional +properties of the field, as seen in \hyperref[fig:FPtabs]{Figure~\ref*{fig:FPtabs}}. + + +A rich text may have any of several style attributes, many of these are illustrated in the above example. +As a guide to introducing the attributes, we follow the \uif{Form Field Text Properties} dialog box shown +in \hyperref[fig:FPtabs]{Figure~\ref*{fig:FPtabs}}. + +\begin{figure}[htb]\centering\setlength{\fboxsep}{0pt}% +\fbox{\parbox{.5\linewidth-5pt-2\fboxrule}{\includegraphics[width=\linewidth]{graphics/fontprops}}}\hspace{10pt}% +\fbox{\parbox{.5\linewidth-5pt-2\fboxrule}{\includegraphics[width=\linewidth]{graphics/paragraphprops}}}\\[6pt] +\fbox{\parbox{.8\linewidth-2\fboxrule}{\includegraphics[width=\linewidth]{graphics/linkprops}}}% +\caption{The Font, Paragraph and Link tabs}\label{fig:FPtabs} +\end{figure} + +\newtopic\noindent +The basic command for creating a rich text \emph{paragraph} is \cs{rtpara}: +\bVerb\takeMeasure{\string\rtpara[\ameta{Para-Font-attrs}]\darg{\ameta{name}}\darg{\ameta{rich-text-paragraph}}}% +\begin{dCmd}[commandchars=!()]{\bxSize} +\rtpara[!ameta(Para-Font-attrs)]{!ameta(name)}{!ameta(rich-text-paragraph)} +\end{dCmd} +\eVerb where \ameta{Para-Font-attrs} are key-value pairs (in the {\LaTeX} +sense) that are described in \hyperref[s:FLtabs]{Sections~\ref*{s:FLtabs}} +and~\ref{s:Paratab}; these attributes are applied to the paragraph as a +whole. The \ameta{name} is a unique name to be associated with +\ameta{rich-text-paragraph} so it can be referenced later from within a text +field. There are two types of attributes: \uif{Font} and \uif{Paragraph}, as +guided by \hyperref[fig:FPtabs]{Figure~\ref*{fig:FPtabs}}. For convenience, +the \uif{Link} attributes (URLs) are classified as \uif{Font}. The optional +argument of \cs{rtpara} consists of usually \uif{Paragraph} attributes, most +\uif{Font} attributes are also recognized. + +The definition of the first paragraph of the above rich text field reads as +follows: +\begin{Verbatim}[fontsize=\small] +\rtpara[indent=first]{para1}{Now is the time for + \span{style={bold,italic,strikeit},color=ff0000}{J\374rgen} + and all good men to come to the aid of \it{their} + \bf{country}. Now is the time for \span{style=italic} + {all good} women to do the same.} +\end{Verbatim} +In this example, the optional argument for \cs{rtpara} was used to indent the +paragraph. The rich text defined here is named \texttt{para1}. The third +argument, \ameta{rich-text-string}, consists of ordinary text, the \cs{span} +command used to insert special formatting for text, and certain other +`short-cut' markups like \cs{it} and \cs{bf}. Note that the umluat (\"{u}) is +expressed as octal (\cs{374}). + +The \cs{span} command is used to format individual sentence fragments. Its +syntax is, +\bVerb\takeMeasure{\string\span\darg{\ameta{Font-attrs}}\darg{\ameta{rich-text-string}}}% +\begin{dCmd}[commandchars=!()]{\bxSize} +\span[!ameta(Font-attrs)]{!ameta(rich-text-string)} +\end{dCmd} +\eVerb where \ameta{Font-attrs} are \uif{Font} attributes as described in +\hyperref[s:FLtabs]{Sections~\ref*{s:FLtabs}}; these attributes are applied +to the string \ameta{rich-text-string} only. The \cs{span} command, as +described here, is only defined within the third argument +(\ameta{rich-text-paragraph}) of \cs{rtpara}. This is necessary because +\cs{span} is a {\TeX} primitive command, and we must not overwrite its +definition. + +When you create a \emph{rich text string} there is a parallel development of a +\emph{plain text string}, the string without its rich text markup, these two +(rich and plain strings) are used to populate the values of the \psf{RV} and +\psf{V} keys of a text field. When you define a rich text paragraph string +under its own \ameta{name}, you can typeset it (to check the syntax) and its +plain text counterpart using the \cs{useRV\darg{\ameta{name}}} and +\cs{useV\darg{\ameta{name}}} commands. For example, +\begin{quote}\raggedright\ttfamily\makeatletter\def\rt@SC{;\penalty0}% +\rtpara[indent=first]{para1}{Now is the time for +\span{style={bold,italic,strikeit},color=ff0000}{J\string\374rgen} and all +good men to come to the aid of \it{their} \bf{country}. Now is the time for +\span{style=italic}{all good} women to do the same.} +\makeatother +\hspace*{-\leftmargini}\textbf{\cs{useRV\darg{para1}:}}\ \useRV{para1}\\[\baselineskip] +\hspace*{-\leftmargini}\textbf{\cs{useV\darg{para1}:}}\ \useV{para1} +\end{quote} +These commands may also be used to insert the strings into the \psf{RV} and +\psf{V} keys, respectively; though the \pkg{richtext} package offers an +alternative technique. + +\subsection{The \texorpdfstring{\uif{Font}}{Font} and +\texorpdfstring{\uif{Link}}{Link} tabs}\label{s:FLtabs} + +In this section, we cover the \uif{Font} and \uif{Link} tabs, as well as other attributes +not listed on any tab. + +\subsubsection{The \texorpdfstring{\uif{Font}}{Font} tab} + +We discuss the \uif{Font} tab of \hyperref[fig:FPtabs]{Figure~\ref*{fig:FPtabs}}. The +key-value for each of the attributes is given and described briefly. These key-values +may appear as \ameta{Font-attrs} or \ameta{Para-Font-attrs}. +\begin{description} +%The font family used to draw the text. It is an array of family names to be searched for in order. The first +%entry in the array is the font name of the font to use. The second entry is an optional generic family name +%to use if an exact match of the first font is not found. The generic family names are +%symbol, serif, sans-serif, cursive, monospace, fantasy +%The default generic family name is sans-serif. +\item[\uif{Font:}] \texttt{font=\ameta{font\_name}} A font name or a list of + font names to be used to display the enclosed text. The first + entry is the font name of the font to use. The second font name is + typically a generic family name to use if an exact match is not found. + The generic family names are \texttt{symbol}, \texttt{serif}, + \texttt{sans-serif}, \texttt{cursive}, \texttt{monospace}, and + \texttt{fantasy}. The default is \texttt{sans-serif}. If a typeface name + contains white space, enclose it within single quotes (\texttt{'}). +\begin{flushleft}\small %\previewtrue +\verb|\rtpara[font={Arial,sans-serif}]{para1}{This is Arial or a| +\hspace*{20pt}\verb|san-serif substitute.}|\\[3pt] +\rtpara[font={Arial,sans-serif}]{para1}{This is Arial or a san-serif substitute.}% +\incFldCnt\textField[\Ff{\FfRichText}%\Ff{\FfMultiline} +\DS{\useDefaultDS}\RV{\useRV{para1}}\V{\useV{para1}}]{rtFld\the\fldCnt}{3in}{16bp}\\[6pt] +\verb|\rtpara{para2}{This is \span{font='Myriad Pro'}| +\hspace*{20pt}\verb|{Myriad Pro} font.}|\\[3pt] +\rtpara{para2}{This is \span{font='Myriad Pro'}{Myriad Pro} font.} +\incFldCnt\textField[\Ff{\FfRichText}%\Ff{\FfMultiline} +\DS{\useDefaultDS}\RV{\useRV{para2}}\V{\useV{para2}}]{rtFld\the\fldCnt}{3in}{16bp} +\end{flushleft} +In the second example, only `Myriad Pro' is actually set in the Myriad Pro font; the rest of the sentence +is typeset in the default font, Helvetica in this case. Use \uif{Ctrl+E} (\uif{Cmd+E}) to inspect the properties +of these two fields and verify the fonts are Arial, Myriad Pro, and Helvetica. + +\item[\uif{Size}:] \texttt{size=\ameta{dec\_num}} The size of the font to + be used. The value of \texttt{size} is \ameta{dec\_num}, a (positive) + decimal number. +\begin{flushleft}\small %\previewtrue +\verb|\rtpara[size=12]{para1}{This is 12pt font, while| +\hspace*{20pt}\verb|\span{size=8}{this is 8pt font.} OK?}|\\[6pt] +\rtpara[size=12]{para1}{This is 12pt font, while \span{size=8}{this is 8pt font.} OK?} +\incFldCnt\textField[\Ff{\FfRichText}%\Ff{\FfMultiline} +\DS{\useDefaultDS}\RV{\useRV{para1}}\V{\useV{para1}}]{rtFld\the\fldCnt}{3in}{16bp} +\end{flushleft} + +\item[\uif{Baseline Shift:}] \texttt{raise=\ameta{def\_num}} The position of the baseline of the text is determined +by the \texttt{raise} key. \texttt{raise=6.6} raises the baseline \texttt{6.6pt}, while \texttt{raise=-4} lowers +it \texttt{4pt}. +\begin{flushleft}\small +\verb|\rtpara{para1}{This text \span{raise=6.6}{is raised by| +\hspace*{20pt}\verb| 6.6pt} while this text \span{raise=-4}| +\hspace*{20pt}\verb|{is lowed by 4pt.} Back to normal baselines.}|\\[6pt] +\rtpara{para1}{This text \span{raise=6.6}{is raised by 6.6pt} while this text +\span{raise=-4}{is lowed by 4pt.} Back to normal baselines.} +\incFldCnt\textField[\Ff{\FfRichText}\Ff{\FfMultiline} +\DS{\useDefaultDS}\RV{\useRV{para1}}\V{\useV{para1}}]{rtFld\the\fldCnt}{3in}{16bp*4} +\end{flushleft} + +\item[\uif{Underline:}] + \texttt{ulstyle=\ameta{\upshape{none|ul|2ul|wul|2wul}}} The + \texttt{ulstyle} key determines the style of underlining, possible values + are \texttt{none} (no underlining), \texttt{ul} (underlining), + \texttt{2ul} (double-line underlining), \texttt{wul} (word underlining), + and \texttt{2wul} (double-line word underlining). +\begin{flushleft}\small %\previewtrue +\verb|\rtpara{para1}{We can \span{ulstyle=ul}{underline in a}| +\hspace*{20pt}\verb|\span{ulstyle=2ul}{number of different ways}| +\hspace*{20pt}\verb|\span{ulstyle=wul}{that catch the}| +\hspace*{20pt}\verb|\span{ulstyle=2wul}{attention of the reader}.|\\[3pt] +\rtpara{para1}{We can \span{ulstyle=ul}{underline in a} \span{ulstyle=2ul}{number of different ways} +\span{ulstyle=wul}{that catch the} \span{ulstyle=2wul}{attention of the reader}.} +\incFldCnt\textField[\Ff{\FfRichText}\Ff{\FfMultiline} +\DS{\useDefaultDS}\RV{\useRV{para1}}\V{\useV{para1}}]{rtFld\the\fldCnt}{3in}{16bp*4} +\end{flushleft} + +\item[\uif{Style}:] + \texttt{style=\darg{\upshape{[bold,][italic,][strikeit]}}} Unlike some + of the other (choice) keys, the value of the \texttt{style} key is any + \emph{subset} of the values listed: for example, \texttt{style=bold} + paints the underlying text in bold, \texttt{style=\darg{bold,italic}} + yields bold-italic font, and, for a final example, + \texttt{style=\darg{italic,strikeit}} typesets its text in + strike-through italic. Multiple values must be enclosed in braces + (\darg{}) so that \pkg{xkeyval} can correctly parse them. +\begin{flushleft}\small %\previewtrue +\verb|\rtpara{para1}{To \span{style=bold}{boldly to go} where| +\hspace*{20pt}\verb|\span{style={bold,italic}}{no man has gone}| +\hspace*{20pt}\verb|\span{style={italic,strikeit}}{prior}| +\hspace*{20pt}\verb|\span{style={italic,bold}}{before.}|\\[3pt] +\rtpara{para1}{To \span{style=bold}{boldly to go} where +\span{style={bold,italic}}{no man has gone} +\span{style={italic,strikeit}}{prior}\span{style={italic,bold}}{before.}} +\incFldCnt\textField[\Ff{\FfRichText}\Ff{\FfMultiline} +\DS{\useDefaultDS}\RV{\useRV{para1}}\V{\useV{para1}}]{rtFld\the\fldCnt}{3in}{16bp*2} +\end{flushleft} + +\item[\uif{Color:}] + \texttt{color=\ameta{\upshape{\meta{rrggbb}|\darg{rgb(\meta{rrr,ggg,bbb})}}}} + Use this key to color the effected text. There are two + methods of defining color: +\begin{itemize} + \item[(1)] \meta{rrggbb} uses a 2-digit hexadecimal + value for each component; + \item[(2)] \texttt{rgb(\meta{rrr,ggg,bbb})} uses a decimal + value (0--255) for each component. +\end{itemize} + Because the second form contains + commas, it must necessarily be enclosed in braces (\darg{}) to be + correctly parsed by \pkg{xkeyval}. +\begin{flushleft}\small %\previewtrue +\verb|\rtpara{para1}{This is \span{color={rgb(255,0,0)}}{red} and| +\hspace*{20pt}\verb|this is \span{color=0000ff}{blue}.| +\rtpara{para1}{This is \span{color={rgb(255,0,0)}}{red} and this is \span{color=0000ff}{blue}.}\\[3pt] +\incFldCnt\textField[\Ff{\FfRichText}%\Ff{\FfMultiline} +\DS{\useDefaultDS}\RV{\useRV{para1}}\V{\useV{para1}}]{rtFld\the\fldCnt}{3in}{16bp} +\end{flushleft} +Things are not as bad as it seems. The \pkg{xcolor} package has the +wonderful command \cs{convertcolorspec} that converts colors between color +models. For example, we might define: +\begin{Verbatim}[fontsize=\small] +\convertcolorspec{named}{red}{RGB}{\rgbRed} +\convertcolorspec{named}{blue}{HTML}{\htmlBlue} +\convertcolorspec{named}{magenta}{RGB}{\rgbMagenta} +\convertcolorspec{named}{magenta}{HTML}{\htmlMagenta} +\end{Verbatim} +We can then use these named colors. +\begin{Verbatim}[fontsize=\small] +\rtpara{para1}{This is \span{color={rgb(\rgbRed)}}{red} and +this is \span{color=\htmlBlue}{blue}. We can do magenta two +ways, using \span{color={rgb(\rgbMagenta)}}{decimal +components} or using \span{color=\htmlMagenta}{hexadecimal +components}.} +\end{Verbatim} +\rtpara{para1}{This is \span{color={rgb(\rgbRed)}}{red} and this +is \span{color=\htmlBlue}{blue}. We can do magenta two ways, +using \span{color={rgb(\rgbMagenta)}}{decimal components} or +using \span{color=\htmlMagenta}{hexadecimal components}.}\par\smallskip +\incFldCnt\textField[\Ff{\FfRichText}\Ff{\FfMultiline} +\DS{\useDefaultDS}\RV{\useRV{para1}}\V{\useV{para1}}]{rtFld\the\fldCnt}{3in}{16bp*4}\\[6pt] +% +Notice that \verb|color={rgb(\rgbMagenta)}|, the value of \texttt{color}, is +still enclosed in braces since the expansion of \cs{rgbMagenta} contains +commas. +\end{description} + +\subsubsection{The \texorpdfstring{\uif{Link}}{Link} tab} + +We can create a link within rich text by using the \texttt{url} key from within +the first argument of the \cs{span} command. The syntax is \texttt{url=\ameta{URL}}. +\begin{Verbatim}[fontsize=\small] +\rtpara{para1}{Visit me at \span{url={http://www.acrotex.net}, + font='Courier New'}{http://www.acrotex.net}} +\end{Verbatim} +\begin{quote} +\rtpara{para1}{Visit me at \span{url={http://www.acrotex.net},font='Courier New'}{http://www.acrotex.net}}\par\smallskip +\incFldCnt\textField[\Ff{\FfRichText}%\Ff{\FfMultiline} +\DS{\useDefaultDS}\RV{\useRV{para1}}\V{\useV{para1}}]{rtFld\the\fldCnt}{3.5in}{16bp} +\end{quote} +It appears the \app{Acrobat/Reader} applications format a URL in underlined blue. We can override this however. +\begin{Verbatim}[fontsize=\small] +\rtpara{para1}{Visit me at \span{url={http://www.acrotex.net}, + color=\htmlMagenta,ulstyle=none,font='Courier New'} + {http://www.acrotex.net}} +\end{Verbatim} +\begin{quote} +\rtpara{para1}{Visit me at \span{url={http://www.acrotex.net}, + color=\htmlMagenta,ulstyle=none,font='Courier New'} + {http://www.acrotex.net}} +\par\smallskip +\incFldCnt\textField[\Ff{\FfRichText}%\Ff{\FfMultiline} +\DS{\useDefaultDS}\RV{\useRV{para1}}\V{\useV{para1}}]{rtFld\the\fldCnt}{3.5in}{16bp} +\end{quote} +Special characters are no problem, with the exception of wrapping a long URL +around to a different line (usually needed for display purposes): +\begin{Verbatim}[fontsize=\small] +\rtpara{para1}{Visit me at + \span{url={http://www.math.uakron.edu/~dpstory/% + acrotex.html#technical}}{AcroTeX at The University + of Akron}} +\end{Verbatim} +\begin{quote} +\rtpara{para1}{Visit me at \span{url={http://www.math.uakron.edu/% + ~dpstory/acrotex.html#technical}} + {AcroTeX at The University of Akron}}\par\smallskip +\incFldCnt\textField[\Ff{\FfRichText}\Ff{\FfMultiline} +\DS{\useDefaultDS}\RV{\useRV{para1}}\V{\useV{para1}}]{rtFld\the\fldCnt}{3.5in}{16bp*2} +\end{quote} + +\subsubsection{Miscellaneous markup of the \texorpdfstring{\uif{Font}}{Font} classification} + +There are several other attributes that are not key-values, but are +implemented through {\LaTeX} commands. + +\paragraph[Bold and italic]{Bold and italic.}\chgCurrLblName{Bold and italic}\label{para:BandI} +There are a couple of XHTML +elements that can also be used for bold and italic. +\begin{itemize} + \item \cs{bf\darg{\ameta{text}}} expands to \texttt{\ameta{text}} and places + \ameta{text} in bold font. May be used within a \cs{span} command. + \item \cs{it\darg{\ameta{text}}} expands to \texttt{\ameta{text}} and places + \ameta{text} in italic font. May be used within a \cs{span} command. +\end{itemize} +Both \cs{bf} and \cs{it} are local commands, undefined outside of the third argument +of \cs{rtpara}. Do not code \texttt{\ameta{text}} or \texttt{\ameta{text}} +directly, rather, always use the {\LaTeX} commands \cs{bf} and \cs{it}. \cs{bf} and \cs{it} may be nested. +\begin{Verbatim}[fontsize=\small] +\rtpara{para1}{We \bf{boldly} say that \it{italic} is used for +emphasis, but both \bf{\it{drive home the point}}.} +\end{Verbatim} +\begin{quote} +\rtpara{para1}{We \bf{boldly} say that \it{italic} is used for emphasis, +but both \span{color=\htmlBlue}{\bf{\it{drive home the point}}}.} +\incFldCnt\textField[\Ff{\FfRichText}\Ff{\FfMultiline} +\DS{\useDefaultDS}\RV{\useRV{para1}}\V{\useV{para1}}]{rtFld\the\fldCnt}{3.5in}{16bp*2} +\end{quote} + +\paragraph[Subscripts and superscripts]{Subscripts and superscripts.}% +\chgCurrLblName{Subscripts and superscripts}\label{para:SubSup} +Subscripts and superscripts are implemented through +{\LaTeX} commands \cs{sub} and \cs{sup}. +\begin{itemize} + \item \cs{sub\darg{\ameta{text}}} expands to + \texttt{\ameta{text}} and places \ameta{text} as a + subscript. + \item \cs{sup\darg{\ameta{text}}} expands to + \texttt{\ameta{text}} and places \ameta{text} as a + superscript. +\end{itemize} +Both \cs{sub} and \cs{sup} are local commands, undefined outside of the third argument +of \cs{rtpara}. Do not code these raw markups, rather always use \cs{sub} and \cs{sup}. +\begin{Verbatim}[fontsize=\small] +\rtpara{para1}{When we compile $x_2^3$ we get +\it{x}\sub{2}\sup{3}, nicely typeset or would you prefer +\it{x}\sup{3}\sub{2}?} +\end{Verbatim} +\begin{quote} +\rtpara{para1}{When we compile $x_2^3$ we get \it{x}\sub{2}\sup{3}, nicely typeset + or would you prefer \it{x}\sup{3}\sub{2}?} +\incFldCnt\textField[\Ff{\FfRichText}\Ff{\FfMultiline} +\DS{\useDefaultDS}\RV{\useRV{para1}}\V{\useV{para1}}]{rtFld\the\fldCnt}{3.5in}{16bp*5/2} +\end{quote} + + + +\subsection{The \texorpdfstring{\uif{Paragraph}}{Paragraph} tab}\label{s:Paratab} + +We begin by following the \uif{Paragraph} tab of +\hyperref[fig:FPtabs]{Figure~\ref*{fig:FPtabs}}. The top-most region on the \uif{Paragraph} tab +is labeled \uif{Alignment}. It consists of two separated regions, the one on the left is \emph{Horizontal Alignment}, +the one on the right is \emph{Vertical Alignment}. +\begin{description} + \item[\uif{Alignment}:]\leavevmode + \begin{description} + \item[Horizontal Alignment:] \texttt{halign=\ameta{\upshape{left|center|right|justify}}}\\The meaning of these + key-values are obvious, we'll illustrate with examples. +\begin{Verbatim}[fontsize=\small] +\rtpara[halign=left]{para1}{This paragraph is left + aligned or flush left. Let's have a few more words + to wrap around.} +\rtpara[halign=center]{para2}{This paragraph is + centered. Let's have a few more words to wrap + around.} +\rtpara[halign=right]{para3}{This paragraph is right + aligned or flush right. Let's have a few more words + to wrap around.} +\rtpara[halign=justify]{para4}{This paragraph is + justified. Space between words are stretched a + little to make this happen. It is adequate for + our purposes.} +\end{Verbatim} +\begin{flushleft} +\rtpara[halign=left]{para1}{This paragraph is left aligned or flush left. Let's have a few more words to wrap around.} +\rtpara[halign=center]{para2}{This paragraph is centered. Let's have a few more words to wrap around.} +\rtpara[halign=right]{para3}{This paragraph is right aligned or flush right. Let's have a few more words to wrap around.} +\rtpara[halign=justify]{para4}{This paragraph is justified. Space + between words are stretched a little to make this happen. It is adequate for our purposes.} +\setRVVContent{myContent}{{para1}{skipline}{para2}{skipline}{para3}{skipline}{para4}} %{skipline} +\setDefaultStyle{myDS}{font={Helvetica,sans-serif},size=10,color=000000}\par\medskip +\incFldCnt\textField[\Ff{\FfRichText}\Ff{\FfMultiline} +\DS{\useDS{myDS}}\RV{\useRVContent{myContent}}\V{\useVContent{myContent}}]{rtFld\the\fldCnt}{3in}{12bp*12} +\end{flushleft} +Horizontal alignment is applied to individual paragraph, unlike vertical alignment. + + \item[Vertical Alignment:] + \texttt{valign=\ameta{\upshape{top|middle|bottom}}} Again, + we shall illustrate by example. +\begin{Verbatim}[fontsize=\small] +\rtpara[valign=top]{para1}{This paragraph is vertically + aligned at the top.} +\rtpara[valign=middle]{para2}{This paragraph is + vertically aligned at the middle.} +\rtpara[valign=bottom]{para3}{This paragraph is + vertically aligned at the bottom.} +\end{Verbatim} +\begin{flushleft} +\rtpara[valign=top]{para1}{This paragraph is vertically aligned at the top.} +\rtpara[valign=middle]{para2}{This paragraph is vertically aligned at the middle.} +\rtpara[valign=bottom]{para3}{This paragraph is vertically aligned at the bottom.} +\incFldCnt\textField[\Ff{\FfRichText}\Ff{\FfMultiline} +\DS{\useDefaultDS}\RV{\useRV{para1}}\V{\useV{para1}}]{rtFld\the\fldCnt}{1.5in}{16bp*5}\kern4bp +\incFldCnt\textField[\Ff{\FfRichText}\Ff{\FfMultiline} +\DS{\useDefaultDS}\RV{\useRV{para2}}\V{\useV{para2}}]{rtFld\the\fldCnt}{1.5in}{16bp*5}\kern4bp +\incFldCnt\textField[\Ff{\FfRichText}\Ff{\FfMultiline} +\DS{\useDefaultDS}\RV{\useRV{para3}}\V{\useV{para3}}]{rtFld\the\fldCnt}{1.5in}{16bp*5}\par\medskip +\end{flushleft} +The \texttt{valign} key seems to apply to all paragraphs in the rich text form field, as illustrated below. +\begin{flushleft} +\setRVVContent{myContent}{{para1}{skipline}{para2}{skipline}{para3}}\par\smallskip %{skipline} +\incFldCnt\textField[\Ff{\FfRichText}\Ff{\FfMultiline} +\DS{\useDefaultDS}\RV{\useRVContent{myContent}}\V{\useVContent{myContent}}]{rtFld\the\fldCnt}{4in}{16bp*8}\par\smallskip +\setRVVContent{myContent}{{para2}{skipline}{para1}{skipline}{para3}}\par\smallskip %{skipline} +\incFldCnt\textField[\Ff{\FfRichText}\Ff{\FfMultiline} +\DS{\useDefaultDS}\RV{\useRVContent{myContent}}\V{\useVContent{myContent}}]{rtFld\the\fldCnt}{4in}{16bp*8} +\end{flushleft} +The vertical alignment for the whole rich text field obeys the \texttt{valign} key of the first paragraph. + + \item[\uif{Indents:}] Through the \uif{Indents} region of the \uif{Paragraph} tab, left and right margins may be set, + as well as the amount of indent. + \begin{description} + \item[\uif{Left:}] \texttt{margleft=\darg{dec}} The value of \darg{dec} is a nonnegative decimal number, it represents + the number of points to make the left margin. + \item[\uif{Right:}] \texttt{margright=\darg{dec}} The value of \darg{dec} is a nonnegative decimal number, it represents + the number of points to make the right margin. + +\medskip + Below is an example for both \texttt{margleft} and \texttt{margright}. +\begin{Verbatim}[fontsize=\small] +\rtpara[margleft=10,margright=40,halign=justify + ]{para1}{This is the first paragraph, it has + a left margin of 10pt and a right margin of + 40pt.} +\rtpara[halign=justify]{para2}{This is the second + paragraph. We demonstrate that the left and + margins can be applied separately to + paragraphs.} +\end{Verbatim} +\begin{flushleft} +\rtpara[font=10,margleft=10,margright=40,halign=justify]{para1}{This is the first +paragraph, it has a left margin of 10pt and a right margin of 40pt.} +\rtpara[font=10,halign=justify]{para2}{This is the second paragraph. We demonstrate that the +left and margins can be applied separately to paragraphs.} +\setRVVContent{myContent}{{para1}{skipline}{para2}}\par\smallskip %{skipline} +\incFldCnt\textField[\Ff{\FfRichText}\Ff{\FfMultiline} +\DS{\useDefaultDS}\RV{\useRVContent{myContent}}\V{\useVContent{myContent}}]{rtFld\the\fldCnt}{4in}{14bp*6} +\end{flushleft} + +\medskip +\item[\uif{First \& By:}] Two key-values: \texttt{indent=\ameta{\upshape{none|first|hanging}}} \& \texttt{indentby=\ameta{dec}} + When \texttt{indent} key is set to \texttt{indent=first}, the first line is indented by an amount of \texttt{\ameta{dec}pt}; similarly, + if \texttt{indent=hanging}, there is a hang indent on the first line by an amount of \texttt{-\ameta{dec}pt} + (the minus sign (\texttt{-}) is automatically applied. The default indent amount it \texttt{12pt}.\smallskip\kern0pt +\begin{Verbatim}[fontsize=\small] +\rtpara[indent=first]{para1}{This paragraph is + indented by the default amount of 12pt.} +\rtpara[indent=first,indentby=24]{para2}{In this + second paragraph, we indent by 24pt, twice + as wide as the default.} +\rtpara[indent=hanging]{par3}{Here we have a third + paragraph, separated from the other two, with + the default hanging indentation.} +\end{Verbatim} +\begin{flushleft} +\rtpara[indent=first]{para1}{This paragraph is indented by the default amount of 12pt.} +\rtpara[indent=first,indentby=24]{para2}{In this second paragraph, we indent by 24pt, twice as wide as the default.} +\rtpara[indent=hanging]{para3}{Here we have a third paragraph, separated from the other two, with +the default hanging indentation.}\par\smallskip +\setRVVContent{myContent}{{para1}{para2}{skipline}{para3}}\par\smallskip %{skipline} +\incFldCnt\textField[\Ff{\FfRichText}\Ff{\FfMultiline} +\DS{\useDefaultDS}\RV{\useRVContent{myContent}}\V{\useVContent{myContent}}]{rtFld\the\fldCnt}{3.5in}{16bp*15/2}\par\smallskip +\end{flushleft} + + \end{description} + +\goodbreak + \item[\uif{Spacing:}] + \begin{description} + \item[\uif{Above:}] \texttt{margtop=\ameta{dec}} A value of \ameta{dec} (positive, negative, or zero) adds + vertical space \emph{above} the paragraph.\medskip +\begin{Verbatim}[fontsize=\small] +\rtpara[margtop=12]{para1}{We put 12pt of extra + space above this paragraph.} +\rtpara[margtop=24]{para2}{Extra space above this + paragraph (24pt).} +\end{Verbatim} +\begin{flushleft} +\rtpara[margtop=12]{para1}{We put 12pt of extra space above this paragraph.} +\rtpara[margtop=24]{para2}{Extra space above this paragraph (24pt).} +\setRVVContent{myContent}{{para1}{para2}}\par\medskip %{skipline} +\incFldCnt\textField[\Ff{\FfRichText}\Ff{\FfMultiline} +\DS{\useDefaultDS}\RV{\useRVContent{myContent}}\V{\useVContent{myContent}}]{rtFld\the\fldCnt}{3.5in}{16bp*6}\par\smallskip +\end{flushleft} + + \item[\uif{Below:}] \texttt{margbottom=\ameta{dec}} A value of \ameta{dec} (positive, negative, or zero) adds + vertical space below the paragraph.\par\medskip +\begin{Verbatim}[fontsize=\small] +\rtpara[valign=bottom,margbottom=12]{para1}{We put + \span{font=Courier,style=bold}{valign=bottom}, + but bring the paragraph up 12pt from there.} +\end{Verbatim} +\rtpara[valign=bottom,margbottom=12]{para1}{We put \span{font=Courier,style=bold}{valign=bottom}, but bring the +paragraph up 12pt from there.}\par\medskip +\incFldCnt\textField[\Ff{\FfRichText}\Ff{\FfMultiline} +\DS{\useDefaultDS}\RV{\useRV{para1}}\V{\useV{para1}}]{rtFld\the\fldCnt}{3.5in}{16bp*6} + +\medskip\goodbreak + \item[\uif{Line Spacing}] Sets the amount of vertical space between baselines. The key-values are +\begin{equation*} + \texttt{linespacing=\ameta{\upshape{single|oneandhalf|double|exact}}} +\end{equation*} + When \texttt{linespacing=exact}, use + \texttt{lineheight=\ameta{dec}} to set the space between baselines. +\begin{flushleft} +\rtpara[linespacing=oneandhalf]{para1}{This +paragraph has line spacing of oneandhalf. We will prattle on to get +some wraparound to the next line.} +\rtpara[linespacing=double]{para2}{This paragraph has double spacing. Once again, we'll +ramble, not prattle, on for several more words.} +\rtpara[linespacing=exact,lineheight=30]{para3}{Let's see what we get here, with +linespacing=exact, lineheight=30. Do we get significant separation between sentences?} +\setRVVContent{myContent}{{para1}{para2}{para3}}\par\medskip %{skipline} +\incFldCnt\textField[\Ff{\FfRichText}\Ff{\FfMultiline} +\DS{\useDefaultDS}\RV{\useRVContent{myContent}}\V{\useVContent{myContent}}]{rtFld\the\fldCnt}{\linewidth-2bp}{16bp*12}\par\medskip +\end{flushleft} + +The paragraph declarations for the above rich text field are, +\begin{Verbatim}[fontsize=\small] +\rtpara[linespacing=oneandhalf]{para1}{This + paragraph has line spacing of oneandhalf. We + will prattle on to get some wraparound to the + next line.} +\rtpara[linespacing=double]{para2}{This paragraph + has double spacing. Once again, we'll ramble, + not prattle, on for several more words.} +\rtpara[linespacing=exact,lineheight=30]{para3} + {Let's see what we get here, with + linespacing=exact, lineheight=30. Do we + get significant separation between sentences?} +\end{Verbatim} +\medskip\noindent +The value of \texttt{lineheight}, which gives a `squeezing' effect between lines of the paragraph. + \end{description} + \end{description} +\end{description} + +\subsubsection{Miscellaneous markup for the \texorpdfstring{\protect\uif{Paragraph}}{Paragraph} classification} + +There are several other features that do not fit conveniently anywhere else, so here they are. + +\paragraph[Starting a new line using \texorpdfstring{\protect\cs{br}}{\textbackslash{br}}]% +{Starting a new line using \cs{br}.}\chgCurrLblName{Starting a new line using \protect\cs{br}}\label{para:NewLine} +The \cs{br} command expands to \texttt{
}. It should not be put within +the second argument of the \cs{span} command. As was the case with \cs{bf}, +\cs{it}, \cs{sub}, and \cs{sup}, do not directly code in \texttt{
} for +you will fail. +\begin{Verbatim}[xleftmargin=\amtIndent] +\rtpara{para1}{Let's begin a sentence,\br then we'll + start a new line for no apparent reason.\br\br + Let's double down on the new lines shall we?} +\end{Verbatim} +\begin{quote} +\rtpara{para1}{Let's begin a sentence,\br then we'll + start a new line for no apparent reason.\br\br Let's + double down on the new lines shall we?} +\incFldCnt\textField[\Ff{\FfRichText}\Ff{\FfMultiline} +\DS{\useDefaultDS}\RV{\useRV{para1}}\V{\useV{para1}}]{rtFld\the\fldCnt}{3.5in}{16bp*6} +\end{quote} + +\paragraph[Adding spaces with \texorpdfstring{\cs{spc}}{\textbackslash{spc}}]{Adding + spaces with \cs{spc}.}\chgCurrLblName{Adding + spaces with \protect\cs{spc}}\label{para:addSPC} + As with {\TeX} multiple spaces are ignored. To insert additional + `hard' spaces into the data stream, use the \cs{spc} command. (This is a local command that + is undefined outside \cs{rtpara}. +\begin{Verbatim}[xleftmargin=\amtIndent] +\rtpara{para1}{Way to go!\spc\spc\spc\spc The Coach} +\end{Verbatim} +Here we induce four hard spaces. +\begin{quote} +\rtpara{para1}{Way to go!{\spc\spc\spc\spc}The Coach} +\incFldCnt\textField[\Ff{\FfRichText}%\Ff{\FfMultiline} +\DS{\useDefaultDS}\RV{\useRV{para1}}\V{\useV{para1}}]{rtFld\the\fldCnt}{3.5in}{16bp} +\end{quote} + +\paragraph[Using the \texorpdfstring{\texttt{raw}}{raw} key]{Using +the \texttt{raw} key.}\chgCurrLblName{Using +the \texttt{raw} key}\label{para:RawKey} +There is another key, the \texttt{raw} key, that can be used +within the optional argument of \cs{rtpara} or within the first argument of \cs{span}. Using this key, +you can pass raw CSS2 markup. +\begin{Verbatim}[xleftmargin=\amtIndent] +\rtpara{para1}{We test the letter-spacing + attribute:\br\br\span{raw=letter-spacing:0.25em;} + {We test the letter-spacing attribute.}} +\end{Verbatim} +\begin{quote} +\rtpara{para1}{We test the letter-spacing attribute:\br\br\span{raw=letter-spacing:0.25em;}{We test the letter-spacing +attribute.}} +\incFldCnt\textField[\Ff{\FfRichText}\Ff{\FfMultiline} +\DS{\useDefaultDS}\RV{\useRV{para1}}\V{\useV{para1}}]{rtFld\the\fldCnt}{3.5in}{16bp*6} +\end{quote} +The syntax for a CSS2 attribute is `\texttt{\ameta{key}:\ameta{value};}', that is, keys and values are separated +by a colon (\texttt{:}) and the value is terminated with a semi-colon (\texttt{;}). + +It appears that tab stops work as well, these can be specified using the \texttt{raw} key as well. Refer to the +XFA Specifications~\cite{webpage:XFASpec}. + +\paragraph[Special characters]{Special characters.}\chgCurrLblName{Special characters}\label{para:SpecChars} + The \pkg{richtext} handles special characters pretty well. +Before \cs{rtpara} reads its third argument (\ameta{rich-text-paragraph}), a +number of changes in \cs{catcode}s and redefinitions occur. Within +\cs{rtpara}, the following characters \emph{do not need to be} escaped: +\texttt{\$}, \texttt{\#}, and \texttt{\string~} (tilde). The following +characters \emph{need to be} escaped: \texttt{\cs{<}}, \texttt{\cs{>}}, +\verb|\&|, \verb|\%| (the comment character (\texttt{\%}) retains its +{\LaTeX} meaning), \verb|\{|, and \verb|\}| (the left and right braces have +their usual \TeX/LaTeX{} meaning). The single quote (\texttt{'}) and double quote (\texttt{"}) may +be optionally escaped (to \cs{'} and \cs{"}). Escape them if something goes wrong. Use the +command \cs{cs\darg{\ameta{text}}} to obtain a literal backslash (`\verb|\|'); for example +\verb|\cs{LaTeX}|, shown below, expands to `\texttt{\cs{LaTeX}}'. +\begin{Verbatim}[fontsize=\small] +\rtpara{para1}{We \"test\" \'special\' \bf{characters:} + \<\>\&\{ #\% in \cs{LaTeX} $x^2_4$ becomes + \it{x}\sup{2}\sub{4} \{\}} +\end{Verbatim} +The above \cs{rtpara} paragraph has two forms the \psf{RV} form and the \psf{V} form; these +can be seen by using the \cs{useRV} and \cs{useV} commands. + +\begingroup\raggedright +\makeatletter\def\rt@SC{;\penalty0}\makeatother +\rtpara{para1}{We \"test\" 'special' \bf{characters:} \<\>\&\{ #\% in +\cs{LaTeX} $x^2_4$ becomes \it{x}\sup{2}\sub{4} \{\}} +\begin{quote} +\hspace*{-\leftmargini}\textbf{\cs{useRV\darg{para1}:}} \texttt{\useRV{para1}} + +\hspace*{-\leftmargini}\textbf{\cs{useV\darg{para1}:}} \texttt{\useV{para1}} +\end{quote} +The resulting rich text form field is seen below:\\[3pt] +\makeatletter\def\rt@SC{;}\makeatother +\rtpara{para1}{We \"test\" \'special\' \bf{characters:} \<\>\&\{ #\% in +\cs{LaTeX} $x^2_4$ becomes \it{x}\sup{2}\sub{4} \{\}} +\incFldCnt\textField[\Ff{\FfRichText}\Ff{\FfMultiline} +\DS{\useDefaultDS}\RV{\useRV{para1}}\V{\useV{para1}}]{rtFld\the\fldCnt}{3in}{16bp*4} +\par\endgroup +\medskip\noindent +That's pretty cool! + +\section{Rich text fields} + +Up to this point in the manual, the discussion has focused on creating rich +text strings. They may be fun to create and look at, but usually we want to +insert them into a text field. The comments here are for \pkg{eforms} +package, having checked with \pkg{hyperref} to see if there is a \psf{RV} +key, there is not. + +To create a rich text field, use the \cs{textField} command of \pkg{eforms}: +\begin{Verbatim}[xleftmargin=\amtIndent,commandchars=!()] +\textField[\Ff{\FfRichText}\Ff{\FfMultiline} + \DS{!ameta(defaultstyle)}\RV{!ameta(rich-value)}\V{!ameta(value)} +]{!ameta(fld-name)}{!ameta(width)}{!ameta(height)} +\end{Verbatim} +Remove \cs{Ff\darg{\cs{FfMultiline}}} if the field is only a single line. We +discuss the \psf{DS} key (\cs{DS}) key first, followed by the keys \psf{RV} +and \psf{V} (\cs{RV} and \cs{V}). + +\subsection{The \texorpdfstring{\protect\psf{DS}}{DS} key} + +The value of the \psf{DS} key sets the formatting for the text field as a +whole. Most importantly, use it to set the font, text size, and color. +There is a built-in default style, defined below: +\bVerb\takeMeasure{\small\string\newcommand\string\useDefaultDS\darg{font-family:Helvetica,sans-serif;}}% +\begin{dCmd}[fontsize=\small,commandchars=!()]{\bxSize} +\newcommand\useDefaultDS{font-family:Helvetica,sans-serif; + font-size:12.0pt;font-style:normal;font-weight:normal; + text-align:left;color:#000000} +\end{dCmd} +\eVerb You may redefine it to suit your purposes, but this is what +\app{Acrobat}/\app{Adobe Reader} sets as the default style. I would recommend +\cs{setDefaultStyle} to define your own custom default style. \cs{useDefaultDS} is the reason +why most all rich text fields in this document use Helvetica at \texttt{12pt}! Use +\cs{useDefaultDS} as follows, shown in bold font: +\begin{Verbatim}[xleftmargin=\amtIndent,commandchars=!()] +\textField[\Ff{\FfRichText}\Ff{\FfMultiline} + \DS{!textbf(\useDefaultDS)}\RV{!ameta(rich-value)}\V{!ameta(value)} +]{!ameta(fld-name)}{!ameta(width)}{!ameta(height)} +\end{Verbatim} + +\newtopic\noindent To create a custom default style use \cs{setDefaultStyle}. +\bVerb\takeMeasure{\string\setDefaultStyle\darg{\ameta{name}}\darg{\ameta{Font-Para-attrs}}}% +\begin{dCmd}[commandchars=!()]{\bxSize} +\setDefaultStyle{!ameta(name)}{!ameta(Font-Para-attrs)} +\useDS{!ameta(name)} +\end{dCmd} +Typically, the key-values associated with the \uif{Font} tab, Section~\ref{s:FLtabs}, may be used, +some key-values are removed, such as \texttt{ul}, \texttt{raise}, and \texttt{url}. When you've defined +a custom default style using \cs{setDefaultStyle}, insert \cs{useDS\darg{\ameta{name}}} as the value +of the \psf{DS} key.\incFldCnt +\begin{Verbatim}[xleftmargin=\amtIndent,fontsize=\small,commandchars=!()] +\rtpara{para1}{The font should be \'Myriad Pro\' at 10pt + and the default color of the field is webbrown, a color + defined in the web package.} +\setDefaultStyle{myStyle}{font='Myriad Pro',size=10, + color=!htmlWebBrown} +\textField[\Ff{\FfRichText}\Ff{\FfMultiline} + \DS{!textbf(\useDS{myStyle})}\RV{\useRV{para1}}\V{\useV{para1}} +]{rtFld!the!fldCnt}{3in}{16bp*3} +\end{Verbatim} +\begin{quote} +\rtpara{para1}{The font should be \'Myriad Pro\' at 10pt and the + default color of the field is webbrown, a color defined in the web package.} +\setDefaultStyle{myStyle}{font='Myriad Pro',size=10,color=\htmlWebBrown} +\textField[\Ff{\FfRichText}\Ff{\FfMultiline} +\DS{\useDS{myStyle}}\RV{\useRV{para1}}\V{\useV{para1}}]{rtFld\the\fldCnt}{3in}{16bp*3} +\end{quote} +Note the use of \cs{useRV} and \cs{useV} in the \psf{RV} and \psf{V} fields. +These are discussed in the next section. + +\subsection{The \texorpdfstring{\protect\psf{RV}}{RV} and +\texorpdfstring{\protect\psf{V}}{V} keys} + +The techniques to handle multiple paragraph fields are more complex (but not discouragingly so), +that topic will be taken up after the discussion of single paragraph fields. + +\subsubsection{Single paragraph fields} + +For a single paragraph field, there is only one \cs{repara} defined prior to the field. This string +data (both rich and plain) are inserted into the \cs{RV} and \cs{V} keys using \cs{useRV} and \cs{useV}. We repeat the +previous example, but with the emphasis on \cs{RV} and \cs{V}, and not on \cs{DS}. +\begin{Verbatim}[xleftmargin=\amtIndent,fontsize=\small,commandchars=!()] +\rtpara{para1}{The font should be \'Myriad Pro\' at 10pt + and the default color of the field is webbrown, a + color defined in the web package.} +\setDefaultStyle{myStyle}{font='Myriad Pro',size=10, + color=!htmlWebBrown} +\textField[\Ff{\FfRichText}\Ff{\FfMultiline} + \DS{\useDS{myStyle}}\RV{!textbf(\useRV{para1})}\V{!textbf(\useV{para1})} +]{rtFld!the!fldCnt}{3in}{16bp*3} +\end{Verbatim} +\begin{quote} +\rtpara{para1}{The font should be \'Myriad Pro\' at 10pt and the +default color of the field is webbrown, a color defined in the web package.} +\setDefaultStyle{myStyle}{font='Myriad Pro',size=10,color=\htmlWebBrown} +\textField[\Ff{\FfRichText}\Ff{\FfMultiline} +\DS{\useDS{myStyle}}\RV{\useRV{para1}}\V{\useV{para1}}]{rtFld\the\fldCnt}{3in}{16bp*3} +\end{quote} +We declare our rich paragraph string using \cs{rtpara} and name it +\texttt{para1}. We insert two data streams, one into the rich text key +(\cs{RV\darg{useRV\darg{para}}}) and the other into the (plain) text key +(\cs{V\darg{useV\darg{para}}}). + + +\subsubsection{Multiple paragraph fields} + +The strategy is to use several \cs{rtpara} commands to declare several rich +text paragraph. What is the best way to `paste' these paragraphs together? The method +developed is to use \cs{setRVVContent} command. +\bVerb\takeMeasure{\string\setRVVContent\darg{\ameta{name}}\darg{ \darg{\ameta{name\SUB{1}}}\darg{\ameta{name\SUB{2}}}...\darg{\ameta{name\SUB{k}}} }}% +\begin{dCmd}[commandchars=!()]{\bxSize} +\setRVVContent{!ameta(name)}{ {!ameta(name!SUB(1))}{!ameta(name!SUB(2))}...{!ameta(name!SUB(k))} } +\end{dCmd} +\eVerb where \ameta{name\SUB{i}} is the name of a rich text paragraph string, +or is the keyword \texttt{skipline}. The keyword \texttt{skipline} is +case-sensitive, it must be typed exactly. The role \texttt{skipline} plays is to +insert a blank line between paragraphs; \texttt{\darg{skipline}} inserts one +blank line between paragraphs. + +Having composed how the strings are to be put together, we need to insert them into +\psf{RV} and \psf{V}. +\bVerb\takeMeasure{\string\useRVContent\darg{\ameta{name}}}% +\begin{dCmd}[commandchars=!()]{\bxSize} +\useRVContent{!ameta(name)} +\useVContent{!ameta(name)} +\end{dCmd} +\eVerb where \ameta{name} is the name given in a previous \cs{setRVVContent} +command. Insert \cs{useRVContent} as the value of the \psf{RV} key, and +\cs{useVContent} as the value of the \psf{V} key. + +We take as an example, the one from Section~\ref{s:CreateRTS}.\incFldCnt +\begin{Verbatim}[fontsize=\small] +\rtpara[indent=first]{para1}{Now is the time for + \span{style={bold,italic,strikeit},color=ff0000}{J\374rgen} + and all good men to come to the aid of \it{their} + \bf{country}. Now is the time for \span{style=italic} + {all good} women to do the same.} +\rtpara[indent=first]{para2}{With rich text, we can format the + text within the text field. As a reader of this rich text + field, you can edit the contents of the box, feel free to + do so.} +\rtpara[halign=right]{para3}{D. P. Story + \span{url=http://www.acrotex.net}{AcroTeX.Net}} +\end{Verbatim} +Now set the content with \cs{setRVVContent}, naming it \texttt{myContent}. +\begin{Verbatim}[fontsize=\small] +\setRVVContent{myContent}{{para1}{para2}{skipline}{para3}} +\end{Verbatim} +Having done all that, we create our rich text field: +\begin{Verbatim}[fontsize=\small,commandchars=!()] +\begin{center} +\textField[\Ff{\FfRichText}\Ff{\FfMultiline} + \DS{\useDefaultDS} + !textbf(\RV{\useRVContent{myContent}}) + !textbf(\V{\useVContent{myContent}}) +]{rtFld!the!fldCnt}{4in}{10\baselineskip} +\end{center} +\end{Verbatim} +where, the \cs{RV} and \cs{V} keys are highlighted in bold for your viewing pleasure. +The rich text field the result of these declarations. + +\rtpara[indent=first]{para1}{Now is the time for +\span{style={bold,italic,strikeit},color=ff0000}{J\374rgen} and +all good men to come to the aid of \it{their} \bf{country}. Now +is the time for \span{style=italic}{all good} women to do the same.} +\rtpara[indent=first]{para2}{With rich text, we can format the text within +the text field. As a reader of this rich text field, you can edit the +contents of the box, feel free to do so.} +\rtpara[halign=right]{para3}{D. P. Story \span{url=http://www.acrotex.net}{AcroTeX.Net}} + +\setRVVContent{myContent}{{para1}{para2}{skipline}{para3}} + +\begin{center} +%\previewtrue +\incFldCnt +\textField[\Ff{\FfRichText}\Ff{\FfMultiline} +\DS{\useDefaultDS}%\DS{\useDS{myDS}}% +\RV{\useRVContent{myContent}}\V{\useVContent{myContent}}]{rtFld\the\fldCnt}{4in}{10\baselineskip} +\end{center} + +The argument of \cs{setRVVContent} is pretty robust. In making our declarations, we can type: +\begin{Verbatim}[xleftmargin=\amtIndent,fontsize=\small] +\setRVVContent{myContent} +{ + {para1} + {para2} + {skipline} + {skipline} + {para3} +} +\end{Verbatim} +Note that I've added a \texttt{skipline} so that are two blank lines after the second paragraph +and before the third paragraph. + +\bigskip\noindent +That's about it! Now, back to my retirement. \dps \space (See next page) + +\newpage + +Did I say that you can write captions to figures using rich text? + +\rtpara[valign=bottom,margbottom=12,margleft=12,margright=12]{farewell}{\bf{Thank you} for reviewing the +\span{font=Courier}{richtext} package, I hope you will enjoy exploring +it. Did I say that \span{url=www.acrotex.net,style=bold}{AcroTeX Rocks!}\spc\spc\spc\spc dps} + +\begin{center}\incFldCnt +\makebox[\dpswebW]{\makebox[0pt][l]{\textField[\BC{}\BG{}\autoCenter{n}\Ff{\FfRichText}\Ff{\FfMultiline} +\DS{\useDefaultDS} +\RV{\useRV{farewell}}\V{\useV{farewell}}]{rtFld\the\fldCnt}{\dpswebW}{\dpswebH}}% + \includegraphics{dpsweb}} +\end{center} + +\newpage + +\begin{thebibliography}{[1]}\label{references} +\addcontentsline{toc}{section}{\protect\numberline{}References} +%\backrefparscanfalse +\let\backrefprint\relax +\def\srtln{\vskip-\baselineskip\vskip-\parsep} +\def\lngln{\vskip-\parsep} + +\bibitem{webpage:XFASpec}\hypertarget{references}{}% +Adobe XML Forms Architecture (XFA) Specification, Version 3.3, Adobe Systems, Inc., +Jan.\ 2012\backrefprint + \lngln\hfill{\small\url{partners.adobe.com/public/developer/xml/index_arch.html}} + +\bibitem{webpage:CSS2} +Cascading Style Sheets (CSS 2.2) Specification, Editors: Bert Bos \textsl{et al.}, +World Wide Web Consortium (W3C), June 2011 + \lngln\hfill{\small\url{https://www.w3.org/TR/CSS2/}} + +\bibitem{tech:AcroJS} + JavaScript for Acrobat API Reference, + Adobe Systems, Inc., May 2015 + \lngln\hfill{\small\url{adobe.com/devnet/acrobat/documentation.html}} + +\bibitem{book:pdfspec} + PDF Reference, Sixth Edition, Version 1.7, Adobe Systems, Inc., 2006 + \lngln\hfill{\small\url{adobe.com/devnet/pdf/pdf_reference_archive.html}} + + +\end{thebibliography} + + + +% Adobe XML Forms Architecture (XFA) Specification, version 3.3, Jan. 2012, +% http://partners.adobe.com/public/developer/xml/index_arch.html + +\end{document} + +\bVerb\takeMeasure{\string\useNoHints\quad\string\useHints}% +\begin{dCmd}[commandchars=!()]{\bxSize} +\useNoHints!quad\useHints +\end{dCmd} +\eVerb The commands are used between \env{card} environments to change the +default usage of hints. When hints are \emph{not provided}, a simple message +defined by the command \cs{noHintProvided} (see \autopageref{noHintProvided}) appears on the hint page. diff --git a/texmf-dist/source/latex/richtext/richtext.dtx b/texmf-dist/source/latex/richtext/richtext.dtx new file mode 100644 index 00000000..51bb4118 --- /dev/null +++ b/texmf-dist/source/latex/richtext/richtext.dtx @@ -0,0 +1,775 @@ +%\iffalse +%<*copyright> +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% richtext package, %% +%% Copyright (C) 2016 D. P. Story %% +%% dpstory@uakron.edu %% +%% %% +%% This program can redistributed and/or modified under %% +%% the terms of the LaTeX Project Public License %% +%% Distributed from CTAN archives in directory %% +%% macros/latex/base/lppl.txt; either version 1 of the %% +%% License, or (at your option) any later version. %% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +%\NeedsTeXFormat{LaTeX2e}[1997/12/01] +%\ProvidesPackage{richtext} +% [2016/10/03 v1.0c richtext: create rich text strings (dps)] +%<*driver> +\documentclass{ltxdoc} +\usepackage[colorlinks,hyperindex=false]{hyperref} +\usepackage{calc} +\let\uif\textsf\let\app\textsf +\let\pkg\textsf\let\env\texttt +\def\psf#1{\textsf{\textbf{#1}}} +%\pdfstringdefDisableCommands{\let\\\textbackslash} +\OnlyDescription % comment out for implementation details +\EnableCrossrefs +\CodelineIndex +\RecordChanges +\InputIfFileExists{aebdocfmt.def}{\PackageInfo{richtext}{Inputting aebdocfmt.def}} + {\def\IndexOpt{\DescribeMacro}\def\IndexKey{\DescribeMacro}\let\setupFullwidth\relax + \PackageInfo{richtext}{aebdocfmt.def cannot be found}} +\begin{document} +\def\CMD#1{\textbackslash#1} + \GetFileInfo{richtext.sty} + \title{\textsf{richtext}: Creating Rich Text Strings} + \author{D. P. Story\\ + Email: \texttt{dpstory@acrotex.net}} + \date{processed \today} + \maketitle + \tableofcontents + \let\Email\texttt + \renewenvironment{theglossary}{% + \let\efill\relax + \begin{itemize}}{\end{itemize}} + \value{GlossaryColumns}=1 + \DocInput{richtext.dtx} +\IfFileExists{\jobname.ind}{\newpage\setupFullwidth\par\PrintIndex}{\paragraph*{Index} The index goes here.\\Execute + \texttt{makeindex -s gind.ist -o richtext.ind richtext.idx} on the command line and recompile + \texttt{richtext.dtx}.} +\IfFileExists{\jobname.gls}{\PrintChanges}{\paragraph*{Change History} The list of changes goes here.\\Execute + \texttt{makeindex -s gglo.ist -o richtext.gls richtext.glo} on the command line and recompile + \texttt{richtext.dtx}.} +\end{document} +% +% \fi +% \MakeShortVerb{|} +% \InputIfFileExists{aebdonotindex.def}{\PackageInfo{web}{Inputting aebdonotindex.def}} +% {\PackageInfo{web}{cannot find aebdonotindex.def}} +% \begin{macrocode} +%<*package> +\RequirePackage{xkeyval} +\RequirePackage{ifxetex}[2006/08/21] +% \end{macrocode} +% \section{Introduction} +% This package supports the creation of \emph{rich text strings} (a type of pdf string). A +% rich text string is used in a rich text field as the value of the PDF key \psf{RV}. We also support +% the \psf{DS} key which determines the default style. +% +% From the PDF Reference (PDF~1.7), page 1310, ``these rich text strings are fully-formed XML documents that conform to the rich +% text conventions specified for the XML Forms Architecture (XFA) specification, +% which is itself a subset of the XHTML 1.0 specification, augmented with a +% restricted set of CSS2 style attributes.'' +% +% A rich text field may be created using the \pkg{eforms} package, like so +%\begin{verbatim} +% \textField[\Ff{\FfRichText}\Ff{\FfMultiline} +% \DS{}\RV{}\V{} +% ]{}{}{} +%\end{verbatim} +% This package provides commands and methods for `conveniently' create values +% \texttt{} and \texttt{} for \psf{RV} and +% \psf{DS}; additionally, the value \texttt{} of the \psf{V} key is the `plain' text +% value of the field; that is the text with all the formatting stripped out. +% +%\section{Preliminaries} +% \begin{macrocode} +\newif\ifrt@formfield \rt@formfieldtrue +\newif\ifrt@needsbody\rt@needsbodyfalse +\@ifpackageloaded{eforms}% + {\ifxetex\let\@eqV\@eqnuV\fi}{\rt@needsbodytrue} +\providecommand\eq@RV@Body{} +\providecommand\eq@RV@endBody{} +\def\rt@bBody{\ifrt@needsbody\eq@RV@Body\fi} +\def\rt@eBody{\ifrt@needsbody\eq@RV@endBody\fi} +% \end{macrocode} +%\section{Documentation for the \texorpdfstring{\protect\psf{RV}}{RV} key} +% +%We follow the \app{Acrobat} user interface. +%There two tabs of interest \uif{Font} and \uif{paragraph}. +% +%\begin{description} +%\item[Font]\leavevmode +%\begin{description} +% \item[\uif{Text}]\leavevmode +% \begin{itemize} +% \item\uif{Font:} \texttt{} +% \item\uif{Size:} 10 +% \item\uif{Baseline Shift:} 0 points +% \item\uif{Underline:} No Underline, Underline, Double Underline, Word Underline, Word Double Underline +% \item\uif{Style:} Bold, Italic, Strike-through +% \item\uif{Color:} RGB +% \end{itemize} +%\end{description} +%\item[Paragraph]\leavevmode +%\begin{description} +% \item[\uif{Alignment}]\leavevmode +% \begin{itemize} +% \item Horizontal: left, center, right, justify +% \item Vertical: top, middle, bottom +% \end{itemize} +% \item[\uif{Indents}]\leavevmode +% \begin{itemize} +% \item \uif{Left:} 0 points +% \item \uif{Right:} 0 points +% \item \uif{First:} None, First Line, Hanging +% \item \uif{By:} 0 points +% \end{itemize} +% \item[\uif{Spacing}]\leavevmode +% \begin{itemize} +% \item \uif{Above:} 0 points +% \item \uif{Below:} 0 points +% \item \uif{Line Spacing:} Single, 1.5 Lines, Double Lines, Exactly (At: 0 points) +% \end{itemize} +%\end{description} +%\item[Link] \uif{Enter a URL for this link} +%\item[On main Properties Menu bar:] Also supported are subscript (\texttt{\penalty0}) and superscript +%(\texttt{\penalty0})\leavevmode +%\end{description} +% \subsection{The \texorpdfstring{\protect\uif{Font}}{Font} +% and \texorpdfstring{\protect\uif{Link}}{Link} tabs} +% We support the attributes seen in the above list. We further +% support subscripts, superscript, and links in this section. +% \begin{macrocode} +\newif\ifrtfontstyle\rtfontstylefalse +% \end{macrocode} +% The keys of the \texttt{rtFont} key-value family. Supported keys are \texttt{font}, \texttt{size}, \texttt{raise}, \texttt{ulstyle}, +% \texttt{color}, \texttt{url}, and \texttt{style}. Superscripts and subscripts are handled differently. +% \begin{macrocode} +% \end{macrocode} +% The \IndexKey{font}\texttt{font} key's value is a font name, if the name contains a space, it should be enclosed +% in single quotes: \texttt{font=Arial} or \texttt{font='Myriad Pro'}. +% \begin{macrocode} +\define@key{rtFont}{font}[]{\def\rt@argi{#1}\ifx\rt@argi\@empty + \let\rf@font\@empty\else\rtfontstyletrue + \def\rf@font{font-family:#1}\fi} +% \end{macrocode} +% The value of \IndexKey{size}\texttt{size} is the size of the font, as measured in points +% \texttt{font=12pt}, note the use of the entity `\texttt{pt}'. +% \begin{macrocode} +\define@key{rtFont}{size}[]{\def\rt@argi{#1}\ifx\rt@argi\@empty + \let\rf@size\@empty\else\rtfontstyletrue\def\rf@size@num{#1}% + \def\rf@size@pt{#1pt}\def\rf@size{font-size:#1pt}\fi} +\def\rf@size@num{12}\def\rf@size@pt{12pt} +% \end{macrocode} +% The key \IndexOpt{raise}\texttt{raise} corresponds to the user interface item \uif{Baseline Shift}, +% measured in points, for example, \texttt{raise=6pt}. +% \begin{macrocode} +\define@key{rtFont}{raise}[]{\def\rt@argi{#1}\ifx\rt@argi\@empty + \let\rf@raise\@empty\else\rtfontstyletrue + \def\rf@raise{vertical-align:#1pt}\fi} +% \end{macrocode} +% The key \IndexOpt{ulstyle}\texttt{ulstyle} supplies an underline attribute, for example, +% \texttt{ul=word} underlines each word in the span. +% \begin{macrocode} +\define@choicekey+{rtFont}{ulstyle}[\val\nr]% + {none,ul,2ul,wul,2wul}[none]{% + \ifcase\nr\relax + \def\rf@ul{none}\or + \def\rf@ul{underline}\or + \def\rf@ul{double}\or + \def\rf@ul{word}\or + \def\rf@ul{double word}\fi + \rtfontstyletrue +}{} +% \end{macrocode} +% The key \IndexOpt{color}\texttt{color} supplies a color attribute for the text in the span. +% There are two formats: \texttt{rrggbb} (hex) and \texttt{rgb(r,g,b)} (0-255). For example, +% \texttt{color=ff0000} or \texttt{color=rgb(255,0,0)} both color the text red. +% \begin{macrocode} +\def\rt@r{r}\let\rt@One=1 \let\rt@Zero=0 +\def\rt@parseColor#1(#2\@nil{\def\rt@argi{#2}\ifx\rt@argi\@empty +\let\rt@rgbdec\rt@Zero\else\let\rt@rgbdec\rt@One\fi} +\def\rt@gobbletonil#1\@nil{} +\bgroup\@makeother\#\@makeother\&% +\gdef\rt@hashtag{#}\gdef\rt@amp{&}\egroup +\define@key{rtFont}{color}[]{\def\rt@argi{#1}\ifx\rt@argi\@empty + \let\rf@color\@empty\else\rtfontstyletrue + \rt@parseColor#1(\@nil + \if\rt@rgbdec\rt@One + \def\rf@color{color:#1}\else + \def\rf@color{color:\rt@hashtag#1}\fi +\fi} +\let\rf@color\@empty +% \end{macrocode} +% The key \IndexOpt{url}\texttt{url} enable the rich text string to contain +% a URL hypertext link. +% \begin{macrocode} +\define@key{rtFont}{url}[]{\def\rt@argi{#1}\ifx\rt@argi\@empty + \let\rt@url\@empty\else\rtfontstyletrue\def\rt@url{#1}\fi} +% \end{macrocode} +% The \texttt{rtFontStyle} family provides keys \IndexOpt{bold}\texttt{bold}, +% \IndexOpt{italic}\texttt{italic} and \IndexOpt{strikeit}\texttt{strikeit}. +% They are possible values of the \texttt{style} key, define below. The \texttt{style} key +% can take on one or several values. +% \begin{macrocode} +\define@choicekey+{rtFontStyle}{bold}[\val\nr]{normal,bold}[bold]% + {\edef\rfS@bold{\val}}{} +\define@choicekey+{rtFontStyle}{italic}[\val\nr]{normal,italic}[italic]% + {\edef\rfS@italic{\val}}{} +\define@key{rtFontStyle}{strikeit}[]{\def\rfS@strikeit{line-through}} +\let\rfS@normal\@empty\let\rfS@bold\@empty +\let\rfS@italic\@empty\let\rfS@strikeit\@empty +% \end{macrocode} +% Continuing the \texttt{rtFont} family, the \IndexOpt{style}\texttt{style} can take on +% several values: The key-value of \texttt{style=\{bold,italic,strikeit\}} sets the text to bold, italic, +% and strike out. Multiple attributes must be enclosed in parentheses, as shown above. +% \begin{macrocode} +\define@key{rtFont}{style}[]{\def\rt@argi{#1}\ifx\rt@argi\@empty + \let\rf@style\@empty\else\rtfontstyletrue\def\rf@style{#1}\fi} +% \end{macrocode} +% We provide a \IndexKey{raw}\texttt{raw} experimental key. The value of this key is passed through; it must +% be of the proper syntax. +% \begin{macrocode} +\define@key{rtFont}{raw}[]{\def\rt@argi{#1}\ifx\rt@argi\@empty + \let\rf@raw\@empty\else\rtfontstyletrue\def\rf@raw{#1}\fi} +% \end{macrocode} +% The \DescribeMacro{\resetRtFontKeys} is an internal command to reset all keys to their default values. +% \begin{macrocode} +\def\resetRtFontKeys{% rtFont family + \let\rf@font\@empty\let\rf@size\@empty + \let\rf@raise\@empty\let\rf@ul\@empty + \let\rf@color\@empty\let\rf@style\@empty\let\rt@url\@empty + \let\rf@raw\@empty + % rtFontStyle family + \let\rfS@normal\@empty\let\rfS@bold\@empty + \let\rfS@italic\@empty\let\rfS@strikeit\@empty + \rtfontstylefalse} +% \end{macrocode} +% Now give all keys their default values. +% \begin{macrocode} +\resetRtFontKeys +% \end{macrocode} +% As we interpret the rich text string, we must save it properly formatted in both +% rich and plain format. These are macro for accumulating the strings. +% \begin{macrocode} +\newcommand{\@AddToRichText}{\g@addto@macro\rt@RichText} +\newcommand{\@AddToPlainText}{\g@addto@macro\rt@PlainText} +% \end{macrocode} +% Some utility commands +% \begin{macrocode} +\def\rt@excl{!} +\def\rt@csarg#1#2{\expandafter#1\csname#2\endcsname} +% \end{macrocode} +% \begin{macro}{\useRV} +% The \cs{useRV} command expands to the rich string defined by \cs{rtpara} and is used as the value +% of the \psf{RV} key. +% \begin{macro}{\useV} +% The \cs{useV} command expands to the plain string defined by \cs{rtpara} and is used as the value +% of the \psf{V} key. +% \begin{macrocode} +\newcommand{\useRV}[1]{\@nameuse{#1-ri}} +\newcommand{\useV}[1]{\@nameuse{#1-pl}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \DescribeMacro{\rvorvstring}\cmd{rvorvstring} is similar to \cs{texorpdfstring}, the first argument +% is a rich string while the second is a plain string. The two must match correctly, or the PDF reader +% may not display correctly; on error the reader displays the plain text. +% \begin{macrocode} +\newif\if@rvstring \@rvstringfalse +\def\rvorvstring{\if@rvstring + \expandafter\@firstoftwo + \else + \expandafter\@secondoftwo + \fi +} +% \end{macrocode} +% \paragraph*{Subscripts (\cs{sub}\DescribeMacro{\sub}) and superscripts (\cs{sup}\DescribeMacro{\sup})} There are two versions, one for rich text expansion +% and one for plain text expansion. Within \cs{rtpara} these two are \cs{let} to \cs{sub} and \cs{sup}. +% \begin{macrocode} +\def\rt@sub#1{\rvorvstring{#1}{#1}} +\def\rt@sup#1{\rvorvstring{#1}{#1}} +% \end{macrocode} +% Other supported markup: \cs{br}\DescribeMacro{\br}, \cs{bf}\DescribeMacro{\bf}, and +% \cs{it}\DescribeMacro{it}. +% \begin{macrocode} +\def\rt@br{\rvorvstring{
}{\string\r}} +\def\rt@bf#1{\rvorvstring{#1}{#1}} +\def\rt@it#1{\rvorvstring{#1}{#1}} +\def\rt@spc{\rvorvstring{\rt@amp + \rt@hashtag160\rt@SC}{ }} +% \end{macrocode} +% Some convenience commands +% \begin{macrocode} +\def\rt@SC{;}\def\rt@CN{:}\def\rt@fs{font-style}\def\rt@fw{font-weight} +\def\rt@td{text-decoration} +% \end{macrocode} +% \paragraph*{The \cs{span} command} There are two versions of the \cs{span} command, these +% are \cs{rt@remove@span} for plain text and \cs{rt@span} for rich text strings. +% \begin{macrocode} +\def\rt@remove@span#1#2{#2} +%\let\rt@remove@span\@gobble +% \end{macrocode} +% \begin{macro}{\rt@span} +% This is the internal \cs{span} command, it is \cs{let}\cs{span}\cs{rt@span}. Of course +% \cs{span} is a {\TeX} primitive, so we must be careful not to overwrite it. +% \begin{macrocode} +\def\rt@StyleAttr{\ifx\rf@font\@empty\else\rf@font\rt@SC\fi + \ifx\rf@size\@empty\else\rf@size\rt@SC\fi + \ifrt@formfield\ifx\rf@raise\@empty\else\rf@raise\rt@SC\fi\fi + \ifx\rf@ul\@empty\ifx\rfS@strikeit\@empty\else + \rt@td\rt@CN\rfS@strikeit\rt@SC\fi + \else\rt@td\rt@CN\rf@ul\ifx\rfS@strikeit\@empty\else\space + \rfS@strikeit\fi\rt@SC\fi + \ifx\rfS@bold\@empty\else\rt@fw\rt@CN\rfS@bold\rt@SC\fi + \ifx\rfS@italic\@empty\else\rt@fs\rt@CN\rfS@italic\rt@SC\fi + \ifx\rf@color\@empty\else\rf@color\rt@SC\fi + \ifx\rf@raw\@empty\else\rf@raw\fi} +% \end{macrocode} +% The \DescribeMacro{\span}\cs{span} is let to \cs{rt@span} within the \cs{rtpara} command. +% \changes{v1.0c}{2016/10/03}{Added \string\cs{rt@afterFont} to allow access by \string\pkg{annot\_pro}.} +% \begin{macrocode} +\let\rt@afterFont\relax +\newcommand\rt@span[2]{\resetRtFontKeys + \edef\x{\noexpand\setkeys{rtFont}{#1}}\x\rt@afterFont + \edef\x{\noexpand\setkeys{rtFontStyle}{\rf@style}}\x + \edef\rt@Style@ttr{\rt@StyleAttr}% + \ifx\rt@url\@empty +% \end{macrocode} +% We are processing a regular \cs{span}. +% \begin{macrocode} + \ifx\rt@StyleAttr\@empty\def\x{#2}\else + \edef\x{#2}\fi + \else +% \end{macrocode} +% We are processing a \cs{span} with the \texttt{url} key set. +% \begin{macrocode} + \ifx\rt@StyleAttr\@empty\edef\x{#2}\else + \edef\x{#2\fi}\fi + \fi +} +% \end{macrocode} +% \end{macro} +% \subsection{The \texorpdfstring{\protect\uif{Paragraph}}{Paragraph} tab} +% We now come to the \cs{rtpara} command, which sets the attributes of the \uif{Paragraph} +% tab. +% \begin{macro}{\rtpara} +% This is how you define a rich text string, through the use of \cs{rtpara}. The command +% takes three options: (1) The optional first takes key-values just defined in the \texttt{rtFont} +% and the \texttt{rtPara} families. +%\begin{verbatim} +% halign: text-align:left|center|right|justify +% valign: text-valign:top|middle|bottom +% top is same as no text-valign attribute (vertical-align) +% Indents: +% Left: margin-left:10pt; +% Right: margin-right:10pt +% First: text-indent: 12pt (Indent) +% text-indent:-12pt; (Hanging) +% None +% Spacing > Line Spacing Line: height:18pt +% Above margin-top:11pt; Below margin-bottom:11pt; +% applies to all text in field, not individual paragraphs +% line-height: pt +% Single Space: line-height:\rt@size +% 1.5 Lines : line-height: 1.8*max(\rt@size) +% Double : line-height: 2.4*max(\rt@size) +% Exact : line-height: pt +%\end{verbatim} +%\paragraph*{Alignment} +% The \IndexKey{halign}\texttt{halign} key effects the horizontal alignment of a paragraph, choices +% are \texttt{left}, \texttt{center}, \texttt{right}, and \texttt{justify}. The default is \texttt{left}. +% \begin{macrocode} +\define@choicekey+{rtPara}{halign}[\val\nr]% + {left,center,right,justify}[left]{% + \ifcase\nr\relax + \def\rt@halign{text-align:left}\or + \def\rt@halign{text-align:center}\or + \def\rt@halign{text-align:right}\or + \def\rt@halign{text-align:justify}\fi + \rtfontstyletrue +}{} +% \end{macrocode} +% The \IndexKey{valign}\texttt{valign} seems to effect all paragraphs in the rich text field. Its value +% determines the vertical placement of the paragraphs: \texttt{top}, \texttt{middle}, and \texttt{bottom}. +% The default is \texttt{top}. +% \begin{macrocode} +\define@choicekey+{rtPara}{valign}[\val\nr]{top,middle,bottom}[top]{% + \ifcase\nr\relax + \def\rt@valign{text-valign:top}\or + \def\rt@valign{text-valign:middle}\or + \def\rt@valign{text-valign:bottom}\fi + \rtfontstyletrue +}{} +\let\rt@halign\@empty\let\rt@valign\@empty +% \end{macrocode} +%\paragraph*{Indents} +% With the \IndexKey{margleft}\texttt{margleft} and \IndexKey{margright}\texttt{margright} +% you set the left and right margins of the effected paragraph. The default is \texttt{0pt}. +% \begin{macrocode} +\define@key{rtPara}{margleft}{\def\rt@margleft{margin-left:#1pt}} +\define@key{rtPara}{margright}{\def\rt@margright{margin-right:#1pt}} +% \end{macrocode} +% The \IndexKey{indent}\texttt{indent} key sets the amount of indent of a paragraph, values +% are \texttt{none}, \texttt{first}, and \texttt{hanging}. The amount of indent is determined +% by the key \IndexKey{indentby}\texttt{indentby}, which is set to \texttt{12pt} by default. +% \begin{macrocode} +\define@choicekey+{rtPara}{indent}[\val\nr]{none,first,hanging}[none]{% + \edef\rt@indenttype{\nr}% +}{} +\define@key{rtPara}{indentby}[12]{\def\rt@indentby{#1pt}} +\let\rt@margleft\@empty\let\rt@margright\@empty +\def\rt@indenttype{0}\def\rt@indentby{12pt} +% \end{macrocode} +%\paragraph*{Spacing} +% With the \IndexKey{margtop}\texttt{margtop} and \IndexKey{margbottom}\texttt{margbottom} +% you set the space above and below a paragraph. The default is \texttt{0pt}. +% \begin{macrocode} +\define@key{rtPara}{margtop}[0]{\def\rt@margtop{#1pt}} +\define@key{rtPara}{margbottom}[0]{\def\rt@margbottom{#1pt}} +\def\rt@margtop{0pt}\def\rt@margbottom{0pt} +% \end{macrocode} +% The \IndexKey{linespacing}\texttt{linespacing} key the spacing +% lines. The default is \texttt{0pt}. Choices are \texttt{single} (spacing), +% \texttt{oneandhalf} (spacing), \texttt{double} (spacing), and \texttt{exact} (spacing). +% \begin{macrocode} +\define@choicekey{rtPara}{linespacing}[\val\nr]% + {single,oneandhalf,double,exact}[single]{%line-height + \edef\rt@linespacingtype{\nr}% + \ifcase\nr + \let\rt@linesp\@empty\or + \setlength{\@tempdima}{1.8pt*\rf@size@num}% + \edef\rt@linesp{\the\@tempdima}\or + \setlength{\@tempdima}{2.4pt*\rf@size@num}% + \edef\rt@linesp{\the\@tempdima}\or + \def\rt@linesp{\rf@size@pt}\fi +}{} +\let\rt@linesp\@empty\def\rt@linespacingtype{0} +% \end{macrocode} +% The \IndexKey{lineheight}\texttt{lineheight} key +% \begin{macrocode} +\define@key{rtPara}{lineheight}[]{\def\rt@lineheight{#1pt}} +\let\rt@lineheight\@empty +% \end{macrocode} +% More convenience definitions. +% \begin{macrocode} +\def\rtp@ti{text-indent}\def\rtp@mt{margin-top} +\def\rtp@mb{margin-bottom}\def\rtp@lh{line-height} +% \end{macrocode} +% We put the parameters all together. +% \begin{macrocode} +\def\rt@ParaAttr{% +% Alignment + \ifx\rt@halign\@empty\else\rt@halign\rt@SC\fi +\ifrt@formfield + \ifx\rt@valign\@empty\else\rt@valign\rt@SC\fi +% Indents + \ifx\rt@margleft\@empty\else\rt@margleft\rt@SC\fi + \ifx\rt@margright\@empty\else\rt@margright\rt@SC\fi + \ifcase\rt@indenttype\space\or + \rtp@ti\rt@CN\rt@indentby\rt@SC\or + \rtp@ti\rt@CN-\rt@indentby\rt@SC\fi +% Spacing + \rtp@mt\rt@CN\rt@margtop\rt@SC\rtp@mb\rt@CN\rt@margbottom\rt@SC + \ifx\rt@linesp\@empty\else + \if\rt@linespacingtype3% + \ifx\rt@lineheight\@empty + \rtp@lh\rt@CN\rt@linesp\rt@SC + \else + \rtp@lh\rt@CN\rt@lineheight\rt@SC + \fi + \else + \rtp@lh\rt@CN\rt@linesp\rt@SC + \fi + \fi +\fi +} +\begingroup +\catcode`\@=0 @catcode`@\=12 +@gdef@rtbs{\} +@endgroup +\def\rt@cs#1{\rvorvstring{\rtbs\rtbs#1}{\string\134#1}} +% \end{macrocode} +% The \DescribeMacro{\rtpara}\cmd{rtpara} takes three arguments. The first optional argument is key-value pairs +% from the \texttt{rtFont} and \texttt{rtPara} families. The second is a name this rich string. The third is the +% rich string itself, with supported markup. +% \changes{v1.0c}{2016/10/03}{Added \string\cs{rt@afterParaFont} to allow access by \string\pkg{annot\_pro}.} +% \begin{macrocode} +\let\rt@afterParaFont\relax +% \end{macrocode} +% \changes{v1.0c}{2016/10/03}{Added \string\cs{rt@dir}} +% (2016/10/03) Added the \texttt{dir} HTML attribute, default is \texttt{"ltr"}. +% \begin{macrocode} +\def\rt@dir{ dir="ltr"} +% \end{macrocode} +% \begin{macrocode} +\newcommand\rtpara[2][]{\begingroup + \setkeys{rtPara,rtFont}{#1}\rt@afterParaFont + \edef\rt@Para@ttr{\rt@ParaAttr\rt@StyleAttr}% + \global\let\rt@RichText\@empty + \global\let\rt@PlainText\@empty + \def\rt@ctrlName{#2}% +% \end{macrocode} +% Before taking the next parameter, we'll make some special definitions. +% \begin{macrocode} + \def\{{\string\{}\def\}{\string\}}% + \def\1{\string\1}\def\2{\string\2}\def\3{\string\3}% + \@makeother\$\@makeother\#\@makeother\^\@makeother\_\@makeother\~% + \@makeother\&\def\&{\rvorvstring{\string&}{\string&}}% req + \@makeother\<\def\<{\rvorvstring{\string<}{\string<}}% req + \@makeother\>\def\>{\rvorvstring{\string>}{\string>}}% + \@makeother\'\def\'{\rvorvstring{\string'}{\string'}}% + \@makeother\"\def\"{\rvorvstring{\string"}{\string"}}% + \let\cs\rt@cs + \rtpara@cont} +% \end{macrocode} +% \cs{rtpara} continues with \cs{rtpara@cont}. +% \begin{macrocode} +\def\rtpara@cont#1{% + \let\sup\rt@sup\let\sub\rt@sub + \let\br\rt@br\let\bf\rt@bf\let\it\rt@it + \let\spc\rt@spc + \let\span\rt@remove@span + \@rvstringfalse + \edef\x{#1}\expandafter\@AddToPlainText\expandafter{\x}% + \let\span\relax + \@rvstringtrue + \rtpara@i#1\span!;\endgroup} +% \end{macrocode} +% Step 1: \cs{rtpara} comes here. +% \begin{macrocode} +\def\rtpara@i#1\span#2;{\def\argii{#2}% + \g@addto@macro\rt@RichText{#1}% + \ifx\argii\rt@excl + \rt@csarg\xdef{\rt@ctrlName-ri}% + {% + \rt@RichText

% + }% + \rt@csarg\xdef{\rt@ctrlName-pl}{\rt@PlainText}% + \let\rt@next\relax + \else + \def\rt@next{\rtpara@ii#2;}% + \fi +\rt@next} +% \end{macrocode} +% Step 2: \cs{rtpara@i} comes here. +% \begin{macrocode} +\def\rtpara@ii#1#2#3;{\def\argii{#2}% + \ifx\argii\rt@excl + \let\rt@next\relax + \else + \let\span\rt@span + \let\br\rt@br\let\bf\rt@bf\let\it\rt@it +% \end{macrocode} +% We have encountered \cs{span\{\}\{\}} and we expand it appropriately. +% \begin{macrocode} + \@rvstringtrue + \span{#1}{#2}\edef\rt@tmp{\noexpand\g@addto@macro + \noexpand\rt@RichText{\x}}\rt@tmp + \rt@csarg\xdef{\rt@ctrlName-ri}% + {% + \rt@RichText

% + }% + \rt@csarg\xdef{\rt@ctrlName-pl}{\rt@PlainText}% + \let\span\relax + \def\rt@next{\rtpara@i#3;}% + \fi\rt@next} +% \end{macrocode} +% \end{macro} +% There is a special definition for \IndexKey{par}\texttt{par} and +% \IndexKey{skipline}\texttt{skipline}, these should be used between paragraphs to add +% a blank line between paragraphs. +% \begin{macrocode} +\rt@csarg\def{par-ri}{}\rt@csarg\def{par-pl}{\string\r} +\rt@csarg\def{skipline-ri}% + {

\rt@amp + \rt@hashtag160;

} +\rt@csarg\def{skipline-pl}{\string\r\space} +\def\rt@skipline{skipline} +\rt@csarg\def{br-ri}{}\rt@csarg\def{br-pl}{\string\r} +% \end{macrocode} +% \section{Documentation for the \texorpdfstring{\psf{DS}}{DS} key} +% The \psf{DS} key sets the default style. According to the JavaScript API for Acrobat reference, +% the default style supports alignment, textFont, (font family, font style, font weight), textColor, +% and textSize +%\begin{verbatim} +% /DS(font: Helvetica,sans-serif 12.0pt;text-align:left;color:#000000) +% f=this.getField("RichText") +% style=f.defaultStyle; +% style.fontFamily; +% style.fontStyle; +% style.fontWeight; +% style.textFont; +% style.alignment; +% style.textColor; +% style.textSize; +%\end{verbatim} +% \begin{macrocode} +\def\rt@DSAttr{\ifx\rf@font\@empty\else\rf@font\rt@SC\fi + \ifx\rf@size\@empty\else\rf@size\rt@SC\fi + \ifx\rf@raise\@empty\else\rf@raise\rt@SC\fi + \ifx\rf@ul\@empty\ifx\rfS@strikeit\@empty\else + \rt@td\rt@CN\rfS@strikeit\rt@SC\fi + \else\rt@td\rt@CN\rf@ul\ifx\rfS@strikeit\@empty\else\space + \rfS@strikeit\fi\rt@SC\fi + \ifx\rfS@bold\@empty\else\rt@fw\rt@CN\rfS@bold\rt@SC\fi + \ifx\rfS@italic\@empty\else\rt@fs\rt@CN\rfS@italic\rt@SC\fi + \ifx\rf@color\@empty\else\rf@color\rt@SC\fi} +% \end{macrocode} +% \begin{macro}{\useDefaultDS} +% A fixed definition for default \psf{DS}. +% \begin{macrocode} +\newcommand\useDefaultDS{font-family:Helvetica,sans-serif;% + font-size:12.0pt;font-style:normal;font-weight:normal;% + text-align:left;color:\rt@hashtag000000} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\setDefaultStyle} +%\begin{verbatim} +% \setDefaultStyle{myDS}{font=Arial,...,color=#ff0000} +%\end{verbatim} +% \begin{macrocode} +\newcommand{\setDefaultStyle}[2]{\begingroup + \edef\x{\noexpand\setkeys{rtFont}{#2}}\x + \edef\x{\noexpand\setkeys{rtFontStyle}{\rf@style}}\x + \ifx\rf@ul\@empty\else + \let\rt@ul\@empty\PackageWarning{richtext}{% + The ul key is not supported within\MessageBreak + \string\setDefaultStyle. Ignoring it}\fi + \ifx\rf@raise\@empty\else + \let\rt@raise\@empty\PackageWarning{richtext}{% + The raise key is not supported within\MessageBreak + \string\setDefaultStyle. Ignoring it}\fi + \ifx\rt@url\@empty\else\let\rf@url\@empty + \PackageWarning{richtext}{% + The url key is not supported within\MessageBreak + \string\setDefaultStyle. Ignoring it}\fi +% \end{macrocode} +% Fill in any missing essential attributes. +% \begin{macrocode} + \ifx\rf@font\@empty + \def\rf@font{font-family:Helvetica,sans-serif}\fi + \ifx\rf@size\@empty\def\rf@size{font-size:\rf@size@pt}\fi + \ifx\rf@color\@empty\def\rf@color{color:\rt@hashtag000000}\fi + \rt@csarg\xdef{#1-DS}{\rt@DSAttr}% +\endgroup} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\useDS} +% \verb!\useDS{}! +% \begin{macrocode} +\newcommand{\useDS}[1]{\@nameuse{#1-DS}} +% \end{macrocode} +% \end{macro} +% \section{Passing the rich content to \texorpdfstring{\psf{RV}}{RV} +% and \texorpdfstring{\psf{V}}{V}} +% \begin{macro}{\setRVVContent} +% |\setRVVContent{{name_1}{name_1}...{name_k}}| or |\setRVVContent{name}| +% \changes{v1.0a}{2016/09/30}{Allow \string\cs{setRVVContent} to have only one argument.} +% \begin{macrocode} +\newif\ifrt@firsttok \rt@firsttoktrue +\newif\ifrt@itsskipline \rt@itsskiplinefalse +% \end{macrocode} +% \cmd{\rt@addtoRVV} is a convenience internal command to add the name \texttt{\#1} +% both to \cs{toks0}, which holds the \psf{RV} string, and to \cs{toks2}, which holds the \psf{V} string. +% \begin{macrocode} +\def\rt@addtoRVV#1{% + \toks4={\useRV{#1}}\edef\rt@tmpRV{\the\toks0\the\toks4}% + \toks4={\useV{#1}}\edef\rt@tmpV{\the\toks2\the\toks4}% + \toks0=\expandafter{\rt@tmpRV}\toks2=\expandafter{\rt@tmpV}% +} +% \end{macrocode} +% We begin \cmd{\setRVVContent} +% \begin{macrocode} +\def\rt@testifbgroup{\@ifnextchar\bgroup + {\let\rt@nultiargs=1\rt@gobbletonil} + {\let\rt@nultiargs=0\rt@gobbletonil}} +\newcommand{\setRVVContent}[2]{\begingroup + \rt@firsttoktrue \rt@itsskiplinefalse + \rt@testifbgroup#2\@nil + \def\contName{#1}\toks0={}\toks2={}\toks4={}% + \if\rt@nultiargs1\def\rt@next{\setRVVContent@i#2;}\else + \def\rt@next{\setRVVContent@i{#2};}\fi\rt@next} +\def\setRVVContent@i#1{\def\rt@argi{#1}% + \ifx\rt@argi\rt@SC +% \end{macrocode} +% If a semi-colon (\cs{rt@SC}), we are finished. Make the definitions +% for \psf{RV} and \psf{V}, and exit. +% \begin{macrocode} + \rt@csarg\xdef{\contName-vcont}{\the\toks0}% + \rt@csarg\xdef{\contName-pcont}{\the\toks2}% + \let\rt@next\endgroup + \else +% \end{macrocode} +% See if the current argument has been declared earlier by \cs{rtpara}. +% If not, we issue a warning and ignore it. +% \begin{macrocode} + \expandafter\ifx\csname #1-ri\endcsname\relax + \PackageWarning{richtext} + {The name '#1' is not declared,\MessageBreak + will ignore it. Check the spelling}% + \def\rt@next{\setRVVContent@i}% + \else +% \end{macrocode} +% We want to automatically induce \texttt{par} between non-\texttt{lineskip} +% tokens. The automatic \texttt{par} goes in prior to the token, so we first +% skip the first token. +% \begin{macrocode} + \ifrt@firsttok\rt@firsttokfalse\else +% \end{macrocode} +% Not the first token, see if it is a \texttt{skipline}, if yes, register it +% as a skip line for the next token. +% \begin{macrocode} + \ifx\rt@argi\rt@skipline + \rt@itsskiplinetrue + \else +% \end{macrocode} +% If the previous token was a \texttt{skipline}, we don't induce a \texttt{par}. +% \begin{macrocode} + \ifrt@itsskipline + \rt@addtoRVV{br}\rt@itsskiplinefalse + \else +% \end{macrocode} +% Finally, if this is not a \texttt{skipline}, and the previous token is not a \texttt{skipline}, +% we induce a \texttt{par}. +% \begin{macrocode} + \rt@addtoRVV{par}% + \fi + \fi + \fi + \rt@addtoRVV{#1}% + \def\rt@next{\setRVVContent@i}% + \fi + \fi\rt@next +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\useRVContent} +% \verb!\useRVConent{}! +% \begin{macro}{\useVContent} +% \verb!\useVConent{}! +% \begin{macrocode} +\def\useRVContent#1{\@nameuse{#1-vcont}} +\def\useVContent#1{\@nameuse{#1-pcont}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \begin{macrocode} +%
+% \end{macrocode} +\endinput + +% iPad +% Landscape +% w: 7.75in +% h: 5.8in diff --git a/texmf-dist/source/latex/richtext/richtext.ins b/texmf-dist/source/latex/richtext/richtext.ins new file mode 100644 index 00000000..6d01d8e1 --- /dev/null +++ b/texmf-dist/source/latex/richtext/richtext.ins @@ -0,0 +1,60 @@ +%% +%% This file will generate fast loadable files and documentation +%% driver files from the doc files in this package when run through +%% LaTeX or TeX. +%% +%% Copyright 1999-2016 D. P. Story +%% +%% This file is part of the `AcroTeX eDucation Bundle'. +%% ------------------------------------------- +%% +%% It may be distributed under the conditions of the LaTeX Project Public +%% License, either version 1.2 of this license or (at your option) any +%% later version. The latest version of this license is in +%% http://www.latex-project.org/lppl.txt +%% and version 1.2 or later is part of all distributions of LaTeX +%% version 1999/12/01 or later. +%% +%% --------------- start of docstrip commands ------------------ +%% +\def\filedate{2012/01/22} +\def\batchfile{richtext.ins} + +\input docstrip +\ifx\generate\undefined + \Msg{**********************************************} + \Msg{*} + \Msg{* This installation requires docstrip} + \Msg{* version 2.4 or later.} + \Msg{*} + \Msg{* An older version of docstrip has been input} + \Msg{*} + \Msg{**********************************************} + \errhelp{Move or rename old docstrip.tex and get a newer one.} + \errmessage{Old docstrip in input path} + \batchmode + \csname @@end\endcsname\end +\fi + +\keepsilent +\askforoverwritefalse +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\preamble +\endpreamble + +\generate +{% + \file{richtext.sty}{\from{richtext.dtx}{copyright,package}} +} + +\Msg{***************************************************************} +\Msg{*} +\Msg{* \space To finish the installation you have to copy the files } +\Msg{*} +\Msg{* \space *.sty, *.cfg and *.def into a directory searched by TeX} +\Msg{*} +\Msg{***************************************************************} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\endinput diff --git a/texmf-dist/source/latex/yt4pdf/doc/yt4pdf_man.pdf b/texmf-dist/source/latex/yt4pdf/doc/yt4pdf_man.pdf new file mode 100644 index 00000000..5b0bbca6 Binary files /dev/null and b/texmf-dist/source/latex/yt4pdf/doc/yt4pdf_man.pdf differ diff --git a/texmf-dist/source/latex/yt4pdf/doc/yt4pdf_man.tex b/texmf-dist/source/latex/yt4pdf/doc/yt4pdf_man.tex new file mode 100644 index 00000000..97febc04 --- /dev/null +++ b/texmf-dist/source/latex/yt4pdf/doc/yt4pdf_man.tex @@ -0,0 +1,737 @@ +% makeindex < aebpro_man.idx > aebpro_man.ind +\documentclass{article} +\usepackage[fleqn]{amsmath} +\usepackage[ + web={centertitlepage,designv,tight*,usetemplates, + forcolorpaper,latextoc,pro},%usesf, + eforms,aebxmp +]{aeb_pro} +%\usepackage{multicol} +\usepackage{aeb_mlink} +\usepackage{array} +\usepackage[altbullet]{lucidbry} + +\usepackage{makeidx} +\makeindex +\usepackage{acroman} + +\usepackage[active]{srcltx} + +\def\expath{../examples} + +\urlstyle{rm} +\def\pkg{\textsf} +\let\app\textsf +\let\opt\texttt +\let\uif\textsf +\let\env\texttt +\def\meta#1{\textit{\texttt{#1}}} +\def\ameta#1{$\langle\textit{\texttt{#1}}\rangle$} +\newdimen\aebdimen \aebdimen6pt %\partopsep \advance\aebdimen\partopsep +\newcommand\bVerb[1][]{\begingroup#1\vskip\aebdimen\parindent0pt}% +\def\eVerb{\vskip\aebdimen\endgroup\noindent} +\def\SUB#1{\ensuremath{{}_{\text{#1}}}} +\def\darg#1{\texttt{\{#1\}}} +\def\takeMeasure{\bgroup\obeyspaces\takeMeasurei} +\def\takeMeasurei#1{\global\setbox\webtempboxi\hbox{\ttfamily#1}\egroup} +\def\bxSize{\wd\webtempboxi+2\fboxsep+2\fboxrule} +\let\amtIndent\leftmargini +\makeatletter +\def\setDisplayNumber#1#2{\kern0pt + \setlength\abovedisplayshortskip{0pt}% + \setlength\belowdisplayshortskip{0pt}% + \setlength\abovedisplayskip{0pt}% + \setlength\belowdisplayskip{0pt}% + \begin{equation}\label{#2}\end{equation}\kern0pt +} +\renewenvironment{quote}[1][] + {\def\@rgi{#1}\ifx\@rgi\@empty + \let\rghtm\@empty\else\def\rghtm{\rightmargin\leftmargin}\fi + \list{}{\rghtm} %{\rightmargin\leftmargin}% + \item\relax} + {\endlist} +\renewcommand*\descriptionlabel[1]{\hspace\labelsep + \normalfont #1} +\setcounter{secnumdepth}{4} +\setcounter{tocdepth}{5} +\renewcommand*{\theparagraph}{\texorpdfstring{\protect\P\protect\ }{\textparagraph}} +\renewcommand{\paragraph} + {\renewcommand{\@seccntformat}[1]{\theparagraph}% + \@startsection{paragraph}{4}{0pt}{6pt}{-3pt}{\color{\aeb@subsubsectioncolor}\bfseries}} +\renewcommand*\l@paragraph{\@dottedtocline{4}{5.0em}{1em}} %{7.0em}{4.1em}} +\def\chgCurrLblName#1{\def\@currentlabelname{#1}} +\def\echgCurrLblName#1{\edef\@currentlabelname{#1}} +\makeatother + + +\newcommand{\YouTube}{\textsf{YouTube}} + + +%\def\tutpath{doc/tutorial} +%\def\tutpathi{tutorial} + +\DeclareDocInfo +{ + university={\AcroTeX.Net}, + title={The \texorpdfstring{\textsf{yt4PDF} Package\\[1em]}{: } + Playing \texorpdfstring{\YouTube}{YouTube} Videos in PDF}, + author={D. P. Story}, + email={dpstory@acrotex.net}, + subject={Playing YouTube Videos in PDF}, + talksite={\url{www.acrotex.net}}, + version={1.1, 2016/10/04}, + keywords={AcroTeX, PDF, YouTube, rmannot}, + copyrightStatus=True, + copyrightNotice={Copyright (C) \the\year, D. P. Story}, + copyrightInfoURL={http://www.acrotex.net} +} + +\def\dps{$\hbox{$\mathfrak D$\kern-.3em\hbox{$\mathfrak P$}% + \kern-.6em \hbox{$\mathcal S$}}$} + +\universityLayout{fontsize=Large} +\titleLayout{fontsize=LARGE} +\authorLayout{fontsize=Large} +\tocLayout{fontsize=Large,color=aeb} +\sectionLayout{indent=-40pt,fontsize=large,color=aeb} %,afterskip=1sp} +\subsectionLayout{indent=-20pt,color=aeb} %,afterskip=1sp} +\subsubsectionLayout{indent=0pt,color=aeb} %,afterskip=1sp} +\subsubDefaultDing{\texorpdfstring{$\bullet$}{\textrm\textbullet}} + +\newenvironment{eqComments}[1][\strut]{\smallskip\leftskip-\labelwidth +\item[]\textbf{\textcolor{blue}{#1}}}{\par\smallskip} + +%\pagestyle{empty} +%\parindent0pt\parskip\medskipamount + +\chngDocObjectTo{\newDO}{doc} +\begin{docassembly} +var titleOfManual="The yt4pdf MANUAL"; +var manualfilename="Manual_BG_Print_yt4pdf.pdf"; +var manualtemplate="Manual_BG_Brown.pdf"; // Blue, Green, Brown +var _pathToBlank="C:/Users/Public/Documents/ManualBGs/"+manualtemplate; +var doc; +var buildIt=false; +if ( buildIt ) { + console.println("Creating new " + manualfilename + " file."); + doc = \appopenDoc({cPath: _pathToBlank, bHidden: true}); + var _path=this.path; + var pos=_path.lastIndexOf("/"); + _path=_path.substring(0,pos)+"/"+manualfilename; + \docSaveAs\newDO ({ cPath: _path }); + doc.closeDoc(); + doc = \appopenDoc({cPath: manualfilename, oDoc:this, bHidden: true}); + f=doc.getField("ManualTitle"); + f.value=titleOfManual; + doc.flattenPages(); + \docSaveAs\newDO({ cPath: manualfilename }); + doc.closeDoc(); +} else { + console.println("Using the current "+manualfilename+" file."); +} +var _path=this.path; +var pos=_path.lastIndexOf("/"); +_path=_path.substring(0,pos)+"/"+manualfilename; +\addWatermarkFromFile({ + bOnTop:false, + bOnPrint:false, + cDIPath:_path +}); +\executeSave(); +\end{docassembly} + +\begin{document} + +\maketitle + +\selectColors{linkColor=black} +\tableofcontents +\selectColors{linkColor=webgreen} + +\section{Introduction}\label{s:intro} + + I believe that I was vaguely aware of the \href{http://code.google.com/apis/youtube/flash_api_reference.html} +{{\YouTube} ActionScript 3.0 Player},\footnote{The YouTube AcrionScript 2.0 Player API + has been deprecated as of January 27, 2015; however, it is still supported, for now.} but never pursued it because of my +general lack of interest in {\YouTube} (\url{www.youtube.com}). Recently, I +came across a very nice demo PDF that used the API, see +%\mlhref{http://www.uvsar.com/pdftube/}{PDF Tube - {\YouTube} API wrapper for PDF documents}. +``PDF Tube - {\YouTube} API wrapper for PDF documents'' (the page has +since been removed). +The SWF file and JavaScript are made freely available, so I +downloaded it, and was sufficiently impressed to port the example to +{\LaTeX} using various members of the {Acro\negthinspace\TeX} Fine Family of Software +\verb!:-{)!. The SWF file and JavaScript are due to the good folks at +\textbf{UVSAR} (\url{www.uvsar.com}). The \textbf{UVSAR}'s sample demo also appeared in the forums of +the \href{http://acrobatusers.com/forum/javascript/embed-youtube-video-pdf}{Acrobat User +Community}. + +The \textsf{yt4pdf} package uses the \textsf{rmannot} to embed the \textsf{SWF} +file that plays the {\YouTube} videos. There is a complete set of buttons +that come with the package to control the video: play, pause, stop +loading, rewind, load a video by its {\YouTube} video ID, and a button to +view a video on the {\YouTube} web site.\footnote{Some videos do not allow +embedded playback, and must be viewed on the {\YouTube} web site.} + +% http://acrobatusers.com/news/youtube-widget-acrobat + +\subsection{Sample files} + +The following are the sample files shipped with \textsf{yt4pdf}: +\begin{itemize} + \item \texttt{yt4pdf-1.tex} demonstrates the basic functionality of + the {\YouTube} RMA: the use of the poster, including \cs{ytComboList}, + \cs{ytComboBtn}, and \cs{ytvId}. + \item \texttt{yt4pdf-2.tex} experiments with different ways the + {\YouTube} annotation can be displayed + \begin{itemize} + \item As a small icon, videos are played in a floating window, + buttons displayed in the running footer. + \item[] This one uses a rollover, popup menu system (as opposed to + a combo box). The \textsf{popupmenu} package is used. + \item Using a built-in poster, with the combo box under the + annotation, control buttons in running footer. + \item Same as above, but control buttons moved to a two column + format. + \item Using the custom {\YouTube} for PDF poster with combo box and + control buttons under the RMA. + \end{itemize} + \item \texttt{yt4pdf-3.tex} illustrates the usage of the \texttt{play} and \texttt{load} + keys that are passed in the optional parameter of \cs{ytRmAnnot}. +\end{itemize} +% Advanced examples \href{http://www.math.uakron.edu/~dpstory/aebblog.html}{AeB Blog site}. + +\section{Requirements} + +This package is part of \textsf{AeB Pro}, which means Acrobat Distiller is +used to create the PDF; the package requires \textsf{rmannot}, which +creates rich media annotations. Therefore, we require +\begin{equation*} + \boxed{\text{\large\bfseries Adobe Acrobat, version 9.0 or later}} +\end{equation*} +To use this package, the document author must have AeB and AeB Pro +installed, as well as \textsf{rmannot}. The manual for \textsf{rmannot} +needs to be read closely to properly install it and to function correctly. +I have made \textsf{rmannot} a required package, and recently +have made the \textsf{popupmenu} package required as well. + +\section{Configuring your installation} + +In addition to configuring the \textsf{rmannot} package correctly, the +\textsf{yt4pdf} package needs configuring as well. The \textsf{yt4pdf} package +comes with a configuration file \texttt{yt4pdf.cfg}. Open this file in +your favorite editor to see +\begin{Verbatim}[fontsize=\small] +% yt4pdf config file. Delete the \endinput below and replace the path +% provided with the path to the swf folder of your yt4pdf installation. +% This path is used to locate the pdf_tube_basic.swf file, used to play +% YouTube videos. +\endinput +\renewcommand{\ytFolder}{C:/Users/Public/Documents/My TeX Files/% +tex/latex/aeb/aebpro/yt4pdf/swf} +\end{Verbatim} +Edit this file so that \cs{ytFolder} points to the \texttt{swf} folder on +your computer. + +\section{The Rich Mediation Annotation for {\YouTube}} + +The Rich Media Annotation (RMA) used is \cs{ytRmAnnot}, its definition +uses the command \cs{rmAnnot}, which is defined in the \textsf{rmannot} package. +\bVerb\takeMeasure{\string\ytRmAnnot[\ameta{KV-pairs}]\darg{\ameta{name}}\darg{\ameta{width}}\darg{\ameta{height}}}% +\begin{minipage}{\linewidth} +\begin{minipage}{\bxSize} +\xdef\panelWidth{\the\linewidth}% +\begin{Verbatim}[frame=single,commandchars=!(),rulecolor=\color{red}] +\ytRmAnnot[!ameta(KV-pairs)]{!ameta(name)}{!ameta(width)}{!ameta(height)} +\end{Verbatim} +\end{minipage}\hfill +\begin{minipage}{\linewidth-\panelWidth} +\setDisplayNumber\label{display:ytRmAnnot} +\end{minipage}\end{minipage}\endgroup +\PD +\begin{enumerate} + \item The first (optional) parameter is used to pass the key-value pairs of the + \cs{rmAnnot} command. Additionally, there are two other \ameta{KV-pairs} + recognized, specialized to the \cs{ytRmAnnot} command. + \begin{itemize} + \item \texttt{play=\ameta{vID}} Loads and plays the {\YouTube} video with + video ID of \ameta{vID}. + \item \texttt{load=\ameta{vID}} Loads the specified video's thumbnail + (as specified by \ameta{vID}) and prepares the player to play + the video. The player does not request the \textsf{FLV} until the play + button is pressed. + \end{itemize} + When you want to play a {\YouTube} video when the page containing + the annotation is opened, use the \texttt{play} key; for example + \texttt{play=GZ9e3Dy7obA} causes the video whose video ID is + \texttt{GZ9e3Dy7obA} to play when the page is opened. + + See the manual for the \pkg{rmannot} package for more details on the + key-value pairs that can be passed through the optional first + parameter. + + \item The \ameta{name} parameter is a name used to refer to the + annotation through underlying JavaScript code. The \ameta{name} + should consist of only letters and numbers. The value of this + parameter is placed in the macro \cs{ytCurrRMAName}. This macro is + used internally by the various control buttons. + + \item The width of the annotation. + + \item The height of the annotation. +\end{enumerate} + +\paragraph*{Annot Dimensions.} +The width and height of the {\YouTube} annotation should be \texttt{571bp} +and \texttt{330bp}, respectively, or any re-scaling of these dimensions. + +Examples, +\begin{Verbatim} + \ytRmAnnot[posternote=AcroTeX PDF Tube,play=eNzrn8-JFSE, + deactivated=pageclose]{YouTube1}{571bp}{330bp} +\end{Verbatim} +is a ``full-size'' annotation, while +\begin{Verbatim} + \ytRmAnnot[posternote=AcroTeX PDF Tube,load=eNzrn8-JFSE, + deactivated=pageclose]{YouTube1}{571bp/2}{330bp/2} +\end{Verbatim} +is half that size. The first example above plays a video when +the page is opened, the second example loads the thumbnail, and waits play +the video. + +You can also re-scale using either \cs{resizebox} or +\cs{scalebox} from the \textsf{graphicx} package. +\begin{Verbatim} + \resizebox{2in}{!}{\ytRmAnnot[posternote=AcroTeX PDF Tube, + deactivated=pageclose]{YouTube1}{571bp}{330bp}} +\end{Verbatim} +or, using \cs{scalebox}, +\begin{Verbatim} + \scalebox{.5}{\ytRmAnnot[posternote=AcroTeX PDF Tube, + deactivated=pageclose]{YouTube1}{571bp}{330bp}} +\end{Verbatim} + +\textbf{Running multiple videos at once.} At the time of this writing, the +\pkg{yt4pdf} package is not designed to run more than one video at a +time, that's not saying it cannot be done, however. It is not recommended, +indeed, why would you want to look at two {\YouTube} videos at the same +time? + +For documents with multiple {\YouTube} annotations over +several pages it is recommended, therefore, that the \texttt{deactivated=pageclose} +should be used in the optional parameter list of the \cs{ytRmAnnot} +command. + +\subsection{The \texorpdfstring{\protect\textsf{yt4pdf}}{yt4pdf} Poster} + +The \textsf{rmannot} package provides a standard poster (a gray rectangle +with text in the lower left corner). However, there is an especially +designed poster, designed by the folks at \textbf{UVSAR}. (See +Figure~\ref*{pdfytPoster}, page~\pageref*{pdfytPoster}.) + +\begin{figure}[htb] +\begin{center} + \includegraphics[scale=.5]{./graphics/pdfyt_poster}\\ + \caption{YouTube for PDF poster}\label{pdfytPoster} +\end{center} +\end{figure} + +\goodbreak +\textbf{To use this really cool poster:} +\begin{enumerate} + \item Insert the following line into the preamble, +\begin{Verbatim}[fontsize=\small] + \makePoster[bb=0 0 570.794 329.887]{pdfyt_poster}{pdfyt_poster} +\end{Verbatim} +The optional parameter should remain as it is, it adjusts the bounding +box so that the poster is properly placed. + +\item Use the \texttt{poster} key in the first optional parameter of +\cs{ytRmAnnot}, like so, +\begin{Verbatim} + \ytRmAnnot[poster=pdfyt_poster, + deactivated=pageclose]{YouTube}{571bp}{330bp}} +\end{Verbatim} +\end{enumerate} + +\subsection{Control Buttons} + +The {\YouTube} rich media annotation (as created by \cs{ytRmAnnot}), comes +with six (optional) control buttons. +\bVerb\takeMeasure{\string\ytSelect[\ameta{KV-pairs}]\darg{\ameta{vID}}\darg{\ameta{width}}\darg{\ameta{height}}}% +\begin{minipage}{\bxSize} +\begin{Verbatim}[frame=single,commandchars=!(),rulecolor=\color{red}] +\ytPlayToggle[!ameta(KV-pairs)]{!ameta(width)}{!ameta(height)} +\ytStopLoading[!ameta(KV-pairs)]{!ameta(width)}{!ameta(height)} +\ytMuteToggle[!ameta(KV-pairs)]{!ameta(width)}{!ameta(height)} +\ytRewind[!ameta(KV-pairs)]{!ameta(width)}{!ameta(height)} +\ytSelect[!ameta(KV-pairs)]{!ameta(vID)}{!ameta(width)}{!ameta(height)} +\ytOpenWeb[!ameta(KV-pairs)]{!ameta(width)}{!ameta(height)} +\end{Verbatim} +\end{minipage}\endgroup +\PD The labels are self-explanatory, the \texttt{} parameter is +the standard \textsf{eforms} optional parameter for changing the +appearance of the form. The \ameta{vID} parameter for \cs{ytSelect} is +a {\YouTube} video ID. + +\goodbreak +\CmdDescription We give brief descriptions of each of the six control +buttons. +\begin{itemize} + \item \cs{ytPlayToggle}: + This button has several functions, \textsf{PAUSE}, \textsf{PLAY}, \textsf{BUFFERING}, and \textsf{REPLAY}. + Initially the button label is on \textsf{PAUSE} (pressing it pauses a playing video); + the button label reads \textsf{PLAY} when the video is loaded and paused (pressing it plays or resumes + the video); while the video is loading, the button label is + \textsf{BUFFERING\dots}. After the video finishes playing, the button + label is changed to \textsf{Replay}. + \item \cs{ytStopLoading}: Pressing this button stops the streaming of the currently playing + video. If the video is started again, there will be some buffering before the play begins. + \item \cs{ytMuteToggle}: This button toggles and sound off and on. Button labels are + \textsf{MUTE} and \textsf{UNMUTE}. + \item \cs{ytRewind}: If the video is playing, this button + stops the video, rewinds it to the beginning, and starts play again. If the video + is paused, this button rewinds the video to the beginning, the video remains paused. + \item \cs{ytSelect}: When this button is pressed, a response dialog opens. + The user enters a {\YouTube} video ID into the field. On pressing OK, this video is played. + + \item[] The second parameter \ameta{vID} is the default video + that is displayed in the input box of the response box that opens. + \item[] \textbf{Note:} Some {\YouTube} videos are security + restricted and cannot be played through an embedded player, such as the one used here. + If video ID of a video that does not allow embedded playback, a dialog appears giving + the user the opportunity to view the video on the web. + \item \cs{ytOpenWeb}: The user has the option of pressing this button to view the + current video on the web at \texttt{www.youtube.com}. +\end{itemize} + +The first (optional) parameter can be used to modify the appearance of the +individual buttons. To modify the appearances of the buttons as a group, +use, +\bVerb\takeMeasure{\string\ytBtnPresets\darg{\ameta{KV-pairs}}}% +\begin{minipage}{\bxSize} +\begin{Verbatim}[frame=single,commandchars=!(),rulecolor=\color{red}] +\ytBtnPresets{!ameta(KV-pairs)} +\end{Verbatim} +\end{minipage}\eVerb +The key-value pairs are ones defined for form fields created by the \textsf{eforms} +package. The default definition is, +\begin{Verbatim}[xleftmargin=\amtIndent] +\ytBtnPresets{\BC{.5 0 0}\S{S}\textFont{HeBo}} +\end{Verbatim} + +The second parameter of \cs{ytRmAnnot} is the name to be associated with +that annot; the name of the annot is not known until after the annot is +defined. The command \cs{DeclareYTName}, +\bVerb\takeMeasure{\string\DeclareYTName\darg{\ameta{name}}}% +\begin{minipage}{\bxSize} +\begin{Verbatim}[frame=single,commandchars=!(),rulecolor=\color{red}] +\DeclareYTName{!ameta(name)} +\end{Verbatim} +\end{minipage}\eVerb +allows you to define the name prior to the creation of the annot. This is +useful if you want to place the control buttons above the annot itself. By +specifying the name, the control buttons will know the name of the annot +they are to control. + +\subsection{Controls for playing a {\YouTube} video} + +To actually play a video, you must pass a video ID to the underlying SWF +file. We present two methods here, through links and through a combo box. +One of the example files, \texttt{yt4pdf-2.pdf}, illustrates another method +using a popup menu. + +\subsubsection{Playing a video through a link} + +The command \cs{ytvId} creates a list such that when you click on it, the +video specified by the second parameter of the command is played in the +associated Rich Media annotation created by \cs{ytRmAnnot}. The associated +RMA is the one most recently defined prior to the link. If the link occurs +before the target RMA, you can use \cs{DeclareYTName} to set the name of +the target RMA for the link. +\bVerb\takeMeasure{\string\ytvId[\ameta{KV-pairs}]\darg{\ameta{vID}}\darg{\ameta{text}}}% +\begin{minipage}{\bxSize} +\begin{Verbatim}[frame=single,commandchars=!(),rulecolor=\color{red}] +\ytvId[!ameta(KV-pairs)]{!ameta(vID)}{!ameta(text)} +\end{Verbatim} +\end{minipage}\endgroup +\PD The first parameter takes the usual key-value pairs for links created +by the \textsf{eforms} package. The second parameter is the video ID to be +played. The third parameter is the text to be displayed by the link, +usually the title of the {\YouTube} video. + +\cs{ytvId} loads and plays the specified video; there is an +\texttt{*}-form of this command, +\bVerb\takeMeasure{\string\ytvId*[\ameta{KV-pairs}]\darg{\ameta{vID}}\darg{\ameta{text}}}% +\begin{minipage}{\bxSize} +\begin{Verbatim}[frame=single,commandchars=!(),rulecolor=\color{red}] +\ytvId*[!ameta(KV-pairs)]{!ameta(vID)}{!ameta(text)} +\end{Verbatim} +\end{minipage}\eVerb +When this form is used, the {\YouTube} thumbnail image for the video is +displayed. The player does not +request the video until the play button is pressed. + +You can set the appearances for a all links created by \cs{ytvId} by using +\cs{ytvIdPresets} +\bVerb\takeMeasure{\string\ytvIdPresets\darg{\ameta{KV-pairs}}}% +\begin{minipage}{\bxSize} +\begin{Verbatim}[frame=single,commandchars=!(),rulecolor=\color{red}] +\ytvIdPresets{!ameta(KV-pairs)} +\end{Verbatim} +\end{minipage}\eVerb +The key-value pairs are ones defined for form fields created by the \textsf{eforms} +package. The default definition is +\begin{Verbatim}[xleftmargin=\amtIndent] +\ytvIdPresets{\linktxtcolor{webbrown}} +\end{Verbatim} + +\subsubsection{Playing a video using a combo box} + +You can created a combo box with a play list. There are three commands +that create the combo list, \cs{ytPlayList}, \cs{ytComboList}, and +\cs{ytComboBtn}. +\bVerb\takeMeasure{\string\ytPlayList\darg{\ameta{default\_vId}}\darg{\ameta{playlist}}}% +\begin{minipage}{\bxSize} +\begin{Verbatim}[frame=single,commandchars=!(),rulecolor=\color{red}] +\ytPlayList{!ameta(default_vId)}{!ameta(playlist)} +\end{Verbatim} +\end{minipage}\eVerb +This command sets the play list to be displayed in the combo box, it needs +to be executed before the actual creation of the combo box (using +\cs{ytComboList}). The first parameter is the default video ID, this title +will be initially displayed by the combo box. The \ameta{playlist} is +an array of video IDs and title pairs. The \ameta{playlist} is conveniently defined +within the \cs{declarePlayList} command: +\bVerb\takeMeasure{\string\declarePlayList\darg{\ameta{\cs{plCmd}}}\{\%}% +\begin{minipage}{\bxSize} +\begin{Verbatim}[frame=single,commandchars=!(),rulecolor=\color{red}] +\declarePlayList{!ameta(\plCmd)}{% + !ameta(array-of-vIDs-titles) +} +\end{Verbatim} +\end{minipage}\eVerb The array of video IDs and title pairs are saved under the command name \ameta{plCmd}. +For example +\begin{Verbatim}[xleftmargin=\amtIndent,fontsize=\small] +\declarePlayList{\playList}{% + [(GZ9e3Dy7obA)(Kung-Fu Fighting {(Bruce Lee version)})] + [(eNzrn8-JFSE)(Open at Adobe)] + [(5y9-EVmreU4)(Lori's Corner: Episode \#1)] +} +\end{Verbatim} +The format for each pair is \texttt{[(\ameta{vId})(\ameta{title})]}. Notice that in the case +of the Bruce Lee video, the title itself contains parentheses; to avoid parsing errors when +the \pkg{eforms} package builds the combo box, \emph{enclose these parentheses in a pair of matching braces}. + +In the example above, the array, in its correct format, is loaded +conveniently into a macro \cs{playList} declared through \cs{declarePlayList}. The macro may then be passed as the +second parameter of \cs{ytPlayList}. Thus, an example of the use of +\cs{ytPlayList} is +\begin{Verbatim}[xleftmargin=\amtIndent] +\ytPlayList{eNzrn8-JFSE}{\playList} +\end{Verbatim} + +There is a convenience command, \cs{ytIdTitle}, that is used to build +a \cs{ytPlayList}. +\bVerb\takeMeasure{\string\ytIdTitle\darg{\ameta{vId}}\darg{\ameta{title}}}% +\begin{minipage}{\bxSize} +\begin{Verbatim}[frame=single,commandchars=!(),rulecolor=\color{red}] +\ytIdTitle{!ameta(vId)}{!ameta(title)} +\end{Verbatim} +\end{minipage}\eVerb +The above example can the be re-written as, +\begin{Verbatim}[xleftmargin=\amtIndent,fontsize=\small] +\declarePlayList{\playList}{% + \ytIdTitle{GZ9e3Dy7obA}{Kung-Fu Fighting {(Bruce Lee version)}} + \ytIdTitle{eNzrn8-JFSE}{Open at Adobe} + \ytIdTitle{5y9-EVmreU4}{Lori's Corner: Episode \#1} +} +\end{Verbatim} + +\paragraph*{The combo box.} The syntax for the combo box itself is +\bVerb\takeMeasure{\string\ytComboList[\ameta{KV-pairs}]\darg{\ameta{width}}\darg{\ameta{height}}}% +\begin{minipage}{\bxSize} +\begin{Verbatim}[frame=single,commandchars=!(),rulecolor=\color{red}] +\ytComboList[!ameta(KV-pairs)]{!ameta(width)}{!ameta(height)} +\end{Verbatim} +\end{minipage}\eVerb +The \cs{ytComboList} is a combo box of video Ids and titles. The user +selects a video based on its title, then presses the \textsf{PLAY} button +(see \cs{ytComboBtn} below). This command is executed \emph{before} +\cs{ytComboBtn} to set the play list, and the default value. +\PD\begin{itemize} + \item \ameta{KV-pairs}: (optional) The key-value pairs associated with an + \textsf{eforms} form field, used to change the appearance of the field. + \item \ameta{width}: The width of the combo box + \item \ameta{height}: The height of the combo box +\end{itemize} +The appearance can be changed locally by the optional first parameter. The +command \cs{ytComboListPresets} is used to change all combo lists create +by \cs{ytComboList}. The command takes has one parameter, the key-value +pairs for changing the appearance. The default definition is +\verb!\ytComboListPresets{}!. + +Originally, I visualized only one combo box per page, recently that +mind-set has changed. Should you want several combo boxes, as created by +\cs{ytComboList}, each box must have a unique name. To that end +\bVerb\takeMeasure{\string\ytNewBaseName[\ameta{name}]}% +\begin{minipage}{\bxSize} +\begin{Verbatim}[frame=single,commandchars=!(),rulecolor=\color{red}] +\ytNewBaseName[!ameta(name)] +\ytResetBaseName +\end{Verbatim} +\end{minipage}\eVerb +The first command, \cs{ytNewBaseName}, has one optional parameter, if no +parameter is supplied, then a base name will be generated; otherwise, +the title of the combo box will be based on the \ameta{name} passed to +it. For the command \cs{ytResetBaseName}, the first command effects the JS +and the field name of \cs{ytComboBtn} described below. +\begin{Verbatim}[xleftmargin=\amtIndent,fontsize=\small,commandchars=!()] +\begin{itemize} +\item \ytNewBaseName\relax\ytPlayList{!ameta(default_Id)}{\playListii}% + \ytComboList{2.5in}{11bp}\kern1bp\ytComboBtn{33bp}{11bp} +\item \ytNewBaseName[Listiii]\ytPlayList{!ameta(default_Id)}{\playListiii}% + \ytComboList{2.5in}{11bp}\kern1bp\ytComboBtn{33bp}{11bp} +\end{itemize} +\end{Verbatim} +\textbf{\textcolor{red}{Note:}} Because \cs{ytNewBaseName} has an optional +argument, you should place a \cs{relax} after \cs{ytNewBaseName} to prevent +premature expansion of the \cs{ytplayList} command that follows. + +\newtopic Once the selection has been made from the combo box, the user +can play the selection by pressing the button created by \cs{ytComboBtn}. +\bVerb\takeMeasure{\string\ytComboBtn[\ameta{KV-pairs}]\darg{\ameta{width}}\darg{\ameta{height}}}% +\begin{minipage}{\bxSize} +\begin{Verbatim}[frame=single,commandchars=!(),rulecolor=\color{red}] +\ytComboBtn[!ameta(KV-pairs)]{!ameta(width)}{!ameta(height)} +\end{Verbatim} +\end{minipage}\eVerb +\textbf{\textcolor{red}{Note:}} If you hold down the shift key and click on +the button, the thumbnail poster is loaded, and the player is ready to +play the video. +\PD\begin{itemize} + \item \ameta{KV-pairs}: (optional) The key-value pairs associated with an + \textsf{eforms} form field, used to change the appearance of the field. + \item \ameta{width}: The width of the combo box + \item \ameta{height}: The height of the combo box +\end{itemize} +The appearance can be changed locally by the optional first parameter. The +command \cs{ytComboBtnPresets} is used to change all combo lists create +by \cs{ytComboBtn}. The command takes has one parameter, the key-value +pairs for changing the appearance. The default definition is +\verb!\ytComboBtnPresets{}!. + +\subsection{Using the \textsf{popupmenu} package} + +The \pkg{popupmenu} a required package, \pkg{yt4pdf} adds some commands and +JS to facilitate its usage. The demo file for this feature is +\texttt{yt4pdf-2.tex}, where you will find some comments in the source file. + +In the preamble, we define our menu structure, + +\begin{Verbatim}[numbers=left,xleftmargin=\leftmargini,fontsize=\fontsize{9}{11}\selectfont] +\begin{popupmenu}{YTMenu} + \puIdTitle{Select a You Tube Video}{} % A title has no yt Id + \begin{submenu}{title=Music Videos} + \puIdTitle{Ink Spots - If I didn't care}{rvwfLe6sLis} + \puIdTitle{Ink Spots - My Prayer}{h7KJCns5v3g} + \end{submenu} + \begin{submenu}{title=Adobe Related Videos} + \puIdTitle{Open at Adobe}{eNzrn8-JFSE} + \puIdTitle{Lori's Corner Episode \#1}{5y9-EVmreU4} + \puIdTitle{Intro to PDF Portfolios}{T9Yzo_hlwP0} + \end{submenu} +\end{popupmenu} +\ytPopupMenuData{\YTMenu} +\end{Verbatim} +The \cs{puIdTitle} is a convenience macro to enter the menu data; the +first argument is the title of the {\YouTube} video, the second argument +is the {\YouTube} ID. There may be several \texttt{popupmenu} environments, each +with a different name. After the last such environment, execute the +\cs{ytPopuMenuData} command, seen in line~(12). Its argument is a token +list of all popupmenus; here, we have only one. If there are several, they +are listed as follows: +\begin{Verbatim}[xleftmargin=\leftmargini] +\ytPopupMenuData{\YTMenu\myEduVids\myMusicVids} +\end{Verbatim} + +The menu is displayed as an mouse-over action of button, here is the +verbatim listing from \texttt{yt4pdf-2.tex} + +\begin{Verbatim}[numbers=left,xleftmargin=\leftmargini,fontsize=\fontsize{9}{11}\selectfont] +\DeclareYTName{ytInWindow} +... +\newcommand{\myPBPresets}{% + \CA{YT Menu}\textColor{0 0 1}\W1\BC{}\textSize{0}\S{S} + \AA{\AAMouseEnter{\JS{ytPopupMenu("\ytCurrRMAName",YTMenu)}}}} +\setWindowDimPos{% + position={halign=center,valign=center,hoffset=0,voffset=0}, + width={default=571},height={default=330}}% +\setlength{\pichskip}{3pt} +\parpic(.25in,.25in){% +\parbox{.25in}{\offinterlineskip\resizebox{.25in}{!}{% + \ytRmAnnot[windowed,poster=yt_poster,deactivated=pageclose]% + {ytInWindow}{72bp}{72bp}% +}}} +\pushButton[\presets{\myPBPresets}]{myYTMenu}{20bp}{5bp} +On this page, the You Tube annotation is icon size and the +video is played in a floating window. +\end{Verbatim} +\textbf{Comments:} +\begin{itemize} + \item In line~(1) we declare the name of the {\YouTube} annot to be + used. We do this because we need to use the name before the annot is + defined. The annot itself is not defined until line~(12). + \item Lines~(3)--(5): Define a command to be used for passing the + button attributes for the \texttt{myYTMenu} button (seen in + line~(15)). In line~(5) we define the action for the button; it is a + mouse enter action that executes the \texttt{ytPopupMenu} JS function + defined in the \texttt{yt2pdf} package. This function takes two + arguments, the first is the name of the target Rich Media Annotation + hat will display the videos, this name is \verb!"\ytCurrRMAName"!, + where \cs{ytCurrRMAName} holds the name of the most recent {\YouTube} + annotation. The second argument is the name of the menu data (defined + by the \texttt{popupmenu} environment. + \item Lines~(9)--(14): We create an annot so that it appears as an + icon, the text of the paragraph wraps around the icon. This is what we + do with the \cs{parpic} command. In lines~(12)--(13), we create the + {\YouTube} annot using \cs{ytRmAnnot}. + \item In line~(15) we have a button with a mouse rollover action. Note + we pass the earlier defined presets to this button. +\end{itemize} +See the complete source file in \texttt{yt4pdf-2.tex}. + + +\section{Language localizations} + +The default language for \textsf{yt4pdf} is English; the English strings +that \textsf{yt4pdf} uses are listed below. These can be redefined as +desired. +\begin{Verbatim} +\newcommand{\ytStrPLAY}{PLAY} +\newcommand{\ytStrREPLAY}{REPLAY} +\newcommand{\ytStrPAUSE}{PAUSE} +\newcommand{\ytStrBuffering}{Buffering...} +\newcommand{\ytStrStopLoading}{Stop Loading} +\newcommand{\ytStrMUTE}{MUTE} +\newcommand{\ytStrUNMUTE}{UNMUTE} +\newcommand{\ytStrREWIND}{REWIND} +\newcommand{\ytStrLoadVideo}{Load Video} +\newcommand{\ytStrWatchOnWeb}{Watch on YouTube} +% response dialog box associated with ytSelect() +\newcommand{\ytRespQues}{Enter the YouTube Video ID} +\newcommand{\ytRespTitle}{Load a Video} +\newcommand{\ytRespLabel}{ID:} +% alert error messages +\newcommand{\ytStrErrorVideoNotFound}{Error: Video not found} +\newcommand{\ytStrErrorNoEmbed}{Error: This video does not allow + embedded playback \r\r Would you like to view this video + on the web?} +\newcommand{\ytStrConnecTimedOut}{Connection timed out, try again.} +\end{Verbatim} + +\bigskip + +That's all for now, I simply must get back to my retirement. {\dps} + +\end{document} diff --git a/texmf-dist/source/latex/yt4pdf/examples/config_intacc.def b/texmf-dist/source/latex/yt4pdf/examples/config_intacc.def new file mode 100644 index 00000000..ac2e0f8e --- /dev/null +++ b/texmf-dist/source/latex/yt4pdf/examples/config_intacc.def @@ -0,0 +1,29 @@ +\newpage + +\begin{minipage}[t]{3in}\parindent20pt\small +\noindent\makebox[\linewidth][c]{\bfseries\normalsize\color{blue}Configuring +Preferences}\\[3pt] +To avoid the security alerts when loading FLV files from You Tube, +configure your preferences as described below. + +Start Adobe Reader 9 or later (or Acrobat~9 or later), and open the \textbf{Preferences} +dialog box (located in the menu system by selecting \textbf{Edit +\texttt{>} Preferences} or using the shortcut Ctrl+K); select +\textbf{Trust Manager} from the left-hand \textbf{Categories} panel. On +the right side of the dialog box, press the button labeled \textbf{Change +Settings}, shown below.\par\vspace*{3pt}\centering +\includegraphics[width=\linewidth]{graphics/trustmanager} +\end{minipage}\hfill +\begin{minipage}[t]{\linewidth-3in-10pt}\small +In the \textbf{Manage Internet Access}, make selections as +indicated by the red boxes.\par\medskip +\noindent\makebox[\linewidth][c]{\bfseries\normalsize\color{blue}For Version 9}\\[3pt] +\noindent\makebox[\linewidth][c]{\includegraphics[width=2in]{graphics/MIA9}}\\[3pt] +That is, select \textbf{Allow all web sites}\par\medskip +\noindent\makebox[\linewidth][c]{\bfseries\normalsize\color{blue}For Version 10}\\[3pt] +\noindent\makebox[\linewidth][c]{\includegraphics[width=2in]{graphics/MIAX}}\\[3pt] +\textbf{Allow PDF files to access all web sites}\par\medskip +Exit the dialogs, and try \textbf{YT4PDF}! +\end{minipage} + +\newpage diff --git a/texmf-dist/source/latex/yt4pdf/examples/graphics/MIA9.eps b/texmf-dist/source/latex/yt4pdf/examples/graphics/MIA9.eps new file mode 100644 index 00000000..e68a0a0b Binary files /dev/null and b/texmf-dist/source/latex/yt4pdf/examples/graphics/MIA9.eps differ diff --git a/texmf-dist/source/latex/yt4pdf/examples/graphics/MIAX.eps b/texmf-dist/source/latex/yt4pdf/examples/graphics/MIAX.eps new file mode 100644 index 00000000..71bdbbc0 Binary files /dev/null and b/texmf-dist/source/latex/yt4pdf/examples/graphics/MIAX.eps differ diff --git a/texmf-dist/source/latex/yt4pdf/examples/graphics/trustmanager.eps b/texmf-dist/source/latex/yt4pdf/examples/graphics/trustmanager.eps new file mode 100644 index 00000000..ee141a72 Binary files /dev/null and b/texmf-dist/source/latex/yt4pdf/examples/graphics/trustmanager.eps differ diff --git a/texmf-dist/source/latex/yt4pdf/examples/graphics/yt_icon_sm.eps b/texmf-dist/source/latex/yt4pdf/examples/graphics/yt_icon_sm.eps new file mode 100644 index 00000000..2e6e0ff1 Binary files /dev/null and b/texmf-dist/source/latex/yt4pdf/examples/graphics/yt_icon_sm.eps differ diff --git a/texmf-dist/source/latex/yt4pdf/examples/yt4pdf-1.tex b/texmf-dist/source/latex/yt4pdf/examples/yt4pdf-1.tex new file mode 100644 index 00000000..fac944ab --- /dev/null +++ b/texmf-dist/source/latex/yt4pdf/examples/yt4pdf-1.tex @@ -0,0 +1,93 @@ +\documentclass{article} +\usepackage{amsmath} +% +% the driver line is not necessary if you +% have aebpro.cfg configured to your driver. +% +\usepackage[% + web={designv,pro,tight,usesf,usetemplates}, + eforms,graphicxsp={showembeds},aebxmp +]{aeb_pro} +\usepackage{rmannot} +\usepackage{yt4pdf} +\usepackage{multicol} + +\textBgColor{lightgray} + +\DeclareDocInfo +{ + title=The \texorpdfstring{\textsf{yt4pdf} Package\\[3pt]}{yt4pdf Package: }Demo 1 of You Tube API, + author=D. P. Story, + university=Acro\negthinspace\TeX.Net, + email=dpstory@acrotex.net, + subject={Live streamed video from YouTube.com}, + keywords={You Tube, AeB, rmannot}, + talksite=\url{http://www.acrotex.net}, + talkdate={\today} +} +\talkdateLabel{Published:} + +\def\AcroTeX{Acro\!\TeX} + +\makePoster{pdfyt_poster}{pdfyt_poster} + +\parindent=0pt\parskip6pt +\rheader{} + +\DeclarePageLayout{footskip=29pt} + +\declarePlayList{\playList}{% dps note I've put these parentheses within braces, that was the problem. + \ytIdTitle{Kung-Fu Fighting {(Bruce Lee version)}}{GZ9e3Dy7obA} + \ytIdTitle{Kung-Fu Fighting {(Original, must view on YouTube)}}{jhUkGIsKvn0} + \ytIdTitle{RAF Sculthorpe {(Watch for my Mom!)}}{K7H8QghVs9k} + \ytIdTitle{Rocket Jump}{7XzdZ4KcI8Y} + \ytIdTitle{Abdul And Cleopatra - Jonathan Richman and the Modern Lovers}{mLDF5MBMWHE} +} + +\begin{document} + +\maketitle + +\input{config_intacc.def} + +\begin{center}\bfseries\Large\color{blue}YT4PDF\end{center} + + +%\previewtrue + +\begin{minipage}{571bp/2} +\ytRmAnnot[poster=pdfyt_poster,deactivated=pageclose]{YouTube}{571bp/2}{330bp/2} +\end{minipage}\hfill +\begin{minipage}{\linewidth-290bp-10bp}\centering +\ytPlayToggle{1in}{11bp}\\[3bp] +\ytStopLoading[\textSize{0}]{1in}{11bp}\\[3bp] +\ytMuteToggle{1in}{11bp}\\[3bp] +\ytRewind{1in}{11bp}\\[3bp] +\ytSelect[\textSize{0}]{eNzrn8-JFSE}{1in}{11bp}\\[6bp] +\ytOpenWeb[\textSize{0}]{1in}{11bp} +\end{minipage} + +\medskip + +\begin{flushleft} +\raggedcolumns\bfseries +Favorites to play:\vspace{-.5\baselineskip} +\begin{multicols}{2}\ytPlayList{GZ9e3Dy7obA}{\playList}% +\begin{itemize} +\item \ytComboList{\linewidth-1bp-33bp}{11bp}\kern1bp\ytComboBtn[\TU{Click to play, shift-click to load thumbnail only}]{33bp}{11bp} +\item \ytvId{_iUnOpPEg0w}{TegrityGuy} + +\item \ytvId*{eNzrn8-JFSE}{Open at Adobe} (load thumbnail) + +\columnbreak + +\item \ytvId{q-iiFo-6Vi0}{Digital Signature in 9.0 Pro} +\item \ytvId{5y9-EVmreU4}{Lori's Corner: Episode \#1} +\item \ytvId{T9Yzo_hlwP0}{Intro to PDF Portfolios} +\end{itemize} +\end{multicols} +\end{flushleft} + + + +\end{document} diff --git a/texmf-dist/source/latex/yt4pdf/examples/yt4pdf-2.tex b/texmf-dist/source/latex/yt4pdf/examples/yt4pdf-2.tex new file mode 100644 index 00000000..558b3928 --- /dev/null +++ b/texmf-dist/source/latex/yt4pdf/examples/yt4pdf-2.tex @@ -0,0 +1,152 @@ +\documentclass{article} +\usepackage{amsmath} +% +% the driver line is not necessary if you +% have aebpro.cfg configured to your driver. +% +\usepackage[% + web={designv,pro,tight,usesf,usetemplates}, + eforms,graphicxsp={showembeds},aebxmp +]{aeb_pro} +\usepackage{yt4pdf} +\usepackage{picins} + +% \textBgColor{lightgray} + +\DeclareDocInfo +{ + title=The \texorpdfstring{\textsf{yt4pdf} Package\\[3pt]}{yt4pdf Package: }Demo 2 of You Tube API, + author=D. P. Story, + university=Acro\negthinspace\TeX.Net, + email=dpstory@acrotex.net, + subject={Live streamed video from YouTube.com}, + keywords={You Tube, AeB, rmannot}, + talksite=\url{http://www.acrotex.net}, + talkdate={\today} +} +\talkdateLabel{Published:} + +\def\AcroTeX{Acro\!\TeX} + +\makePoster{pdfyt_poster}{pdfyt_poster} +\makePoster{yt_poster}{graphics/yt_icon_sm} + +\parindent=0pt\parskip6pt +\rheader{} + +\DeclarePageLayout{footskip=15.5pt} + +%\previewtrue + +\declarePlayList{\playList}{% + \ytIdTitle{Kung-Fu Fighting {(Bruce Lee version)}}{GZ9e3Dy7obA} + \ytIdTitle{Kung-Fu Fighting {(Original, must view on YouTube)}}{jhUkGIsKvn0} + \ytIdTitle{RAF Sculthorpe {(Watch for my Mom!)}}{K7H8QghVs9k} + \ytIdTitle{Rocket Jump}{7XzdZ4KcI8Y} +} + +% +% Note: popupmenu package version 1.0 (2010/09/18) or later required here. +% +\begin{popupmenu}{YTMenu} + \puIdTitle{Select a You Tube Video}{} % A title has no yt Id + \begin{submenu}{title=Music Videos} + \puIdTitle{Kung-Fu Fighting (Bruce Lee version)}{GZ9e3Dy7obA} + \puIdTitle{Kung-Fu Fighting (Original, view on You Tube)}{jhUkGIsKvn0} + \puIdTitle{Ink Spots - If I didn't care}{rvwfLe6sLis} + \puIdTitle{Ink Spots - My Prayer}{h7KJCns5v3g} + \end{submenu} + \begin{submenu}{title=Adobe Related Videos} + \puIdTitle{Open at Adobe}{eNzrn8-JFSE} + \puIdTitle{Lori's Corner Episode \#1}{5y9-EVmreU4} + \puIdTitle{Intro to PDF Portfolios}{T9Yzo_hlwP0} + \end{submenu} + \begin{submenu}{title=Action Videos} + \puIdTitle{Rocket Jump}{7XzdZ4KcI8Y} + \puIdTitle{AimBot}{NYGlWjIKoY4} + \puIdTitle{Flower Warfare}{031Dshcnso4} + \puIdTitle{Modern Warfare: Frozen Crossing Pt. 1}{rzQMGMuD1sU} + \puIdTitle{Modern Warfare: Frozen Crossing Pt. 2}{a08ViuvORRM} + \end{submenu} +\end{popupmenu} + +% After defining all menus used with YouTube videos, we declare them using \ytPopupMenuData +% The argument is a token list: \ytPopupMenuData{\myEducationMenu\myFunMenu...} +\ytPopupMenuData{\YTMenu} + +\begin{document} + +\maketitle + +\input{config_intacc.def} + + +\begin{center}\bfseries\Large\color{blue}YT4PDF\end{center} + +\DeclareYTName{ytInWindow} +\ytBtnPresets{\BC{.5 0 0}\W{1}\S{S}\textFont{HeBo}}% +{\setlength{\dimen0}{(\linewidth)/6-1bp}\xdef\ytWidth{\the\dimen0}} %-.5bp +\cfooter{\makebox[\linewidth][c]{\kern1bp\ytPlayToggle{\ytWidth}{11bp}\kern1bp\ytStopLoading[\textSize{0}]{\ytWidth}{11bp}\kern1bp +\ytMuteToggle{\ytWidth}{11bp}\kern1bp\ytRewind{\ytWidth}{11bp}\kern1bp +\ytSelect[\textSize{0}]{eNzrn8-JFSE}{\ytWidth}{11bp}\kern1bp\ytOpenWeb[\textSize{0}]{\ytWidth}{11bp}}} + +\newcommand{\myPBPresets}{\CA{YT Menu}\textColor{0 0 1}\W1\BC{}\textSize{0} + \S{S}\AA{\AAMouseEnter{\JS{ytPopupMenu("\ytCurrRMAName",YTMenu)}}}} + +\setWindowDimPos{position={halign=center,valign=center,hoffset=0,voffset=0}, + width={default=571},height={default=330}}% + +\setlength{\pichskip}{3pt} +\parpic(.25in,.25in){% +\parbox{.25in}{\offinterlineskip\resizebox{.25in}{!} +{\ytRmAnnot[windowed,poster=yt_poster,deactivated=pageclose]{ytInWindow}{72bp}{72bp}}}} +\pushButton[\presets{\myPBPresets}]{myYTMenu}{20bp}{5bp} +On this page, the You Tube annotation is icon size and the video is played +in a floating window. + +Move the window by dragging its title bar. Resize it by dragging the +lower-right corner. Close the window by clicking on the upper-right +corner. + +The \textsf{YT Menu} uses the \textsf{popupmenu} package. Alternatively, +we could just use the combo box that has been used already, but, I thought +we might try something different. + +\newpage + +\ytRmAnnot[posternote=AcroTeX PDF Tube,deactivated=pageclose]{YouTube1}{571bp/2}{330bp/2}\\ +\ytPlayList{GZ9e3Dy7obA}{\playList}\ytComboListPresets{\textSize{9}}% +\ytComboList{(571bp/2)-1bp-33bp}{11bp}\kern1bp\ytComboBtn[\TU{Click to play, shift-click to load thumbnail only}]{33bp}{11bp} + +\newpage +\cfooter{} +\begin{minipage}{571bp/2} +\ytRmAnnot[posternote=AcroTeX PDF Tube,deactivated=pageclose]{YouTube2}{571bp/2}{330bp/2}\\ +\ytPlayList{GZ9e3Dy7obA}{\playList}\ytComboListPresets{\textSize{9}}% +\ytComboList{(571bp/2)-1bp-33bp}{11bp}\kern1bp\ytComboBtn[\TU{Click to play, shift-click to load thumbnail only}]{33bp}{11bp} +\end{minipage}\hfill +\begin{minipage}{\linewidth-290bp-10bp}\centering +\ytPlayToggle{1in}{11bp}\\[3bp] +\ytStopLoading[\textSize{0}]{1in}{11bp}\\[3bp] +\ytMuteToggle{1in}{11bp}\\[3bp] +\ytRewind{1in}{11bp}\\[3bp] +\ytSelect[\textSize{0}]{eNzrn8-JFSE}{1in}{11bp}\\[6bp] +\ytOpenWeb[\textSize{0}]{1in}{11bp} +\end{minipage} + +\newpage + +\begin{center} +\begin{minipage}{571bp/2} +\ytRmAnnot[poster=pdfyt_poster,deactivated=pageclose]{YouTube3}{571bp/2}{330bp/2}\\ +\ytPlayList{GZ9e3Dy7obA}{\playList}\ytComboListPresets{\textSize{9}}% +\ytComboList{(571bp/2)-1bp-33bp}{11bp}\kern1bp\ytComboBtn[\TU{Click to play, shift-click to load thumbnail only}]{33bp}{11bp}\\[1bp] +{\setlength{\dimen0}{(\linewidth+1bp)/6-1bp}\xdef\ytWidth{\the\dimen0}}% +\ytPlayToggle{\ytWidth}{11bp}\kern1bp\ytStopLoading[\textSize{0}]{\ytWidth}{11bp}\kern1bp +\ytMuteToggle{\ytWidth}{11bp}\kern1bp\ytRewind{\ytWidth}{11bp}\kern1bp +\ytSelect[\textSize{0}]{eNzrn8-JFSE}{\ytWidth}{11bp}\kern1bp +\ytOpenWeb[\textSize{0}\CA{View on Web}]{\ytWidth}{11bp} +\end{minipage} +\end{center} + +\end{document} diff --git a/texmf-dist/source/latex/yt4pdf/examples/yt4pdf-3.tex b/texmf-dist/source/latex/yt4pdf/examples/yt4pdf-3.tex new file mode 100644 index 00000000..03625c9f --- /dev/null +++ b/texmf-dist/source/latex/yt4pdf/examples/yt4pdf-3.tex @@ -0,0 +1,88 @@ +%\ytIdTitle{No Ordinary Love - Sade}{_WcWHZc8s2I} +\documentclass{article} +\usepackage{amsmath} +% +% the driver line is not necessary if you +% have aebpro.cfg configured to your driver. +% +\usepackage[% + web={designv,pro,tight,usesf,usetemplates}, + eforms,graphicxsp={showembeds},aebxmp +]{aeb_pro} +\usepackage{yt4pdf} + +%\margins{10bp}{10bp}{.5in}{.5in} % left,right,top, bottom +%\screensize{7.5in}{10in} % height,width dimensions + +\textBgColor{lightgray} + +\DeclareDocInfo +{ + title=The \texorpdfstring{\textsf{yt4pdf} Package\\[3pt]}{yt4pdf Package: }Demo 3 of You Tube API, + author=D. P. Story, + university=Acro\negthinspace\TeX.Net, + email=dpstory@acrotex.net, + subject={Live streamed video from YouTube.com}, + keywords={You Tube, AeB, rmannot}, + talksite=\url{http://www.acrotex.net}, + talkdate={\today} +}\talkdateLabel{Published:} + +\def\AcroTeX{Acro\!\TeX} + +\makePoster{pdfyt_poster}{pdfyt_poster} +\makePoster{yt_poster}{graphics/yt_icon_sm} + +\parindent=0pt\parskip6pt +\rheader{} + +% dps need to change the catcode of subscript (_) before hyperref gets +% chance to look at it. +\declarePlayList{\playList}{% + \ytIdTitle{Kung-Fu Fighting {(Bruce Lee version)}} {GZ9e3Dy7obA} + \ytIdTitle{Kung-Fu Fighting {(Original, must view on YouTube)}}{jhUkGIsKvn0} + \ytIdTitle{RAF Sculthorpe {(Watch for my Mom!)}} {K7H8QghVs9k} + \ytIdTitle{Rocket Jump} {7XzdZ4KcI8Y} + \ytIdTitle{No Ordinary Love - Sade} {_WcWHZc8s2I} +} + +\begin{document} + +\maketitle + +\input{config_intacc.def} + +\begin{center}\bfseries\Large\color{blue}YT4PDF\end{center} + +\ytBtnPresets{\BC{.5 0 0}\W{1}\S{S}\textFont{HeBo}}% + +\resizebox{\linewidth}{!}{\ytRmAnnot[play=eNzrn8-JFSE,poster=pdfyt_poster, + deactivated=pageclose]{ytPlayOnOpen}{571bp}{330bp}}\\ +{\setlength{\dimen0}{(\linewidth-2bp)/6}\xdef\ytWidth{\the\dimen0}}% +\ytPlayToggle{\ytWidth}{11bp}\ytStopLoading{\ytWidth}{11bp}% +\ytMuteToggle{\ytWidth}{11bp}\ytRewind{\ytWidth}{11bp}% +\ytSelect{eNzrn8-JFSE}{\ytWidth}{11bp}\ytOpenWeb[\textSize{0}]{\ytWidth}{11bp}% + +\ytPlayList{GZ9e3Dy7obA}{\playList} + +% We have to disable the RMA so the combo box can be seen above it. +Playlist: \ytComboList[\A{\JS{\thisNamedRMA(ytPlayOnOpen).activated=false;}}]{2.5in}{11bp}\kern1bp\ytComboBtn[\TU{Click to play, shift-click to load thumbnail only}]{33bp}{11bp} + +\newpage +\begin{center}\bfseries\Large\color{blue}YT4PDF\end{center} + +\resizebox{\linewidth}{!}{\ytRmAnnot[load=GZ9e3Dy7obA,poster=pdfyt_poster, + deactivated=pageclose]{ytLoadOnOpen}{571bp}{330bp}}\\ +\ytBtnPresets{\BC{.5 0 0}\W{1}\S{S}\textFont{HeBo}}% +{\setlength{\dimen0}{(\linewidth-2bp)/6}\xdef\ytWidth{\the\dimen0}}% +\ytPlayToggle{\ytWidth}{11bp}\ytStopLoading{\ytWidth}{11bp}% +\ytMuteToggle{\ytWidth}{11bp}\ytRewind{\ytWidth}{11bp}% +\ytSelect{eNzrn8-JFSE}{\ytWidth}{11bp}\ytOpenWeb[\textSize{0}]{\ytWidth}{11bp}% + +\ytPlayList{GZ9e3Dy7obA}{\playList} + +% We have to disable the RMA so the combo box can be seen above it. +Playlist: \ytComboList[\A{\JS{\thisNamedRMA(ytLoadOnOpen).activated=false;}}]{2.5in}{11bp}\kern1bp\ytComboBtn[\TU{Click to play, shift-click to load thumbnail only}]{33bp}{11bp} + + +\end{document} diff --git a/texmf-dist/source/latex/yt4pdf/graphics/pdfyt_poster.eps b/texmf-dist/source/latex/yt4pdf/graphics/pdfyt_poster.eps new file mode 100644 index 00000000..97c7ecd1 Binary files /dev/null and b/texmf-dist/source/latex/yt4pdf/graphics/pdfyt_poster.eps differ diff --git a/texmf-dist/source/latex/yt4pdf/swf/pdf_tube_basic.swf b/texmf-dist/source/latex/yt4pdf/swf/pdf_tube_basic.swf new file mode 100644 index 00000000..5dde7b7c Binary files /dev/null and b/texmf-dist/source/latex/yt4pdf/swf/pdf_tube_basic.swf differ diff --git a/texmf-dist/source/latex/yt4pdf/yt4pdf.dtx b/texmf-dist/source/latex/yt4pdf/yt4pdf.dtx new file mode 100644 index 00000000..4ca3bcc0 --- /dev/null +++ b/texmf-dist/source/latex/yt4pdf/yt4pdf.dtx @@ -0,0 +1,629 @@ +%\iffalse +%<*copyright> +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% yt4pdf.sty package, %% +%% Copyright (C) 2010--2016 D. P. Story %% +%% dpstory@uakron.edu %% +%% %% +%% This program can redistributed and/or modified under %% +%% the terms of the LaTeX Project Public License %% +%% Distributed from CTAN archives in directory %% +%% macros/latex/base/lppl.txt; either version 1 of the %% +%% License, or (at your option) any later version. %% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +%\NeedsTeXFormat{LaTeX2e}[1997/12/01] +%\ProvidesPackage{yt4pdf} +% [2016/10/04 v1.1 yt4pdf: Play You Tube videos in PDF, Acrobat Distiller only (dps)] +%<*driver> +\documentclass{ltxdoc} +\usepackage[colorlinks,hyperindex]{hyperref} +%\pdfstringdefDisableCommands{\let\\\textbackslash} +%\EnableCrossrefs \CodelineIndex +\begin{document} +\def\CMD#1{\textbackslash#1} + \GetFileInfo{yt4pdf.sty} + \title{\textsf{yt4pdf}: Package for playing You Tube Videos} + \author{D. P. Story\\ + Email: \texttt{dpstory@uakron.edu}} + \date{processed \today} + \maketitle + \tableofcontents + \let\Email\texttt + \DocInput{yt4pdf.dtx} + \PrintIndex +\end{document} +% +% \fi +% \MakeShortVerb{|} +% \StopEventually{} +% +% \DoNotIndex{\def,\edef,\gdef,\xdef,\global,\long,\let} +% \DoNotIndex{\expandafter,\string,\the,\ifx,\else,\fi} +% \DoNotIndex{\csname,\endcsname,\relax,\begingroup,\endgroup} +% \DoNotIndex{\DeclareTextCommand,\DeclareTextCompositeCommand} +% \DoNotIndex{\space,\@empty,\special} +% +% \begin{macrocode} +%<*package> +% \end{macrocode} +% \begin{macrocode} +\RequirePackage{xkeyval} +% \end{macrocode} +% \begin{macrocode} +\ProcessOptions +\RequirePackage{rmannot} +\RequirePackage{popupmenu}[2010/09/18] +% \end{macrocode} +% +% \section{Introduction} +% +% I believe that I was vaguely aware of the \href{http://code.google.com/apis/youtube/flash_api_reference.html} +%{YouTube ActionScript 3.0 Player}, but never pursued it because of my +%general lack of interest in You Tube (\url{www.youtube.com}). Recently, I +%became aware of a very nice demo PDF that used the API, see +%\href{http://www.uvsar.com/pdftube/}{PDF Tube - YouTube API wrapper for PDF +%documents}. The SWF file and JavaScript are made freely available, so I +%downloaded it, and was sufficiently impressed to port the example to +%{\LaTeX} using various members of the {Acro\negthinspace\TeX} Fine Family of Software +%\verb!:-{)!. The SWF file and JavaScript are due to the good folks at +%UVSAR (\url{www.uvsar.com}). The UVSAR's sample demo also appeared in the forums of +%the \href{http://acrobatusers.com/forums/aucbb/viewtopic.php?pid=62134}{Acrobat User +%Community}. +% +% \section{Implementation} +% +% \DescribeMacro{\ytFolder} The path to the folder containing +% the \texttt{pdf\_Tube\_basic.swf} file. This path is set through +% the \texttt{yt4pdf.cfg} file. +% \begin{macrocode} +\newcommand{\ytFolder}{C:/Users/Public/Documents/My TeX Files/% +tex/latex/aeb/aebpro/yt4pdf/swf} +% \end{macrocode} +% \DescribeMacro{ytSWF} The path to \texttt{pdf\_Tube\_basic.swf}, used +% as an argument for the \cs{rmAnnot} macro. +% \begin{macrocode} +\saveNamedPath{ytSWF}{\ytFolder/pdf_tube_basic.swf} +% \end{macrocode} +% We input the file \texttt{yt4pdf.cfg} which should contain a re-definition +% of \cs{ytFolder}, the path to the user's installation containing the +% \texttt{pdf\_tube\_basic.swf}. +% \begin{macrocode} +\InputIfFileExists{yt4pdf.cfg}{}{} +% \end{macrocode} +% \subsection{The YouTube RMA} +% In this section, we define \cs{ytRmAnnot}, a rich media annotation, that is used +% to play YouTube videos. +% \begin{macrocode} +% \end{macrocode} +% An internal command for getting the rma object based on the current page and the +% name of the annot. +% \begin{macrocode} +\def\yt@namegdef#1{\expandafter\gdef\csname #1\endcsname} +\def\yt@namexdef#1{\expandafter\xdef\csname #1\endcsname} +\def\thisNamedRMA(#1){this.getAnnotRichMedia(this.pageNum,"#1")} +% \end{macrocode} +% \DescribeMacro{play} This is a key-value pair for the \cs{ytRmAnnot} command. +% The value of \texttt{play} is a YouTube video ID. When the page the annot is +% on, the video will be played. +% \begin{macrocode} +\define@key{ytRmAnnot}{play}[]{\def\ytrmannot@play{#1}} +\define@key{ytRmAnnot}{load}[]{\def\ytrmannot@load{#1}} +\setkeys{ytRmAnnot}{play,load} +\let\ytCurrRMAName\@empty +% \end{macrocode} +% \begin{macro}{\ytRmAnnot} +% The \cs{ytRmAnnot} creates a rich media annotation using the \textsf{rmannot} package. +% It uses the SWF file \texttt{pdf\_Tube\_basic.swf} referenced here by the name of +% \texttt{ytSWF}. The command takes four parametrs: +% \begin{itemize} +% \item[\texttt{[\#1]}]: The optional first parameter takes the key-value pairs of the +% \cs{rmAnnot} command, plus the \texttt{play} key, defined above. The play key is used +% to set the annot up so it plays automatically when the page is opened. +% \item[\texttt{\#2}]: The name of this annot, unique to the document. This should be +% a ``JavaScript variable.'' The name populates the command \cs{ytCurrRMAName}, which is +% needed for the other commands in this package. +% \item[\texttt{\#3}]: The width of the annot +% \item[\texttt{\#4}]: The height of the annot +% \end{itemize} +% \begin{macrocode} +\newcommand{\ytRmAnnot}[4][]{\begingroup + \@ifundefined{#2@ytrmname}{\yt@namegdef{#2@ytrmname}{#1}}% + {\PackageError{yt2pdf}{The name `#2' is already defined + for\MessageBreak this \string\ytRmAnnot}{Choose a unique + name for this \string\ytRmAnnot, one different from `#2'.}}% + \setkeys*{ytRmAnnot}{#1}\gdef\ytCurrRMAName{#2}% + \ifx\ytrmannot@play\@empty\else + \makebox[0pt][l]{\pushButton[\BC{}\BG{}\S{S} + \AA{\AAPageOpen{aebStartPlayer(\thisNamedRMA(#2),% + "\ytrmannot@play",true);}\AAPageClose{aebCancelWait(false);}} + ]{btnRmAnnot#2}{1bp}{1bp}}\let\ytrmannot@load\@empty\fi + \ifx\ytrmannot@load\@empty + \else\makebox[0pt][l]{\pushButton[\BC{}\BG{}\S{S} + \AA{\AAPageOpen{aebStartPlayer(\thisNamedRMA(#2),% + "\ytrmannot@load",false);}\AAPageClose{aebCancelWait(false);}} + ]{btnRmAnnot#2}{1bp}{1bp}}\fi + \rmAnnot[\XKV@rm,name=#2,enabled=onclick]{#3}{#4}{ytSWF}% + \endgroup +} +% \end{macrocode} +% \end{macro} +% \DescribeMacro{\DeclareYTName} Defines the internal macro +% \cs{ytCurrRMAName}. This command is needed in the case were links, or +% control buttons come before the RMA annot. The first parameter is the +% page on which the target annot resides, the default is the current page. +% The second argument is the name of the target annot. +% code passed is +% \begin{macrocode} +\newcommand{\DeclareYTName}[2][]{\def\argi{#1}% + \ifx\argi\@empty\gdef\ytCurrRMAName{#2}\else + \gdef\ytCurrRMAName{[#1]#2}\fi +} +% \end{macrocode} +% \subsection{Button Controls} +% We present six control buttons for the rm annot +% \begin{macro}{\ytBtnPresets} +% The default appearances of the control buttons. +% \begin{macrocode} +\newcommand{\ytBtnPresets}[1]{\def\yt@Presets{#1}} +\ytBtnPresets{\BC{.5 0 0}\S{S}\textFont{HeBo}\autoCenter{n}} +% \end{macrocode} +% \end{macro} +% The following six commands all take three parameters, the first one optional +%\begin{enumerate} +% \item[\texttt{\#1}:] Standard key-value pairs for modifying the +% appearance of an eforms form field. +% \item[\texttt{\#2}:] +% \texttt{this.getAnnotRichMedia(this.pageNum+1, "YouTube")}. +% \item[\texttt{\#3}:] the width of the button +% \item[\texttt{\#4}:] the height of the button +%\end{enumerate} +% \begin{macro}{\ytPlayToggle} +% This button has several functions: Pause/Play/Buffering. +% Initially the button label is on Pause (pressing it pauses a playing video); +% the button label reads Play when the video is loaded and paused (pressing it plays or resumes +% the video); while the video is loading, the button label is Buffering... +% \begin{macro}{\ytStopLoading} Pressing this button stops the streaming of the currently playing +% video. If the video is started again, there will be some buffering before the play begins. +% \begin{macro}{\ytMuteToggle} This button toggles and sound off and on. Button labels are +% MUTE and UNMUTE. +% \begin{macro}{\ytRewind} If the video is playing, this button +% stops the video, rewinds it to the beginning, and starts play again. If the video +% is paused, this button rewinds the video to the beginning, the video remains paused. +% \begin{macro}{\ytSelect} When this button is pressed, a response dialog opens. +% The user enters a YouTube video ID into the field. On pressing OK, this video is played. +% \item[] \textbf{Note:} Some YouTube videos are security +% restricted and cannot be played through an embedded player, such as the one used here. +% If video ID of a video that does not allow embedded playback, a dialog appears giving +% the use to view the video on the web. +% \begin{macro}{\ytOpenWeb} The user has the option of pressing this button to view the +% currently video on the web at \texttt{www.youtube.com}. +% \begin{macrocode} +% \end{macrocode} +% The \cs{oyt@RMA} command takes the second parameter of each of the six button commands, +% and expands it into the appropriate JS code. +% \begin{macrocode} +\newcommand{\oyt@RMA}[1][this.pageNum]{\oyt@@RMA[#1]} +\def\oyt@@RMA[#1]#2\@nil{\gdef\yt@CurrRMAName{#2}% + \def\yt@rm{this.getAnnotRichMedia(#1,"#2")}} +% \end{macrocode} +% We finally define the six control buttons. +% \begin{macrocode} +\newcommand{\ytPlayToggle}[3][]{% + \expandafter\oyt@RMA\ytCurrRMAName\@nil% + \pushButton[\CA{\ytStrPAUSE}\presets{\yt@Presets}#1 + \A{\JS{ytPlayToggle(\yt@rm);}}]{playToggle}{#2}{#3}% +} +\newcommand{\ytStopLoading}[3][]{% + \expandafter\oyt@RMA\ytCurrRMAName\@nil% + \pushButton[\CA{\ytStrStopLoading}\presets{\yt@Presets}#1 + \A{\JS{\yt@rm.callAS("stopVideo");}}]{vidStop}{#2}{#3}% +} +\newcommand{\ytMuteToggle}[3][]{% + \expandafter\oyt@RMA\ytCurrRMAName\@nil% + \pushButton[\CA{\ytStrMUTE}\presets{\yt@Presets}#1 + \A{\JS{ytMuteToggle(\yt@rm);}}]{muteToggle}{#2}{#3}% +} +\newcommand{\ytRewind}[3][]{% + \expandafter\oyt@RMA\ytCurrRMAName\@nil% + \pushButton[\CA{\ytStrREWIND}\presets{\yt@Presets}#1 + \A{\JS{ytRewind(\yt@rm);}}]{ytRewind}{#2}{#3}% +} +\newcommand{\ytSelect}[4][]{% + \expandafter\oyt@RMA\ytCurrRMAName\@nil% + \pushButton[\CA{\ytStrLoadVideo}\presets{\yt@Presets}#1 + \A{\JS{ytSelect(\yt@rm,"#2");}}]{selectVid}{#3}{#4}% +} +\newcommand{\ytOpenWeb}[3][]{% + \expandafter\oyt@RMA\ytCurrRMAName\@nil% + \pushButton[\CA{\ytStrWatchOnWeb}\presets{\yt@Presets}#1 + \A{\JS{ytOpenWeb(\yt@rm);}}]{playOnWeb}{#2}{#3}% +} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \subsection{Defining a Video Id} +% \subsubsection{Using a Link} +% \begin{macro}{\ytvIdPresets} +% The options for the \cs{ytvId} link. The default is given below in the definition. +% \begin{macro}{\ytvId} +% The \cs{ytvId} is link which when pressed plays the video whose Video Id is passed as +% its second argument. +% \begin{itemize} +% \item[\texttt{[\#1]}:] The name of the annot this video is to play in. When +% this parameter is not specified, the default +% is \cs{ytCurrRMAName}, which is defined by the \cs{ytRmAnnot} macro. +% \item[\texttt{\#2}:] The video Id for the YouTube video to play +% \item[\texttt{\#3}:] The text that displays the link. +%\end{itemize} +% \begin{macrocode} +\newcommand{\ytvIdPresets}[1]{\def\yt@vIdPresets{#1}} +\ytvIdPresets{\linktxtcolor{webbrown}} +\newcommand{\ytvId}{\@ifstar{\def\yt@lnk@play{false}\yt@@vId} + {\def\yt@lnk@play{true}\yt@@vId}} +\newcommand{\yt@@vId}[3][\ytCurrRMAName]{% + \oyt@RMA#1\@nil\setLink[\presets{\yt@vIdPresets} + \A{\JS{aebStartPlayer(\yt@rm,"#2",\yt@lnk@play);}}]{#3}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \subsubsection{Using a Combobox} +% \begin{macro}{\ytComboList} +% The \cs{ytComboList} is a combox box of video Ids and titles. The user selects a +% video based on its title, then presses the PLAY button. The two commands +% \cs{ytComboListPresets} and \cs{ytComboBtnPresets} are used to set the appearances +% of the combo box and the PLAY button. +%\begin{itemize} +% \item[\texttt{[\#1]}:] eforms key-value pairs +% \item[\texttt{\#2}:] The width of the combo box +% \item[\texttt{\#3}:] The height of the combo box +%\end{itemize} +% \begin{macro}{\ytComboBtn} +% A button to play the selection made in the combo box. +% \begin{macro}{\ytPlayList} +% This command is executed before \cs{ytComboBtn} to set the play list, +% and the default value. +% \begin{macrocode} +\newcommand{\ytComboListPresets}[1]{\def\yt@ComboListPresets{#1}} +\newcommand{\ytComboBtnPresets}[1]{\def\yt@ComboBtnPresets{#1}} +\let\yt@ComboListPresets\@empty +\let\yt@ComboBtnPresets\@empty +% \end{macrocode} +% Use the \cs{ytPlayList} to pass the play list to the next combo box +% \begin{macrocode} +\newcommand{\ytPlayList}{\begingroup\@makeother\_\@makeother\' + \ytPlayList@i} +\def\ytPlayList@i#1#2{\gdef\yt@pl@def{#1}\xdef\yt@pl@pl{#2}\endgroup} +% \end{macrocode} +% \begin{macro}{\declarePlayList} +% A video ID may contain characters {\LaTeX} considers special, so we sanitize these +% special characters before reading in the video ID. Near as I can determine, a video +% id consists of 11 characters comprising combinations of letters (A-Z,a-z) numbers +% (0-9) and special characters underscore and hyphen (\_ and -). We sanitize the last two. +%\begin{verbatim} +%\declarePlayList{<\cmd>}{ +% \ytIdTitle{}{} +% ... +% \ytIdTitle{}{} +% } +%\end{verbatim} +%The entries may also be in raw form `|[()()]|'. Note that the two arguments are +%enclosed in parentheses, there is a problem with parsing if \texttt{} itself contains +%parentheses. Within \texttt{} enclose matching parentheses in braces, for example, +%\begin{flushleft}|\ytIdTitle{Kung-Fu Fighting {(Bruce Lee version)}}{GZ9e3Dy7obA}|\end{flushleft} +% \changes{v1.1}{2016/10/04}{Added \string\cs{declarePlayList}} +% \begin{macrocode} +\newcommand{\declarePlayList}{\bgroup + \@makeother\_\@makeother\- + \yt@declarePlayList} +\def\yt@declarePlayList#1#2{% + \gdef#1{#2}\egroup} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\ytIdTitle} +% A convenience command to lay out the playlist, for example, +%\begin{verbatim} +%\declarePlayList{\playListii}{% +% \ytIdTitle{Elfego Baca}{gRwa0MdeqVs} +% \ytIdTitle{Texas John Slaughter}{7yrk1BvtLE8} +% \ytIdTitle{Swamp Fox}{-SBPnw5riLM&NR} +% \ytIdTitle{Zorro Promo}{cKludhxEoJ0} +%} +%\end{verbatim} +% \begin{macrocode} +\newcommand{\ytIdTitle}[2]{[(#2)(#1)]} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\ytNewBaseName} +% \cs{ytNewBaseName} is a not so perfect attempt to fix the problem of having +% multiple combo boxes on one page. The field names need to be distinct. We +% can pass the new field name using this command. +% \begin{macro}{\ytResetBaseName} +% This command resets the field name back to its default value. +% Both of these commands apply to \cs{ytComboList} and to \cs{ytComboBtn}. +% \changes{v1.0}{2011/08/23}{Added \cs{ytBaseName} to pass a field title to +% combo box and controlling play button} +% \begin{macrocode} +\newcount\ytListCnt \ytListCnt=0 +\newcommand{\ytNewBaseName}[1][]{% + \def\yt@argi{#1}\ifx\yt@argi\@empty\global\advance\ytListCnt1\relax + \gdef\yt@BaseName{\yt@CurrRMAName\the\ytListCnt}\else + \gdef\yt@BaseName{\yt@CurrRMAName#1}\fi +} +\newcommand{\ytResetBaseName}{\gdef\yt@BaseName{\yt@CurrRMAName}} +\ytResetBaseName +% \end{macrocode} +% \end{macro} +% \end{macro} +% Now we have the code for \cs{ytComboList} +% \begin{macrocode} +\newcommand{\ytComboList}[3][]{% + \expandafter\oyt@RMA\ytCurrRMAName\@nil% + \comboBox[\DV{\yt@pl@def}\V{\yt@pl@def} + \presets{\yt@ComboListPresets}#1]{ytSelect\yt@BaseName} + {#2}{#3}{\yt@pl@pl}% +} +% \end{macrocode} +% The parameters for \cs{ytComboBtn} are +%\begin{itemize} +% \item[\texttt{[\#1]}:] The the name of the \cs{ytRmAnnot} this selection is to play in +% the default is \cs{ytCurrRMAName}. +% \item[\texttt{\#2}:] The width of the combo box +% \item[\texttt{\#3}:] The height of the combo box +% the array of values and titles. +%\end{itemize} +% \begin{macrocode} +\newcommand{\ytComboBtn}[3][]{% + \expandafter\oyt@RMA\ytCurrRMAName\@nil% + \pushButton[\CA{\ytStrPLAY}\presets{\yt@ComboBtnPresets}#1 + \A{\JS{var f=this.getField("ytSelect\yt@BaseName");\r + aebStartPlayer(\yt@rm,f.value,!event.shift); + }}]{ytSelectBtn\yt@BaseName}{#2}{#3}% +} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \subsection{Support for the \textsf{popupmenu} package} +% \begin{macro}{\ytPopupMenuData} +% A command use to list the popupmenu data. It defines a command +% \cs{ytPopupData} that is used in the JS support for popup menus. +% \begin{macrocode} +\newcommand{\ytPopupMenuData}[1]{{\toks0={// yt4pdf: Begin popup menu data^^J}% + \@tfor\yt@menu:=#1\do{% + \toks2=\expandafter{\yt@menu}% + \edef\@tmp@exp{\the\toks0\the\toks2^^J}% + \toks0=\expandafter{\@tmp@exp}% + }\xdef\ytPopupData{\the\toks0// End of popup menu data}% +}} +\def\ytPopupData{// No popup menu data defined}% +% \begin{macro}{\puIdTitle} +% A convenience macro for entering popupmenu data for youtube videos. +%\begin{verbatim} +%\puIdTitle{\string\"Sea Hunt\string\" TV serie}{MW-IZ67iADU} +%\end{verbatim} +% Note that we must protect the double quote. +% \begin{macrocode} +\newcommand{\puIdTitle}[2]{\item{title={#1},return={[\itemindex,'#2']}}} +% \end{macrocode} +% \end{macro} +% +% \subsection{Strings that can be localized} +% The following strings are used on the buttons, and in the document level JS +% \begin{macrocode} +\newcommand{\ytStrPLAY}{PLAY} +\newcommand{\ytStrREPLAY}{REPLAY} +\newcommand{\ytStrPAUSE}{PAUSE} +\newcommand{\ytStrBuffering}{Buffering...} +\newcommand{\ytStrStopLoading}{Stop Loading} +\newcommand{\ytStrMUTE}{MUTE} +\newcommand{\ytStrUNMUTE}{UNMUTE} +\newcommand{\ytStrREWIND}{REWIND} +\newcommand{\ytStrLoadVideo}{Load Video} +\newcommand{\ytStrWatchOnWeb}{Watch on YouTube} +% response dialog box associated with ytSelect() +\newcommand{\ytRespQues}{Enter the YouTube Video ID} +\newcommand{\ytRespTitle}{Load a Video} +\newcommand{\ytRespLabel}{ID:} +% alert error messages +\newcommand{\ytStrErrorVideoNotFound}{Error: Video not found} +\newcommand{\ytStrErrorNoEmbed}{Error: This video does not allow + embedded playback \r\r Would you like to view this video + on the web?} +\newcommand{\ytStrConnecTimedOut}{Connection timed out, try again.} +% \end{macrocode} +% +% \subsection{Document level JavaScript} +% \begin{macrocode} +\begin{insDLJS*}[ytPlayToggle]{yt} +\begin{newsegment}{yt4PDF: YouTube for PDF JavaScript} +/* + Document-level script for YouTube player + Document-level script for the PDFtube embedded YouTube player + *************************************************************** + Functions to be called by buttons or links on the PDF + in each case, "rm" is the RichMedia annot containing the player + All these are optional and can be renamed or edited as required + *********************************************************** +*/ +// toggle play/pause (button labels updated by event functions) +function ytPlayToggle(rm) { + var ps = rm.callAS("getPlayerState"); + rm.callAS((ps == 1)? "pauseVideo" : "playVideo"); +} +// toggle mute (have to update button labels ourselves) +function ytMuteToggle(rm) { + var im = rm.callAS("isMuted"); + if (im) { + event.target.buttonSetCaption("\ytStrMUTE"); + rm.callAS("unMute"); + } else { + event.target.buttonSetCaption("\ytStrUNMUTE"); + rm.callAS("mute"); + } +} +// Ask the user for the ID number of a new video, and play it +function ytSelect(rm,vID) { + var rsp = app.response({ + cQuestion: "\ytRespQues", + cTitle: "\ytRespTitle", + cDefault: vID, + cLabel: "\ytRespLabel"}); + if (rsp !=null && rsp != "") + aebStartPlayer(rm,rsp,true); // dps +} +// open the video's YouTube page in the web browser +function ytOpenWeb(rm) { + var link = rm.callAS("getVideoUrl"); + if (link != null) { + app.launchURL(link,true); + rm.activated = false; + } +} +// rewind (seek to zero) +function ytRewind(rm) { rm.callAS("seekTo",0); } +/* + ************************************************************ + Functions called by the player itself, in response to events + as the events are "external", the annot is not the target. + These functions must exist and match the names in the SWF. + *********************************************************** +*/ +function ytPlayerReady() { + + // this is the place to load your default video - for example... + console.println(" Player loaded and ready"); + // this.getAnnotsRichMedia(this.pageNum)[0].callAS("loadVideoById", + // "eNzrn8-JFSE",0); + aebStartPlayer.isPlayerReady=true; // dps +} +function ytStateChange(st) { + // Possible values are unstarted (-1), ended (0), playing (1), + // paused (2), buffering (3), video cued (5) + var lbl = ""; + console.println(" State changed to " + st); + if (st == 0) lbl = "\ytStrREPLAY"; + else if (st == 1) lbl = "\ytStrPAUSE"; + else if (st == 3) lbl = "\ytStrBuffering"; + else if (st == 2 || st == 5) lbl = "\ytStrPLAY"; + if (lbl) this.getField("playToggle").buttonSetCaption(lbl); +} +function ytPlaybackQualityChange(str) { + // Possible values are "small", "medium", "large" and "hd720" + console.println(" Quality changed to " + str); +} +function ytProgress(q) { + // q has four properties that you can use to update form fields, + // such as... + //this.getField("currentTime").value = q.CurrentTime; + //this.getField("Duration").value = q.Duration; + //this.getField("BytesLoaded").value = q.BytesLoaded; + //this.getField("BytesTotal").value = q.BytesTotal; +} +function ytError(err) { + // Video cannot be played + console.println(" ERROR code " + err + " received"); + if (err == 100) + app.alert("\ytStrErrorVideoNotFound", 0, 0, "YouTube"); + else { + var resp=app.alert("\ytStrErrorNoEmbed", 1, 3, "YouTube"); + if (resp==4) { + aebCancelWait(false); + ytOpenWeb(aebStartPlayer.annot); + } + } +} +/* + We start the player if the annot is activated, if not, + we set annot.activated=true, and wait for the widget to say it + is ready. When ready, ytPlayerReady() sets + aebStartPlayer.isPlayerReady=true +*/ +function aebStartPlayer(rm,Id,bPlay) { + aebStartPlayer.annot=rm; + if (aebStartPlayer.annot.activated) + aebStartPlayer.annot.callAS(% +(bPlay)?"loadVideoById":"cueVideoById",Id,0); + else { + aebCancelWait(false); + aebStartPlayer.annot.activated=true; + aebStartPlayer.isPlayerReady=false; + aebStartPlayer.twait=app.setInterval(% +'aebWait4Ready(\"'+Id+'\",'+bPlay+');',250); + aebStartPlayer.to=app.setTimeOut("aebCancelWait(true)", 10000); + } +} +aebStartPlayer.isPlayerReady=false; +aebStartPlayer.twait=null; +aebStartPlayer.to=null; +/* + If the player is ready, we start the video, and clear + the setInterval, otherwise, we wait. +*/ +function aebWait4Ready(Id,bPlay) { + if (aebStartPlayer.isPlayerReady) { + aebCancelWait(false); + aebStartPlayer.annot.callAS(% +(bPlay)?"loadVideoById":"cueVideoById",Id,0); + } +} +function aebCancelWait(bNotify) { + var twait=aebStartPlayer.twait; + if (aebStartPlayer.to!=null) + try { app.clearTimeOut(aebStartPlayer.to); } catch(e) {}; + aebStartPlayer.to=null; + if (aebStartPlayer.twait!=null) + try { app.clearInterval(aebStartPlayer.twait); } catch(e) {} + aebStartPlayer.twait=null; + if ( bNotify && twait!=null ) app.alert("\ytStrConnecTimedOut"); +} +\end{newsegment} +\begin{newsegment}{Popup Menu Data and JS} +\ytPopupData +var aChoice; +function ytProcessMenu(aMenu) { + var cChoice = \popUpMenu(aMenu); + if ( cChoice != null ) { + aChoice=eval(cChoice); + if (aChoice[1]=="") return null; + var thisChoice=aChoice[0]; + if (ytProcessMenu.nChoice==undefined) { + ytProcessMenu.nChoice=thisChoice; + eval("aMenu"+ytProcessMenu.nChoice).bMarked=true; + } else { + eval("aMenu"+ytProcessMenu.nChoice).bMarked=false; + var oldnChoice=ytProcessMenu.nChoice; + ytProcessMenu.nChoice=thisChoice; + eval("aMenu"+ytProcessMenu.nChoice).bMarked=(oldnChoice==ytProcessMenu.nChoice)?false:true; + } + return aChoice; + } else return null; +} +function ytPopupMenu(rmaName,ytmenu) { + var aChoice=ytProcessMenu(ytmenu); + var rm=this.getAnnotRichMedia(this.pageNum,rmaName); + if (aChoice!=null) { + if (ytProcessMenu.lastDescrip==undefined) { + aebStartPlayer(rm,aChoice[1],!event.shift); + } else { + if (ytProcessMenu.lastDescrip!=aChoice[1]) { + aebStartPlayer(rm,aChoice[1],!event.shift); + } + } + ytProcessMenu.lastDescrip=aChoice[1]; + } +} +\end{newsegment} +\end{insDLJS*} +% \end{macrocode} +% \begin{macrocode} +% +% \end{macrocode} +\endinput + +rm=this.getAnnotRichMedia(this.pageNum,"YouTube1"); +rm.callAS("cueVideoById", "GZ9e3Dy7obA"); diff --git a/texmf-dist/source/latex/yt4pdf/yt4pdf.ins b/texmf-dist/source/latex/yt4pdf/yt4pdf.ins new file mode 100644 index 00000000..6732fb25 --- /dev/null +++ b/texmf-dist/source/latex/yt4pdf/yt4pdf.ins @@ -0,0 +1,60 @@ +%% +%% This file will generate fast loadable files and documentation +%% driver files from the doc files in this package when run through +%% LaTeX or TeX. +%% +%% Copyright 1999-2006 D. P. Story +%% +%% This file is part of the `AcroTeX eDucation Bundle'. +%% ------------------------------------------- +%% +%% It may be distributed under the conditions of the LaTeX Project Public +%% License, either version 1.2 of this license or (at your option) any +%% later version. The latest version of this license is in +%% http://www.latex-project.org/lppl.txt +%% and version 1.2 or later is part of all distributions of LaTeX +%% version 1999/12/01 or later. +%% +%% --------------- start of docstrip commands ------------------ +%% +\def\filedate{2010/09/10} +\def\batchfile{yt4pdf.ins} + +\input docstrip +\ifx\generate\undefined + \Msg{**********************************************} + \Msg{*} + \Msg{* This installation requires docstrip} + \Msg{* version 2.4 or later.} + \Msg{*} + \Msg{* An older version of docstrip has been input} + \Msg{*} + \Msg{**********************************************} + \errhelp{Move or rename old docstrip.tex and get a newer one.} + \errmessage{Old docstrip in input path} + \batchmode + \csname @@end\endcsname\end +\fi + +\keepsilent +\askforoverwritefalse +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\preamble +\endpreamble + +\generate +{% + \file{yt4pdf.sty}{\from{yt4pdf.dtx}{copyright,package}} +} + +\Msg{***************************************************************} +\Msg{*} +\Msg{* \space To finish the installation you have to copy the files } +\Msg{*} +\Msg{* \space *.sty, *.cfg and *.def into a directory searched by TeX} +\Msg{*} +\Msg{***************************************************************} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\endinput -- cgit v1.2.3