summaryrefslogtreecommitdiff
path: root/graphics/pictex-addons/autoarea/autoarea.sty
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/pictex-addons/autoarea/autoarea.sty')
-rw-r--r--graphics/pictex-addons/autoarea/autoarea.sty220
1 files changed, 220 insertions, 0 deletions
diff --git a/graphics/pictex-addons/autoarea/autoarea.sty b/graphics/pictex-addons/autoarea/autoarea.sty
new file mode 100644
index 0000000000..84aa0160a7
--- /dev/null
+++ b/graphics/pictex-addons/autoarea/autoarea.sty
@@ -0,0 +1,220 @@
+%% Macro package `autoarea.sty', supporting but not needing LaTeX2e,
+%% copyright (C) 2008 Uwe Lueck [L\"uck]
+%% http://www.contact-ednotes.sty.de.vu
+%% - author-maintained, extending PiCTeX:
+
+\begingroup\expandafter\expandafter\expandafter\endgroup
+\expandafter\ifx\csname ProvidesPackage\endcsname\relax\else
+ % german.sty trick
+ \ProvidesPackage{autoarea}[2008/08/12 v0.3a
+ automatic accounting for PiCTeX lines and arcs]
+ %
+\fi
+
+% LEGAL/CONTACT
+%
+%% This file can be redistributed and/or modified under the terms
+%% of the LaTeX Project Public License, version 1.3c or later, cf.
+%% http://www.latex-project.org/lppl.txt
+%% -- NO WARRANTY! Please report bugs, problems, and suggestions via
+%% http://www.contact-ednotes.sty.de.vu
+
+% FEATURES/USAGE
+%
+% This is an experimental package for use with pictex[wd].sty/.tex.
+% It works with LaTeX2e as well as with Plain TeX or LaTeX2.09.
+% It is "experimental" in that it has come from a mixture of knowing
+% PiCTeX internals and guesses that surprisingly seem to work.
+%
+% PiCTeX's \plot, \circulararc and \ellipticalarc normally don't contribute to
+% proper placement of the picture between text and margins, which may result
+% in pictures overlapping with text or in uneven distances to text margins.
+% You should find a file autodemo-.pdf nearby that illustrates how this may
+% look.
+%
+% In such cases, the document author must use PiCTeX's \setplotarea to correct
+% this manually, determining the "bounding box" (cf. documentation as indicated
+% after \endinput below). PiCTeX's \put, on the opposite, normally DOES
+% contribute to PiCTeX's automatical calculation of the boundaries.
+%
+% autoarea.sty tries to determine the bounding box even for lines and arcs
+% automatically instead, so you can omit \setplotarea (at least for this
+% purpose). You just have to load it (we hope) after pictex[wd].sty/.tex, by,
+% e.g.,
+%
+% \usepackage{pictexwd,autoarea}
+% or
+% \input pictexwd
+% \input autoarea.sty
+%
+% The package defines just three user commands \plottedat, \autoaccountingoff,
+% and \autoaccountingon - which you perhaps won't need, just loading the
+% package may suffice. The samples autodemo-.pdf and autodemo+.pdf nearby both
+% were generated by omitting \setplotarea, the difference being that
+% autodemo+.pdf profits from \usepackage{autoarea}, which may convince you
+% that it's worth trying autoarea.
+%
+% \plottedat XMIN YMIN \plottedat XMAX YMAX may (otherwise) replace
+% \setplotarea x from XMIN to XMAX, y from YMIN to YMAX
+% A single "\plottedat ..." may suffice if other \put commands
+% contribute to proper placement of the picture sufficiently already.
+
+ \expandafter %% ersatz-\newcommand if without LaTeX
+ \ifx \csname newcommand\endcsname \relax
+ \def\newcommand#1{\def#1} \fi
+
+\newcommand{\plottedat}{\put {} at }
+
+% (If the user doesn't want it, we still need it here!)
+%
+% Should a \plot or \circulararc command seem to produce more space than
+% you want, put it between \autoaccountingoff and \autoaccountingon,
+% then try \plottedat and \setplotarea if needed.
+%
+% Our trick will account for starting, ending, or corner points of curves.
+% This may not suffice in general (e.g., with \setquadratic),
+% then you still may need \plottedat or \setplotarea. Below \endinput you
+% find more on CAVEATS etc.
+
+% INTERNALS
+
+\catcode`\!=11 % use and change PiCTeX internals
+
+\let\PT!!start\!start \let\PT!!ljoin\!ljoin \let\PT!!qjoin\!qjoin
+\def\PTaa!start (#1,#2){\plottedat #1 #2 \PT!!start (#1,#2)}
+\def\PTaa!ljoin (#1,#2){\plottedat #1 #2 \PT!!ljoin (#1,#2)}
+\def\PTaa!qjoin (#1,#2) (#3,#4){%
+ \plottedat #1 #2 \plottedat #3 #4 \PT!!qjoin (#1,#2) (#3,#4)}
+
+\expandafter\ifx\csname newcommand\endcsname \def\newcommand#1{\def#1} \fi
+
+\newcommand{\autoaccountingon}{%
+ \let\!start\PTaa!start \let\!ljoin\PTaa!ljoin \let\!qjoin\PTaa!qjoin}
+
+\newcommand{\autoaccountingoff}{%
+ \let\!start\PT!!start \let\!ljoin\PT!!ljoin \let\!qjoin\PT!!qjoin}
+
+\catcode`\!=12
+
+\autoaccountingon % turns on automatic accounting for lines and arcs.
+
+\endinput %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+CAVEATS
+
+1. I won't try to find out whether autoarea.sty makes \setplotarea entirely
+superfluous: will drawing a coordinate system work without \setplotarea?
+
+2. Certainly it was not due to dullness that PiCTeX didn't provide autoarea's
+feature originally. Around 1990, it was important to care for speed with PiCTeX
+(and it may still be, I won't try complex examples).
+Apart from up to four, line and arc commands are irrelevant for placing the
+picture correctly. About the same holds for put commands, and that's why PiCTeX
+has \accountingoff and \accountingon to ignore many of them. Our \autoaccountingoff
+and \autoaccountingon serve the analoguous purpose for line and arc commands.
+
+3. I don't know exactly how arc commands work, therefore I wouldn't be astonished
+if the result still is not properly centered. Our trick is take account of some
+points all of which an approximating curve must meet. Can that curve bend out of
+the bounding rectangle of those points?
+
+
+ACKNOWLEDGEMENTS
+
+This work has been supported by edition projects at the Institute for
+the History of the Sciences directed by Prof. Dr. Menso Folkerts.
+Thanks to Dr. Richard Lorch for introducing me to the subject.
+
+
+
+CHANGE HISTORY
+
+v0.1 2008/02/14 Working, addressed compatibility with ArabTeX.
+v0.2 2008/02/14a Moved compatibility to lorchpic.sty.
+ This one submitted to CTAN, soon kind of withdrawn.
+v0.3 2008/04/19 Made generic, expanded prose.
+ 2008/04/25 `Lueck', not `Lück', for UNIX etc.
+ 2008/05/07 ersatz-\newcommand earlier, typo;
+ removed remarks on PiCTeX documentation.
+ 2008/05/08 Added version numbers, corrected ersatz-\newcommand;
+ uploaded in pictex_may_2008.zip - in vain.
+v0.3a 2008/08/12 typo fix "too text" -> "to text".
+
+_________________________________________________________________________
+
+FORMER VERSION 2008/02/13 (ul, 2008/02/14):
+
+I couldn't find a working redefinition of \circulararc
+("Use of \ellipticalarc doesn't match its definition");
+on the other hand its internals seem to the job all ready;
+and my redefinition seemed to raise further difficulties.
+Here's what I had tried before:
+
+% \circulararc may do the trick for full circles (360 degree) only.
+% CAVEAT: assumes that x and y units are the same.
+% Otherwise or when something else goes wrong, put \circulararc between
+% \autoaccountingarcoff and \autoaccountingarcon.
+%
+% These features come from the start if you load the present package.
+
+\catcode`\!=11 % use and change PiCTeX internals
+
+\let\PT@@start\!start \let\PT@@ljoin\!ljoin \let\PT@@qjoin\!qjoin
+\def\PTaa@start (#1,#2){\plottedat #1 #2 \PT@@start (#1,#2)}
+\def\PTaa@ljoin (#1,#2){\plottedat #1 #2 \PT@@ljoin (#1,#2)}
+\def\PTaa@qjoin (#1,#2) (#3,#4){%
+ \plottedat #1 #2 \plottedat #3 #4 \PT@@qjoin (#1,#2) (#3,#4)}
+
+\let\PT@@circulararc\circulararc
+\def\PTaa@circulararc #1 degrees from #2 #3 center at #4 #5 {%
+ \ifnum #1=360
+ \!dimenE=#2pt \advance\!dimenE-#4pt
+ \!dimenF=#2pt \advance\!dimenF-#4pt
+ \!Pythag\!dimenE\!dimenF\!dimenG
+ \PTaa@plotcorner{#4}{#5}{-}%
+ \PTaa@plotcorner{#4}{#5}{}%
+ \fi
+ % \PT@@circulararc #1 degrees from #2 #3 center at #4 #5
+ %\PT@@circulararc #1 degrees from #2 #3 center at #4 #5 }
+ \ellipticalarc axes ratio 1:1 360 degrees from 0 25 center at 0 0 }
+ %\ellipticalarc axes ratio 1:1 #1 degrees from #2 #3 center at #4 #5 }
+\def\PTaa@plotcorner#1#2#3{%
+ \!dimenE#1pt \!dimenF#2pt
+ \advance\!dimenE#3\!dimenG \advance\!dimenF#3\!dimenG
+ \!removept\!dimenE\@tempa \!removept\!dimenF\@tempb
+ \edef\@tempc{\noexpand\plottedat \@tempa\space\@tempb}%
+ \@tempc
+}
+% <-:
+% 1. May be \!qjoin of \ellipticalarc does the trick already.
+% 2. FUTURE: \accountingcircle[tbrl] if circle isn't full.
+% 3. CAVEAT: May not work in dimension mode.
+% 4. May be improvable with better knowledge of internals than mine.
+
+\newcommand{\autoaccountingon}{%
+ \let\!start\PTaa@start \let\!ljoin\PTaa@ljoin \let\!qjoin\PTaa@qjoin
+ \autoaccountingarcon}
+\newcommand{\autoaccountingarcon}{\let\circulararc\PTaa@circulararc}
+\newcommand{\autoaccountingoff}{%
+ \let\!start\PT@@start \let\!ljoin\PT@@ljoin \let\!qjoin\PT@@qjoin
+ % <- Yet I can't imagine why this could be needed, just in case ...
+ \autoaccountingarcoff}
+\newcommand{\autoaccountingarcoff}{\let\circulararc\PT@@circulararc}
+
+% \setnone FROM ARABTEX SUFFICES INSTEAD OF:
+%
+% COMPATIBILITY WITH ARABTEX ETC.
+%
+% ArabTeX and possibly other packages may disable PiCTeX commands
+% using "<...,...>" syntax, notably \setcoordinatesystem units <1mm,1mm> etc.
+%% TODO: TeX error:
+% Precede such a command (if it breaks) with \restoreanglesyntax,
+% best after \beginpicture to avoid disabling the other package.
+
+\newcommand{\restoreanglesyntax}{\@makeother\<\@makeother\>}
+
+%% todo: or better "compatibility" package ptangles.sty introducing
+%% syntax without <...>!?
+
+%%% end of file