diff options
author | Karl Berry <karl@freefriends.org> | 2014-01-07 23:07:05 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2014-01-07 23:07:05 +0000 |
commit | 57d395428d45725bb0bae19829460622dbbb124f (patch) | |
tree | 9d944e5b0c4f73b721323ab19758a7b83a0bf4c6 /Master/texmf-dist/tex/latex | |
parent | ea751c100642b9b81c97ad32b1b492c917d5a93c (diff) |
scanpages (7jan14)
git-svn-id: svn://tug.org/texlive/trunk@32600 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex')
-rw-r--r-- | Master/texmf-dist/tex/latex/scanpages/scanpages.sty | 143 |
1 files changed, 143 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/scanpages/scanpages.sty b/Master/texmf-dist/tex/latex/scanpages/scanpages.sty new file mode 100644 index 00000000000..2e4dd3833f2 --- /dev/null +++ b/Master/texmf-dist/tex/latex/scanpages/scanpages.sty @@ -0,0 +1,143 @@ +\NeedsTeXFormat{LaTeX2e} + +% A package to help make a document based on scanned pages. +% +% Copyright (c) 2014 by Michael Sharpe, msharpe at ucsd dot edu; +% This is free software, subject to the LATEX Project Public License. + +\def\fileversion{1.00} +\def\filedate{2014/01/06} +\ProvidesPackage{scanpages.sty}[\filedate\space v\fileversion] + +\message{`scanpages' v\fileversion, \filedate\space Macros to help create documents from scanned pages(msharpe)} +% +\RequirePackage{ifpdf} +\RequirePackage{pgffor} +\RequirePackage{xcolor} +\RequirePackage{keyval} +\RequirePackage{fp-basic} +\RequirePackage{graphicx} +\RequirePackage{etoolbox} +\ifpdf\else + \@latex@error{Must be processed in pdf[la]tex!}\@eha +\fi +\newif\ifscanp@nogrid +\define@boolkey{scanp}{nogrid}[true]{% +\csname scanp@nogrid#1\endcsname} +\def\scanp@origscale{1.0} +\def\scanp@srcscale{1.0} +\def\scanp@invscale{1.0} +\define@key{scanp}{scale}[1.0]{\def\scanp@srcscale{#1}} +\def\scanp@llx{1in} +\def\scanp@lly{1in} +\def\scanp@srcw{400\p@} +\def\scanp@srch{600\p@} +\define@key{scanp}{llx}[0]{\def\scanp@llx{#1}}% +\define@key{scanp}{lly}[0]{\def\scanp@lly{#1}}% +\define@key{scanp}{w}[0]{\def\scanp@srcw{#1}}% +\define@key{scanp}{h}[0]{\def\scanp@srch{#1}}% +\DeclareOption*{% + \begingroup + \edef\x{\endgroup + \noexpand\setkeys{scanp}{\CurrentOption}}% + \x} +\ProcessOptions* + +\setlength\unitlength{1bp} +\long\def\putn(#1,#2)#3{% + \@killglue% + \dimen0\@picht\advance\dimen0 -#2\unitlength% + \raise\dimen0\hb@xt@\z@{\kern#1\unitlength #3\hss} + \ignorespaces} +\def\bp@ratio{.99264} % factor to multiply num of pt to get num of bp +\def\unitlength@off{\let\@unitlength\ignorespaces\ignorespaces} +\def\scanp@setlength#1#2{% if #2 has no dimension, append dimension + \let\@unitlength\unitlength + \afterassignment\unitlength@off + #1 #2\@unitlength% +} +\def\scanp@addtolength#1#2{% if #2 has no dimension, append dimension + \let\@unitlength\unitlength + \afterassignment\unitlength@off + \advance#1 #2\@unitlength% +} +\newdimen\scanp@dwdim\newdimen\scanp@dhdim % dest width and height +\newdimen\scanp@swdim\newdimen\scanp@shdim % src width and height +\newdimen\scanp@dwdimbp\newdimen\scanp@dhdimbp % dest width and height in bp +\newdimen\scanp@xindent\newdimen\scanp@yindent +\newdimen\scanp@xl\newdimen\scanp@yl\newdimen\scanp@xr\newdimen\scanp@yr +\newdimen\scanp@xlbp\newdimen\scanp@ylbp\newdimen\scanp@xrbp\newdimen\scanp@yrbp\newdimen\@dima +% +\def\initviewport#1#2#3#4#5{% srcscale,llx,lly,srcw,srch +\FPdiv\scanp@invscale{1.0}{\scanp@srcscale} +\scanp@setlength{\scanp@swdim}{\scanp@srcw} +\scanp@setlength{\scanp@shdim}{\scanp@srch} +\scanp@dwdim=\scanp@srcscale\scanp@swdim +\scanp@dhdim=\scanp@srcscale\scanp@shdim +\scanp@dwdimbp=\bp@ratio\scanp@dwdim +\scanp@dhdimbp=\bp@ratio\scanp@dhdim +\scanp@setlength{\scanp@xl}{#2} +\scanp@setlength{\scanp@yl}{#3} +\scanp@xr=\scanp@xl \advance\scanp@xr\scanp@swdim +\scanp@yr=\scanp@yl \advance\scanp@yr\scanp@shdim +\scanp@xindent=\textwidth \scanp@yindent=\textheight +\advance\scanp@xindent -\scanp@dwdim\advance\scanp@yindent -\scanp@dhdim +\scanp@xindent=0.5\scanp@xindent\scanp@yindent=0.5\scanp@yindent +\advance\scanp@yindent -14\p@ +} +\initviewport{\scanp@srcscale}{\scanp@llx}{\scanp@lly}{\scanp@srcw}{\scanp@srcw} +% +\define@key{scanpi}{dx}{\def\scanp@dx{#1}} +\define@key{scanpi}{dy}{\def\scanp@dy{#1}} +\define@key{scanpi}{page}{\def\scanp@page{#1}} +\define@key{scanpi}{rot}{\def\scanp@rot{#1}} +\define@key{scanpi}{tanrot}{\def\scanp@skew{#1}} +\newdimen\scanp@dxdim\newdimen\scanp@dydim + +\def\scanpage{\@ifnextchar[\scanpage@i{\scanpage@i[]}} +\def\scanpage@i[#1]#2{{\setkeys{scanpi}{#1}% +\edef\scanp@head{\noexpand\vspace*{\scanp@yindent}\noexpand\noindent\noexpand\hspace*{\scanp@xindent}\noexpand\picture(\strip@pt\scanp@dwdimbp,\strip@pt\scanp@dhdimbp)} +%\edef\@x{\strip@pt\scanp@dwdimbp}\edef\@y{\strip@pt\scanp@dhdimbp} +%\vspace*{\the\scanp@yindent}\noindent\hspace*{\scanp@xindent}\picture(\@x,\@y) +\ifdefvoid{\scanp@dx}{}{\scanp@setlength\scanp@dxdim{-\scanp@dx}\scanp@dxdim=\scanp@invscale\scanp@dxdim\advance\scanp@xl \scanp@dxdim \advance\scanp@xr \scanp@dxdim} +\ifdefvoid{\scanp@dy}{}{\scanp@setlength\scanp@dydim{-\scanp@dy}\scanp@dydim=\scanp@invscale\scanp@dydim\advance\scanp@yl \scanp@dydim \advance\scanp@yr \scanp@dydim} +\scanp@xlbp=\bp@ratio\scanp@xl +\scanp@xrbp=\bp@ratio\scanp@xr +\scanp@ylbp=\bp@ratio\scanp@yl +\scanp@yrbp=\bp@ratio\scanp@yr +\edef\scanp@cmd{viewport=\strip@pt\scanp@xlbp\space\strip@pt\scanp@ylbp\space\strip@pt\scanp@xrbp\space\strip@pt\scanp@yrbp, clip]{#2}} +\ifdefvoid{\scanp@rot}{% +\ifdefvoid{\scanp@skew}{}{% + \@dima=\scanp@skew\p@\@dima=57.14\@dima\edef\scanp@cmd{angle=\strip@pt\@dima,origin=c,\scanp@cmd}}}{\edef\scanp@cmd{angle=\scanp@rot,origin=c,\scanp@cmd}}% +\if\scanp@srcscale\scanp@origscale\else\edef\scanp@cmd{scale=\scanp@srcscale,\scanp@cmd}\fi +\ifdefvoid{\scanp@page}{}{\edef\scanp@cmd{page=\scanp@page,\scanp@cmd}} +\edef\scanp@cmd{\noexpand\scanp@head\noexpand\put(0,0){\noexpand\includegraphics[\scanp@cmd}} +%\show\scanp@cmd% +\scanp@cmd +\thegrid{\strip@pt\scanp@dwdimbp}{\strip@pt\scanp@dwdimbp} +\endpicture +\newpage}} + +\ifscanp@nogrid\def\thegrid#1#2{}\else% +\long\def\thegrid#1#2{\edef\scanp@gcmd{\noexpand\put(0,0){\noexpand\line(1,0){#1}} +\noexpand\put(0,0){\noexpand\line(0,1){#2}} +\noexpand\put(#1,0){\noexpand\line(0,1){#2}} +\noexpand\put(0,#2){\noexpand\line(1,0){#1}}} +\foreach\x in{-400,-390,...,800}{% + \put(-400,\x){\color{red!20}\line(1,0){1000}}% + } +\foreach\x in {-300,-290,...,550}{% + \put(\x,-500){\color{red!20}\line(0,1){1500}}% +} +\foreach\x in{-400,-350,...,800}{% + \put(-400,\x){\color{red!50}\line(1,0){1000}}% + \put(-20,\x){\x} + } +\foreach\x in {-300,-250,...,550}{% + \put(\x,-500){\color{red!50}\line(0,1){1500}}% + \put(\x,-15){\x}% +\scanp@gcmd% +}} +\fi % end \ifscanp@nogrid + +\endinput
\ No newline at end of file |