summaryrefslogtreecommitdiff
path: root/texmf-dist/source/latex/aeb-mobile/aeb_mobile.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'texmf-dist/source/latex/aeb-mobile/aeb_mobile.dtx')
-rw-r--r--texmf-dist/source/latex/aeb-mobile/aeb_mobile.dtx341
1 files changed, 341 insertions, 0 deletions
diff --git a/texmf-dist/source/latex/aeb-mobile/aeb_mobile.dtx b/texmf-dist/source/latex/aeb-mobile/aeb_mobile.dtx
new file mode 100644
index 00000000..8741a1ac
--- /dev/null
+++ b/texmf-dist/source/latex/aeb-mobile/aeb_mobile.dtx
@@ -0,0 +1,341 @@
+%\iffalse
+%<*copyright>
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% aeb_mobile.sty package %%
+%% Copyright (C) 2012-2018 %%
+%% dpstory@acrotex.net %%
+%% %%
+%% 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. %%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%</copyright>
+%<package>\NeedsTeXFormat{LaTeX2e}[1997/12/01]
+%<package>\ProvidesPackage{aeb_mobile}
+%<package> [2018/04/26 v1.4 aeb\_mobile: Formatting for mobile devices (dps)]
+%<*driver>
+\documentclass{ltxdoc}
+\usepackage[colorlinks,hyperindex=false]{hyperref}
+%\pdfstringdefDisableCommands{\let\\\textbackslash}
+%\EnableCrossrefs \CodelineIndex
+\OnlyDescription % comment out for implementation details
+\EnableCrossrefs
+\CodelineIndex
+\RecordChanges
+\InputIfFileExists{aebdocfmt.def}{\PackageInfo{web}{Inputting aebdocfmt.def}}
+ {\def\IndexOpt{\DescribeMacro}\def\IndexKey{\DescribeMacro}\let\setupFullwidth\relax
+ \PackageInfo{web}{aebdocfmt.def cannot be found}}
+\begin{document}
+\def\CMD#1{\textbackslash#1}
+\let\pkg\textsf
+\let\opt\texttt
+\addtolength{\marginparwidth}{3pt}
+ \GetFileInfo{aeb_mobile.sty}
+ \title{\texorpdfstring{\protect\pkg{aeb\_mobile}}{aeb_mobile}: Formatting for mobile devices}
+ \author{D. P. Story\\
+ Email: \texttt{dpstory@acrotex.net}}
+ \date{processed \today}
+ \maketitle
+ \tableofcontents
+ \DocInput{aeb_mobile.dtx}
+\IfFileExists{\jobname.ind}{\newpage\setupFullwidth\par\PrintIndex}{\paragraph*{Index} The index goes here.\\Execute
+ \texttt{makeindex -s gind.ist -o aeb\_mobile.ind aeb\_mobile.idx} on the command line and recompile
+ \texttt{aeb\_mobile.dtx}.}
+\IfFileExists{\jobname.gls}{\PrintChanges}{\paragraph*{Change History} The list of changes goes here.\\Execute
+ \texttt{makeindex -s gglo.ist -o aeb\_mobile.gls aeb\_mobile.glo} on the command line and recompile
+ \texttt{aeb\_mobile.dtx}.}
+\end{document}
+%</driver>
+% \fi
+% \MakeShortVerb{|}
+% \InputIfFileExists{aebdonotindex.def}{\PackageInfo{web}{Inputting aebdonotindex.def}}
+% {\PackageInfo{web}{cannot find aebdonotindex.def}}
+%
+% \begin{macrocode}
+%<*package>
+% \end{macrocode}
+% If \cs{ifsmartphone} is undefined, we do nothing; otherwise, if \texttt{true}
+% we load the package, if \texttt{false} we end the package. With this, we don't
+% need to surround the \textsf{aeb\_mobile} package with \cs{ifsmartphone}\dots\cs{fi}.
+%\changes{v1.1}{2012/06/26}{Added a check for \cs{ifsmartphone}}
+% \begin{macrocode}
+\@ifundefined{ifsmartphone}{\newif\ifsmartphone\smartphonetrue}{}
+% \end{macrocode}
+% \section{Introduction}
+%This is a simple package designed to format a document for a smart phone.
+%When the option \texttt{smartphone} is taken a page $4\times8$ inches is
+%created. Other definitions are made, as explained below.
+%
+% \begin{macrocode}
+%</package>
+%<*altpkgname>
+% \end{macrocode}
+%
+% \section{Alternate package name: \texorpdfstring{\protect\pkg{aeb-mobile}}{aeb-mobile}}
+% CTAN lists this package (\pkg{aeb\_mobile}) as \pkg{aeb-mobile}, so we'll create
+% a dummy package by that name.
+% \changes{v1.3}{2018/04/26}{Added dummy package \string\pkg{aeb-mobile}}
+% \begin{macrocode}
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{aeb-mobile}
+ [2018/04/26 v1.0 aeb-mobile Alt-name (dps)]
+\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{aeb_mobile}}
+\ProcessOptions
+\RequirePackage{aeb_mobile}
+% \end{macrocode}
+% \begin{macrocode}
+%</altpkgname>
+%<*package>
+% \end{macrocode}
+% \section{The code}
+% In this main body of the package, we set page dimensions, the inital
+% view of the PDF, define a title page, define links and the JavaScript
+% they use.
+% \subsection{Set Package Options}
+% \begin{macro}{smartphone}
+% First, we get the options.For the \texttt{smartphone}
+% option we have an $4\times8$ inch page, with narrow side margins.
+% \begin{macrocode}
+\DeclareOption{smartphone}{\ifsmartphone\AtEndOfPackage{%
+ \web@MargScrDimOpts{.25in}{.25in}{24pt}{.25in}{8in}{4in}}\fi}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{nomaketitle}
+% The package makes a redefinition of \cs{makeinlinetitle} (originally defined
+% in the web package. Using this option, the redefinition is skipped.
+% \begin{macrocode}
+\newif\ifmob@maketitledefn \mob@maketitledefntrue
+\DeclareOption{nomaketitle}{\mob@maketitledefnfalse}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{useforms}
+% By default, links are created to \textsf{Print} the file and \textsf{Toggle Cols},
+% if this option is used, form buttons are used instead. The form button will be
+% set so that it is visible but does not print. (An advantage it has over links.)
+% \begin{macrocode}
+\newif\ifmob@useforms \mob@useformsfalse
+\DeclareOption{useforms}{\mob@useformstrue}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{scalefigures}
+% An option suggested by Mathias M. When this option is taken, graphic images
+% are scaled according to an algorithm. See the description above the definition
+% of \cs{mob@adjwidth}. The commands \DescribeMacro{\scalefiguresOn}\cmd{\scalefiguresOn}
+% and \DescribeMacro{\scalefiguresOff}\cmd{\scalefiguresOff} are a convenient way to
+% turn the scaling of figures on and off.
+% \changes{v1.2}{2012/06/28}{Added \texttt{scalefigures} and \texttt{!scalefigures}}
+% \begin{macrocode}
+\newif\ifmobscalefigures\mobscalefiguresfalse
+\newcommand{\scalefiguresOn}{\mobscalefigurestrue}
+\newcommand{\scalefiguresOff}{\mobscalefiguresfalse}
+\DeclareOption{scalefigures}{\mobscalefigurestrue}
+\DeclareOption{!scalefigures}{\mobscalefiguresfalse}
+% \end{macrocode}
+% \end{macro}
+% \begin{macrocode}
+\ProcessOptions
+% \end{macrocode}
+% \textbf{Early Stop.} If \cs{ifsmartphone} is false, we stop here.
+%\changes{v1.1}{2012/06/26}{added early \cs{endinput}}
+% \begin{macrocode}
+\ifsmartphone\else\expandafter\endinput\fi
+% \end{macrocode}
+% We require the \textsf{web} package to set the dimensions of the page, above,
+% and the \textsf{eforms} package to set links, defined below.
+% \begin{macrocode}
+\RequirePackage{web}
+\RequirePackage{eforms}
+% \end{macrocode}
+% \subsection{Set initial view}
+% There seems to be a slight conflict between \textsf{aeb\_pro} and \textsf{hyperref}
+% when it comes to setting some of the preferences. If \textsf{aeb\_pro} is
+% loaded, we'll use \textsf{aeb\_pro}, otherwise, we use \textsf{hyperref}.
+% \begin{macrocode}
+\@ifpackageloaded{aeb_pro}{%
+ \DeclareInitView{%
+ layoutmag={pagelayout=TwoColumnLeft,mag=FitWidth},
+ windowoptions=showtitle}}{%
+ \hypersetup{pdfdisplaydoctitle=true,%
+ pdfstartview=FitH -32768,pdfpagelayout=TwoColumnLeft}}
+% \end{macrocode}
+% \subsection{A title page}
+% \DescribeMacro{\makeinlinetitle}The web defines
+% \cs{makeinlinetitle}, we'll redefine it here
+% for our convenience.
+% \begin{macrocode}
+\ifmob@maketitledefn
+\renewcommand{\makeinlinetitle}
+{%
+ \begingroup\parskip0pt\parindent0pt
+ \par\vspace*{6pt}
+ \noindent\makebox[\linewidth][c]{\bfseries
+ \color{\webuniversity@color}\webuniversity}\par\kern6pt\noindent
+ \makebox[\linewidth][c]{\parbox[c]{.75\linewidth}{\centering
+ \bfseries\color{\webtitle@color}\webtitle}}\par\kern12pt
+ \noindent\parbox{\linewidth}{\scriptsize
+ \web@copyright\space\the\year\hfill\thewebemail\\
+ \@date\hfill\@ifundefined{aeb@talksite}{\webversion}
+ {\ifx\aeb@talksite\@empty\webversion
+ \else\aeb@talksite\fi}%
+ }\par
+ \noindent\makebox[\linewidth]{\rule{.67\linewidth}{.4pt}}%
+ \par\endgroup
+}
+\fi
+% \end{macrocode}
+% \subsection{Redefinitions of {\LaTeX} commands}
+% We redefine \cs{paragraph} and a key-value of \cs{includegraphics}
+% \begin{macrocode}
+\renewcommand{\paragraph}{\edef\mob@partpgraphexp{\noexpand
+ \@startsection{paragraph}{4}{0pt}%
+ {\ifdim\parskip=0pt12pt\else0pt\fi}}%
+ \mob@partpgraphexp{-3pt}{\bfseries}}
+% \end{macrocode}
+% This is an implementation of an idea proposed by Mathias M. He notes that
+% a figure that looks fine when the document is compiled for paper, is too small
+% when compiled for the smartphone. So, he proposes to double the width of the
+% image up to a maximum width of \cs{textwidth}. My implementation is to redefine
+% the key-value command for \cs{includegraphics} from \textsf{graphicx}, to intercept the declared width,
+% and modify its value according to the above description.
+%\changes{v1.1}{2012/06/26}{Added the \cs{mob@adjwidth} command to adjust the width
+% of a graphic}
+%
+% The scaling of figures can be turned on and off by setting the switch
+% \cs{ifmobscalefigures}, as appropriate.
+% \changes{v1.2}{2012/06/28}{Added conditional \cs{ifmobscalefigures}}
+% \begin{macrocode}
+\def\mob@adjwidth#1{\ifmobscalefigures{\dimen0=#1
+ \dimen0=2\dimen0\relax
+ \xdef\mob@djwidth{\expandafter\the
+ \ifdim\dimen0<\textwidth
+ \dimen0 \else\textwidth\fi}%
+ }\else\gdef\mob@djwidth{#1}\fi
+}
+% \end{macrocode}
+% We intercept the width parameter, pass it to \cs{mob@adjwidth}, then
+% use the result to define the graphicx command \cs{Gin@ewidth}.
+% \begin{macrocode}
+\@ifpackageloaded{graphicx}{%
+ \define@key{Gin}{width}{\mob@adjwidth{#1}%
+ \edef\Gin@ewidth{\mob@djwidth}}%
+}{}
+% \end{macrocode}
+% \subsection{Some JavaScript}
+% We define two functions: (1) \texttt{\_printIt()} prints
+% the current document using the default printer in two columns;
+% (2) \texttt{\_toggleViews()} toggles the view between single column
+% and two columns. In both case we use fit width zoom type.
+% \begin{macrocode}
+\begin{insDLJS}[_mobileJS]{mobile}{JS supporting mobile formatting}
+var _mobileJS=true
+function _printIt(){
+ var pp=this.getPrintParams();
+ pp.pageHandling=pp.constants.handling.nUp;
+ pp.nUpPageOrder=pp.constants.nUpPageOrders.Horizontal;
+ pp.nUpNumPagesH=2;
+ pp.nUpPageBorder=false;
+ pp.nUpAutoRotate=false;
+ this.print(pp);
+}
+function _toggleViews() {
+ this.zoomType=zoomtype.fitW;
+ this.layout=(this.layout!="TwoColumnLeft")?%
+"TwoColumnLeft":"OneColumn";
+}
+\end{insDLJS}
+% \end{macrocode}
+% \subsection{Links in running header}
+% \DescribeMacro{\mobPrint}\cs{mobPrint} sets the text of the print link
+% and the button caption if its a push button.
+% \DescribeMacro{\mobToggleCols} \cs{mobToggleCols} sets
+% the text for the toggle link and the button caption if its a push
+% button. \DescribeMacro{\mobPrintTip}\cs{mobPrintTip} is the tool tip
+% when there's a button for the print; while \DescribeMacro{\mobToggleColsTip}
+% \cs{mobToggleColsTip} does the same for the toggle button.
+% \begin{macrocode}
+\newcommand{\mobPrint}[1]{\def\mob@print{#1}}
+\mobPrint{Print}
+\newcommand{\mobPrintTip}{Click to print this document in two-column
+ format, recommended.}
+\newcommand{\mobToggleCols}[1]{\def\mob@toggleCols{#1}}
+\mobToggleCols{Toggle Cols}
+\newcommand{\mobToggleColsTip}{Click to toggle between single-column
+ and two-column page layouts.}
+% \end{macrocode}
+% \paragraph*{German language.} The following are redefinitions supplied
+% by a user in the German language.
+%\begin{verbatim}
+%\mobPrint{Drucken}
+%\renewcommand{\mobPrintTip}{Zum Drucken des Dokumentes hier klicken
+% (zweispaltige Ansicht empfehlenswert).}
+%\mobToggleCols{Spaltenansicht umschalten}
+%\renewcommand{\mobToggleColsTip}{Zum Umschalten der Spaltenansicht
+% (einspaltig oder zweispaltig) hier klicken.}
+%\end{verbatim}
+% \DescribeMacro{\mobFormPresets}\cs{mobFormPresets} is used to set
+% the appearance of the buttons when the \texttt{useforms} option is taken.
+% \begin{macrocode}
+\newcommand{\mobFormPresets}[1]{%
+ \def\mob@FormPresets{#1}}
+\mobFormPresets{\S{S}\BC{}\textSize{8}\autoCenter{n}}
+% \end{macrocode}
+% \DescribeMacro{\mobPrintIt}\DescribeMacro{\mobTwoCols} The commands
+% \cs{mobPrintIt} sets the print link, while \cs{mobTwoCols}
+% does the some for toggling. Each call their respective
+% document level JS. They each have one optional parameter
+% that is use to modify its appearance.
+% \begin{macrocode}
+\newcommand{\mobPrintIt}[1][]{%
+ \ifmob@useforms
+ {\footnotesize\def\ef@btnspcr{}%
+ \settoheight{\@tempdima}{\strut}%
+ \settodepth{\@tempdimb}{\strut}%
+ \addtolength{\@tempdima}{\@tempdimb}%
+ \raisebox{-\@tempdimb}{\pushButton[#1\F{-\FPrint}
+ \TU{\mobPrintTip}
+ \presets{\mob@FormPresets}%
+ \CA{\mob@print}\A{\JS{_printIt();}}%
+ ]{mobPrintIt}{}{\@tempdima}}}\else
+ \setLink[#1\A{\JS{_printIt();}}]{\mob@print}\fi
+}
+% \end{macrocode}
+% \begin{macrocode}
+\newcommand{\mobTwoCols}[1][]{%
+ \ifmob@useforms
+ {\footnotesize\def\ef@btnspcr{}%
+ \settoheight{\@tempdima}{\strut}%
+ \settodepth{\@tempdimb}{\strut}%
+ \addtolength{\@tempdima}{\@tempdimb}%
+ \raisebox{-\@tempdimb}{\pushButton[#1\F{-\FPrint}
+ \TU{\mobToggleColsTip}\presets{\mob@FormPresets}%
+ \CA{\mob@toggleCols}\A{\JS{_toggleViews();}}%
+ ]{mobToggleCols}{}{\@tempdima}}}\else
+ \setLink[#1\A{\JS{_toggleViews();}}]{\mob@toggleCols}\fi
+}
+% \end{macrocode}
+% Here, we set the left header. If you want to change the
+% appearance of the links, you need to execute this next
+% line in the preamble with the optional parameter to change
+% the appearances. This assumes the document is using
+% the page style \texttt{webheadings}, as defined in \textsf{web}.
+% \begin{macrocode}
+\lheader{\mobPrintIt\relax\ifmob@useforms\kern3bp
+ \else\,/\,\fi\mobTwoCols\relax}
+% \end{macrocode}
+% \subsection{Add a page if odd}
+% \DescribeMacro{\generateEvenPage} adds one more page
+% to make an even number of pages. May be redefined as needed.
+% \begin{macrocode}
+\newcommand{\generateEvenPage}{\ifodd\value{page}\else
+ \newpage\lheader{}\null\fi}
+\AtEndDocument{\generateEvenPage}
+%</package>
+% \end{macrocode}
+\endinput
+
+% iPad
+% Landscape
+% w: 7.75in
+% h: 5.8in