diff options
Diffstat (limited to 'texmf-dist/source/latex/aeb-tilebg/aeb_tilebg.dtx')
-rw-r--r-- | texmf-dist/source/latex/aeb-tilebg/aeb_tilebg.dtx | 236 |
1 files changed, 236 insertions, 0 deletions
diff --git a/texmf-dist/source/latex/aeb-tilebg/aeb_tilebg.dtx b/texmf-dist/source/latex/aeb-tilebg/aeb_tilebg.dtx new file mode 100644 index 00000000..5ed95729 --- /dev/null +++ b/texmf-dist/source/latex/aeb-tilebg/aeb_tilebg.dtx @@ -0,0 +1,236 @@ +% \iffalse +%<*copyright> +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% aeb_tilebg.sty package, %% +%% Copyright (C) 2006--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} +%<package>\ProvidesPackage{aeb_tilebg} +%<package> [2018/04/26 v1.2 Tile a Background (dps)] +%<*driver> +\documentclass{ltxdoc} +\usepackage[colorlinks,hyperindex]{hyperref} +\pdfstringdefDisableCommands{\let\\\textbackslash}% +\EnableCrossrefs \CodelineIndex +\OnlyDescription % comment out for implementation details +\begin{document} + \GetFileInfo{aeb_tilebg.sty} + \title{The \textsf{aeb\_tilebg} Package} + \author{D. P. Story\\ + Email: \texttt{dpstory@acrotex.net}} + \date{processed \today} + \maketitle + \tableofcontents + \let\Email\texttt + \DocInput{aeb_tilebg.dtx} + \PrintIndex +\end{document} +%</driver> +% \fi +% +% \section{Alternate package name: \texorpdfstring{\textsf{aeb-tilebg}}{aeb-tilebg}} +% CTAN lists this package as \textsf{aeb-tilebg}, so might as well have a package +% by that name. +% \changes{v1.2}{2018/04/26}{Added dummy package \string\pkg{aeb-tilebg}} +% \begin{macrocode} +%<*altpkgname> +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{aeb-tilebg} + [2018/04/26 v1.0 aeb-tilebg Alt-name (dps)] +\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{aeb_tilebg}} +\ProcessOptions +\RequirePackage{aeb_tilebg} +% \end{macrocode} +% \begin{macrocode} +%</altpkgname> +% \end{macrocode} +% \section{Main Code} +% \begin{macrocode} +%<*package> +% \end{macrocode} +% \begin{macrocode} +\let\tb@Yes=y \let\tb@No=n +\DeclareOption{uselltiling}{% + \AtEndOfPackage{% + \let\aeb@currentTileBkgrd\aeb@TileBkgrdLL}% +} +\DeclareOption{draft}{\let\aeb@tilebg@draft\tb@Yes + \AtEndOfPackage{\aeb@DraftMode}} +\let\aeb@tilebg@draft\tb@No +\DeclareOption{ignoreforpaper}{\let\aeb@tilebg@ignoreforpaper\tb@Yes} +\let\aeb@tilebg@ignoreforpaper\tb@No +\ProcessOptions +\ifeqforpaper + \ifx\aeb@tilebg@draft\tb@No + \ifx\aeb@tilebg@ignoreforpaper\tb@No + \AtEndOfPackage{\aeb@DraftMode}% +\fi\fi\fi +% \end{macrocode} +% The package requires \textsf{web}, and compiling is stopped unless the author uses web. Web is +% used for the template management. Also required are the \textsf{graphicx} and \textsf{multido} packages. +% \begin{macrocode} +\@ifpackageloaded{web}{}{% + \PackageError{web}{% + The web package is required for this package% + }{% + Add the web package with the usetemplates option\MessageBreak + in the preamble above this package. + }% +} +\RequirePackage{graphicx} +\RequirePackage{multido} +\def\@gobblesix{\expandafter\@gobbletwo\@gobblefour} +\def\aeb@DraftMode{\let\setTileBgGraphic\aeb@setTileBgGraphicDraft +\let\autosetScreensizeWithMargins\@gobblesix +\let\aeb@TileBkgrd\@empty\disableTiling} +\let\turnOffTiling\aeb@DraftMode +% \end{macrocode} +% \begin{macrocode} +\newbox\aeb@tilingbox +\newdimen\aeb@tiledim +% \end{macrocode} +% \begin{macro}{\setTileBgGraphic} +% This is the main user command. The second argument is the path to the graphics file +% used for tiling, and the first are the optional parameters of \cs{includegraphics}. +% We use, by default, the \texttt{hiresbb} option of \cs{includegraphics}. +% \begin{macrocode} +\newcommand{\aeb@setTileBgGraphicFinal}[2][1]{% + \let\aeb@TileBkgrd\aeb@currentTileBkgrd + \edef\aeb@tile@hbox{% + \hbox{\noexpand\includegraphics[hiresbb,#1]{#2}}}% + \global\setbox\aeb@tilingbox\aeb@tile@hbox + \xdef\tileboxwidth{\strip@pt\wd\aeb@tilingbox}% + \xdef\tileboxheight{\strip@pt\ht\aeb@tilingbox}% + \xdef\tilewidth{\the\wd\aeb@tilingbox}% + \xdef\tileheight{\the\ht\aeb@tilingbox} +} +\newcommand{\aeb@setTileBgGraphicDraft}[2][1]{} +\let\setTileBgGraphic\aeb@setTileBgGraphicFinal +% \end{macrocode} +% \end{macro} +% \begin{macro}{\maxiterations} +% For multido, the number of iterations must be specified in advance. We use +% \cs{multidostop} to break out of an multido loop early, but we need a number +% here. By default it is set at 10. Increase as needed. +% \begin{macrocode} +\newcommand{\maxiterations}[1]{\def\aebtile@maxiterations{#1}} +\maxiterations{10} +% \end{macrocode} +% \end{macro} +%\DescribeMacro\placeTilesinLayers places the tiles in a layer, provided the \texttt{uselayers} +% option is used with \textsf{aeb\_pro} loaded. Added 2015/08/22. +%\changes{v1.1}{2015/08/22}{Added \cs{placeTilesinLayers}} +% \begin{macrocode} +\newcommand{\placeTilesinLayers}[2][tileBG]{% + \@ifpackageloaded{aeb_pro} + {\@ifundefined{xBld}{\PackageWarning{aeb_tilebg} + {The uselayers option + of aeb_pro is\MessageBreak required with + \string\placeTilesinLayers}} + {\def\b@tileLayer{\xBld[#2]{#1}}\def\e@tileLayer{\eBld}}} + {\PackageWarning{aeb_tilebg}{\string\placeTilesinLayers\space + requires the\MessageBreak aeb_pro package}}% +} +\let\b@tileLayer\@empty \let\e@tileLayer\@empty +% \end{macrocode} +% The next two commands are internal. They display the tile graphic on the background +% starting at the upper-left corner of the screen page, and lower-left of the screen page, +% respectively. The default is to start in the upper-left corner. This routine, however, +% uses real arithmetic and may be subject to rounding errors. If the effect is too bad, change +% over to lower-left, by selecting the \texttt{uselltiling} option, or by using \cs{switchtoLLTiling}. +% \begin{macrocode} +\newcommand{\aeb@TileBkgrdUL}{% + \aeb@tiledim=\paperheight + \advance\aeb@tiledim-\tileheight + \xdef\aeb@startingHeight{\strip@pt\aeb@tiledim}% + \b@tileLayer\multido{\rj=\aeb@startingHeight+-\tileboxheight} + {\aebtile@maxiterations}{% + \ifdim\rj pt < -\tileheight \multidostop\else + \multido{\ri=0+\tileboxwidth}{\aebtile@maxiterations}{% + \ifdim\ri pt > \textscreenwidth\multidostop\else + \put(\ri,\rj){\copy\aeb@tilingbox}\fi}\fi}\e@tileLayer +} +\newcommand{\aeb@TileBkgrdLL}{\b@tileLayer + \multido{\nj=0+\tileboxheight}{\aebtile@maxiterations}{% + \ifdim\nj pt > \paperheight\multidostop\else + \multido{\ni=0+\tileboxwidth}{\aebtile@maxiterations}{% + \ifdim\ni pt > \textscreenwidth\multidostop\else + \put(\ni,\nj){\copy\aeb@tilingbox}\fi}\fi}\e@tileLayer +} +% \end{macrocode} +% The default is to start in the upper-left corner +% \begin{macrocode} +\let\aeb@TileBkgrd\@empty +\let\aeb@currentTileBkgrd\aeb@TileBkgrdUL +%\let\aeb@TileBkgrd\aeb@TileBkgrdUL +% \end{macrocode} +% Now set the current definition \cs{aeb@TileBkgrd} as a template managed by web. +% \begin{macrocode} +\AddToTemplate{aeb@TileBkgrd} +%\disableTemplate{aeb@TileBkgrd} +% \end{macrocode} +% That's pretty much it for this package; however, we include a few extras. +% \begin{macro}{\autosetScreensizeWithMargins} +% If you want to get fancy, you can have this package automatically set the screen size +% to fit exactly n rows and m columns of the tiling. This may take some experimentation +% to get the width and height you want along with the effect. Adjust the scale (or width or height) +% parameter as needed. The arguments are +%\begin{enumerate} +%\item \texttt{\#1}: number of rows +%\item \texttt{\#2}: number of columns +%\item \texttt{\#3}: length of left margin +%\item \texttt{\#4}: length of right margin +%\item \texttt{\#5}: length of top margin +%\item \texttt{\#6}: length of bottom margin +%\end{enumerate} +% The latter four parameters are passed in that order to the \cs{margins} command of +% the web package. Standard values are, respectively, \texttt{.25in}, \texttt{.25in}, \texttt{24pt}, \texttt{.25in}. +% +% The \cs{autosetScreensizeWithMargins} command can only be used once in the preamble, and a design +% specification should not be made in the optional parameters of web. +% \begin{macrocode} +\newcommand{\autosetScreensizeWithMargins}[6] +{% + \paperwidth=\tilewidth + \paperwidth=#2\paperwidth + \edef\theReqWidth{\the\paperwidth}% + \paperheight=\tileheight + \paperheight=#1\paperheight + \edef\theReqHeight{\the\paperheight}% + \margins@web@save{#3}{#4}{#5}{#6}% + \screensize@web@save{\theReqHeight}{\theReqWidth} % height, width +} +\@onlypreamble\autosetScreensizeWithMargins +% \end{macrocode} +% \end{macro} +% \begin{macro}{\disableTiling} +% \begin{macro}{\enableTiling} +% Disable/enable tiling, effective on the current page. +% \begin{macrocode} +\newcommand{\disableTiling}{\disableTemplate{aeb@TileBkgrd}} +\newcommand{\enableTiling}{\enableTemplate{aeb@TileBkgrd}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \begin{macro}{\switchtoLLTiling} +% \begin{macro}{\switchtoULTiling} +% Switch how tile are placed on the page. +% \begin{macrocode} +\newcommand{\switchtoLLTiling}{\let\aeb@TileBkgrd\aeb@TileBkgrdLL} +\newcommand{\switchtoULTiling}{\let\aeb@TileBkgrd\aeb@TileBkgrdUL} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \begin{macrocode} +%</package> +% \end{macrocode} +% \Finale +\endinput |