PageRenderTime 64ms CodeModel.GetById 34ms RepoModel.GetById 0ms app.codeStats 0ms

/Master/texmf-dist/tex/latex/textpos/textpos.sty

https://bitbucket.org/preining/tex-live
TeX | 360 lines | 322 code | 1 blank | 37 comment | 1 complexity | c9122f89adbee982aa8aa0865280c20e MD5 | raw file
  1. %%
  2. %% This is file `textpos.sty',
  3. %% generated with the docstrip utility.
  4. %%
  5. %% The original source files were:
  6. %%
  7. %% textpos.dtx (with options: `package')
  8. %% Textpos: absolute positioning of text on the page
  9. %% This software is copyright, 1999, 2001--2003, 2005-7, 2009-12 Norman Gray.
  10. %%
  11. %% This program is free software; you can redistribute it and/or
  12. %% modify it under the terms of the GNU General Public License
  13. %% as published by the Free Software Foundation; either version 2
  14. %% of the License, or (at your option) any later version.
  15. %%
  16. %% This program is distributed in the hope that it will be useful,
  17. %% but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. %% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. %% GNU General Public License for more details.
  20. %%
  21. %% You should have received a copy of the GNU General Public License
  22. %% along with this program; if not, write to the Free Software
  23. %% Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  24. %%
  25. %% Author: Norman Gray, norman@astro.gla.ac.uk.
  26. %% Department of Physics and Astronomy, University of Glasgow, UK
  27. %%
  28. %% See the file LICENCE for a copy of the GPL.
  29. %% You can also find an online copy at http://www.gnu.org/copyleft/gpl.html .
  30. %%
  31. %% Mercurial ident: 67a1f060e5fa, 2012-11-13 15:31 +0000
  32. %%
  33. \NeedsTeXFormat{LaTeX2e}
  34. \ProvidesPackage{textpos}[2012/11/13 v1.7i]
  35. \typeout{Package: textpos 2012/11/13 1.7i, absolute positioning of text on the page}
  36. \newif\ifTPshowboxes
  37. \TPshowboxesfalse
  38. \DeclareOption{showboxes}{\TPshowboxestrue}
  39. \newif\ifTP@showtext
  40. \TP@showtexttrue
  41. \DeclareOption{noshowtext}{\TP@showtextfalse}
  42. \newif\ifTP@abspos
  43. \TP@absposfalse
  44. \DeclareOption{absolute}{\TP@abspostrue}
  45. \newif\ifTP@overlay
  46. \TP@overlayfalse
  47. \DeclareOption{overlay}{\TP@overlaytrue}
  48. \newif\ifTP@chatter
  49. \TP@chattertrue
  50. \DeclareOption{quiet}{\TP@chatterfalse}
  51. \DeclareOption{verbose}{\TP@chattertrue}
  52. \ProcessOptions
  53. \ifTP@abspos
  54. \RequirePackage{everyshi}
  55. \fi
  56. \def\TP@xfloat#1[#2]{
  57. \par\def\@captype{#1}%
  58. \@floatpenalty\z@
  59. \color@vbox
  60. \normalcolor
  61. \vbox\bgroup
  62. }
  63. \def\TP@xympar{
  64. \PackageError{textpos}
  65. {You can't use \protect\marginpar\space within a textblock}
  66. {You're using textpos because you _don't_ want things to float around, yes?}}
  67. \newbox\TP@textbox
  68. \ifTP@abspos
  69. \newbox\TP@holdbox % starts off void
  70. \AtEndDocument{\ifvoid\TP@holdbox \else \hbox{}\fi}
  71. \fi
  72. \newdimen\TPHorizModule
  73. \newdimen\TPVertModule
  74. \newdimen\TP@margin
  75. \TP@margin=0pt
  76. \newdimen\TP@absmargin
  77. \TP@absmargin=0pt
  78. \newcommand{\TPMargin}{%
  79. \@ifstar\TPMargin@outer\TPMargin@inner
  80. }
  81. \newcommand{\TPMargin@inner}[1]{%
  82. \TP@margin=#1\relax
  83. \ifdim\TP@margin < 0pt
  84. \PackageError{textpos}
  85. {\protect\TPMargin\space must have a positive argument}
  86. {\protect\TPMargin\space must have a positive argument}
  87. \fi
  88. \TP@absmargin=\TP@margin
  89. }
  90. \newcommand\TPMargin@outer[1]{%
  91. \TP@margin=-#1\relax
  92. \ifdim\TP@margin > 0pt
  93. \PackageError{textpos}
  94. {\protect\TPMargin*\space must have a positive argument}
  95. {\protect\TPMargin*\space must have a positive argument}
  96. \fi
  97. \TP@absmargin=-\TP@margin
  98. }
  99. \def\TPGrid{%
  100. \@ifnextchar[{\@tempswatrue\TP@Grid}{\@tempswafalse\TP@Grid[0pt,0pt]}}
  101. \def\TP@Grid[#1,#2]#3#4{
  102. \setlength{\@tempdima}{#1}
  103. \multiply\@tempdima by 2
  104. \TPHorizModule=\paperwidth
  105. \advance\TPHorizModule by -\@tempdima
  106. \divide\TPHorizModule by #3
  107. \setlength{\@tempdima}{#2}
  108. \multiply\@tempdima by 2
  109. \TPVertModule=\paperheight
  110. \advance\TPVertModule by -\@tempdima
  111. \divide\TPVertModule by #4
  112. \ifTP@chatter
  113. \typeout{Grid set #3 x #4 = \the\TPHorizModule\space x \the\TPVertModule}%
  114. \fi
  115. \ifTP@abspos\if@tempswa \textblockorigin{#1}{#2}\fi\fi
  116. }
  117. \TPGrid{16}{16}
  118. \newdimen\TPboxrulesize
  119. \setlength{\TPboxrulesize}{0.4pt}
  120. \def\showtextsize{\normalsize}
  121. \ifTP@abspos
  122. \newdimen\TP@ox
  123. \newdimen\TP@oy
  124. \fi
  125. \def\textblockorigin#1#2{%
  126. \ifTP@abspos
  127. \TP@ox=-1in \addtolength\TP@ox{#1}
  128. \TP@oy=-1in \addtolength\TP@oy{#2}
  129. \ifTP@chatter\typeout{TextBlockOrigin set to #1 x #2}\fi
  130. \else
  131. \PackageError{textpos}
  132. {The \protect\textblockorigin\space command\MessageBreak
  133. may only be used if the package was given\MessageBreak
  134. the`absolute' option when it was invoked}
  135. {If you want to use the \protect\textblockorigin\space command, then
  136. \MessageBreak
  137. invoke the package with the syntax\MessageBreak
  138. \protect\usepackage[absolute]{textpos}}
  139. \fi
  140. }
  141. \def\textblocklabel#1{\gdef\TP@textblocklabel{#1}}
  142. \def\textblockcolour#1{%
  143. \@ifundefined{color}%
  144. {\PackageWarning{textpos}{command textblockcolour used,\MessageBreak
  145. but {color} package not loaded.\MessageBreak
  146. Colour changes ignored.}}
  147. {\gdef\TP@blockcolour{#1}
  148. \ifx\TP@defaultblockcolour\@undefined
  149. \gdef\TP@defaultblockcolour{#1}
  150. \fi
  151. }}
  152. \def\TP@blockcolour{} % safe initial default
  153. \let\textblockcolor\textblockcolour
  154. \let\tekstblokkulur\textblockcolour
  155. \def\textblockrulecolour#1{%
  156. \@ifundefined{color}%
  157. {\PackageWarning{textpos}{command textblockrulecolour used,\MessageBreak
  158. but {color} package not loaded.\MessageBreak
  159. Colour changes ignored.}}
  160. {\gdef\TP@rulecolour{#1}}}
  161. \def\TP@rulecolour{black}
  162. \let\textblockrulecolor\textblockrulecolour
  163. \let\tekstblokroolkulur\textblockrulecolour
  164. \gdef\TP@color[#1]#2{}
  165. \def\TP@checkdummycolorpackage{%
  166. \@ifundefined{color}%
  167. {\globaldefs=1
  168. \DeclareRobustCommand\color[2][]{}%
  169. \def\color@block##1##2##3{}%
  170. \globaldefs=0 }{}%
  171. \global\let\TP@checkdummycolorpackage\relax % don't come here again
  172. }
  173. \def\textblock#1{%
  174. \@tempdima=#1\TPHorizModule
  175. \ifvmode\else
  176. \ifmmode
  177. \PackageError{textpos}
  178. {You cannot use textblock in maths mode}
  179. {You may use the textblock environment only in \MessageBreak
  180. vertical mode or horizontal mode (when it triggers a\MessageBreak
  181. new paragraph). You cannot use it in maths mode.}
  182. \else % in horizontal mode
  183. \par % force us back into vertical mode
  184. \fi
  185. \fi
  186. \@ifnextchar[{\TP@textblock}{\TP@textblock[0,0]}%] bracematch
  187. }
  188. \def\TP@textblockstar#1{%
  189. \setlength{\@tempdima}{#1}
  190. \ifvmode\else
  191. \PackageWarning{textpos}{environment textblock* not in vertical mode.
  192. \MessageBreak
  193. Environment textblock* should not have any text\MessageBreak
  194. or printable material appearing before it.\MessageBreak
  195. Alignment may work out wrongly.}%
  196. \par % force us back into vertical mode
  197. \fi
  198. \@ifnextchar[{\TP@textblock}{\TP@textblock[0,0]}%] bracematch
  199. }
  200. \expandafter\let\csname textblock*\endcsname\TP@textblockstar
  201. \newtoks\TP@tbargs
  202. \def\TP@textblock[#1,#2](#3,#4){%
  203. \TP@tbargs={{#1}{#2}{#3}{#4}}%
  204. \let\@xfloat\TP@xfloat
  205. \let\@xympar\TP@xympar
  206. \setbox\TP@textbox=\vbox\bgroup
  207. \ifTPshowboxes
  208. \TP@checkdummycolorpackage
  209. {\color{\TP@rulecolour}\hrule height0pt depth \TPboxrulesize }%
  210. \vskip-\TPboxrulesize
  211. \fi
  212. \ifdim\TP@margin = 0pt
  213. \hsize=\@tempdima
  214. \textwidth\hsize \columnwidth\hsize \linewidth\hsize
  215. \else
  216. \vskip\TP@absmargin
  217. \@tempdimb=\@tempdima % \@tempdimb is outer box width
  218. \hsize=\@tempdima % \hsize is inner box width
  219. \ifdim\TP@margin < 0pt
  220. \advance\@tempdimb by 2\TP@absmargin % bigger box
  221. \else
  222. \advance\hsize by -2\TP@absmargin % narrower content
  223. \fi
  224. \hbox to \@tempdimb\bgroup
  225. \hskip\TP@absmargin\vbox\bgroup
  226. \textwidth\hsize \columnwidth\hsize \linewidth\hsize
  227. \fi
  228. }
  229. \def\endtextblock{\global\@tempswatrue\TP@commonendtextblock}
  230. \@namedef{endtextblock*}{\global\@tempswafalse\TP@commonendtextblock}
  231. \newdimen\TP@prevdepth
  232. \def\TP@commonendtextblock{%
  233. \ifdim\TP@margin = 0pt
  234. \relax
  235. \else
  236. \egroup % end of inner vbox
  237. \hskip\TP@absmargin
  238. \egroup % end of inner hbox
  239. \vskip \TP@absmargin
  240. \fi
  241. \ifTPshowboxes
  242. \vskip-\TPboxrulesize
  243. {\color{\TP@rulecolour}\hrule depth 0pt height \TPboxrulesize}%
  244. \fi
  245. \egroup % end of \TP@textbox
  246. \TP@prevdepth=\prevdepth
  247. \prevdepth=-1000pt % = \nointerlineskip
  248. \expandafter\TP@endtextblock\the\TP@tbargs
  249. }
  250. \def\TP@endtextblock#1#2#3#4{%
  251. \if@tempswa % modular/unstarred endtextblock
  252. \@tempdima=#3\TPHorizModule
  253. \@tempdimb=#4\TPVertModule
  254. \else % absolute/starred endtextblock
  255. \setlength{\@tempdima}{#3}
  256. \setlength{\@tempdimb}{#4}
  257. \fi
  258. \ifdim\TP@margin < 0pt
  259. \advance\@tempdima \TP@margin
  260. \advance\@tempdimb \TP@margin
  261. % #1,#2 are proportions of \TP@textbox size
  262. \@tempdimc=-#1\wd\TP@textbox
  263. \advance\@tempdima\@tempdimc
  264. \@tempdimc=-#2\ht\TP@textbox
  265. \advance\@tempdimb\@tempdimc
  266. \else
  267. % \TP@margin is positive
  268. % #1,#2 are proportions of \TP@framebox size = \TP@textbox+2\TP@margin
  269. \@tempdimc=\wd\TP@textbox
  270. \advance\@tempdimc 2\TP@margin
  271. \@tempdimc=#1\@tempdimc
  272. \advance\@tempdima -\@tempdimc
  273. \@tempdimc=\ht\TP@textbox
  274. \advance\@tempdimc 2\TP@margin
  275. \@tempdimc=#2\@tempdimc
  276. \advance\@tempdimb -\@tempdimc
  277. \fi
  278. \ifTP@abspos
  279. \advance\@tempdima by \TP@ox
  280. \advance\@tempdimb by \TP@oy
  281. \fi
  282. \setbox0=\vbox to 0pt{\vskip\@tempdimb
  283. \hbox to 0pt{\hskip\@tempdima
  284. \ifx\TP@blockcolour\@empty \else
  285. {\TP@checkdummycolorpackage
  286. \color{\TP@blockcolour}%
  287. \color@block{\wd\TP@textbox}{\ht\TP@textbox}{\dp\TP@textbox}%
  288. }%
  289. \fi
  290. \ifx\TP@defaultblockcolour\@undefined \else
  291. \global\let\TP@blockcolour\TP@defaultblockcolour
  292. \fi
  293. \ifTPshowboxes
  294. {\color{\TP@rulecolour}\vrule width \TPboxrulesize}%
  295. \hskip -\TPboxrulesize
  296. \fi
  297. \ifTP@showtext
  298. \box\TP@textbox
  299. \else
  300. \vbox to\ht\TP@textbox{%
  301. \ifTPshowboxes
  302. {\color{\TP@rulecolour}\hrule depth 0pt height \TPboxrulesize \vskip-\TPboxrulesize}%
  303. \fi
  304. \vskip\smallskipamount
  305. \hbox to\wd\TP@textbox{%
  306. \ifx\TP@textblocklabel\undefined
  307. \hbox{}%
  308. \else
  309. \hskip\smallskipamount
  310. \fbox{\showtextsize \TP@textblocklabel}%
  311. \global\let\TP@textblocklabel\undefined
  312. \fi
  313. \hss
  314. }%
  315. \vss
  316. \ifTPshowboxes
  317. \vskip -\TPboxrulesize
  318. {\color{\TP@rulecolour}\hrule depth 0pt height \TPboxrulesize}%
  319. \fi
  320. }%
  321. \fi
  322. \ifTPshowboxes
  323. \hskip -\TPboxrulesize
  324. {\color{\TP@rulecolour}\vrule width \TPboxrulesize}%
  325. \fi
  326. \hss}%
  327. \vss
  328. }% end of box0
  329. \ifTP@abspos
  330. \global\setbox\TP@holdbox\vbox{%
  331. \unvbox\TP@holdbox
  332. \box0
  333. }%
  334. \else
  335. \box0
  336. \prevdepth=\TP@prevdepth
  337. \fi
  338. }%
  339. \ifTP@abspos
  340. \ifTP@overlay
  341. \EveryShipout{%
  342. \global\setbox\@cclv\vbox{%
  343. \vbox to 0pt{\ifvbox\@cclv \unvbox\@cclv \else \box\@cclv \fi \vss}%
  344. \unvbox\TP@holdbox % TP@holdbox is now void
  345. }
  346. }%
  347. \else
  348. \EveryShipout{%
  349. \global\setbox\@cclv\vbox{%
  350. \unvbox\TP@holdbox
  351. \ifvbox\@cclv \unvbox\@cclv \else \box\@cclv \fi
  352. }%
  353. }%
  354. \fi
  355. \textblockorigin{0pt}{0pt}%
  356. \fi
  357. \endinput
  358. %%
  359. %% End of file `textpos.sty'.