summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/autoarea/autoarea.sty
blob: 84aa0160a75294c35805fc0eba832bb93f3d8be6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
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