summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/xymtex/base/sizeredc.dtx
blob: fd6bf49f35ae327307b2a07def952949792b6176 (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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
% \iffalse meta-comment
%% File: sizeredc.dtx
%
%  Copyright 1996, 2001, 2002, 2004, 2010 by Shinsaku Fujita
%
%  This file is part of XyMTeX system.
%  -------------------------------------
%
% This file is a part of the macro package ``XyMTeX'' which has been 
% designed for typesetting chemical structural formulas.
%
% This file is to be contained in the ``xymtex'' directory which is 
% an input directory for TeX. It is a LaTeX optional style file and 
% should be used only within LaTeX, because several macros of the file 
% are based on LaTeX commands. 
%
% For the review of XyMTeX, see
%  (1)  Shinsaku Fujita, ``Typesetting structural formulas with the text
%    formatter TeX/LaTeX'', Computers and Chemistry, in press.    
% The following book deals with an application of TeX/LaTeX to 
% preparation of manuscripts of chemical fields:
%  (2)  Shinsaku Fujita, ``LaTeX for Chemists and Biochemists'' 
%    Tokyo Kagaku Dozin, Tokyo (1993) [in Japanese].  
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'. 
% The Current Maintainer of this work is Shinsaku Fujita.
%
% This work consists of the files sizeredc.dtx and sizeredc.ins
% and the derived file sizeredc.sty.
%
% Please report any bugs, comments, suggestions, etc. to:
%   Shinsaku Fujita, 
%   Shonan Institute of Chemoinformatics and Mathematical Chemistry
%   Kaneko 479-7 Ooimachi, Ashigara-Kami-Gun, Kanagawa 250-0019 Japan
%  (old address)
%   Ashigara Research Laboratories, Fuji Photo Film Co., Ltd., 
%   Minami-Ashigara, Kanagawa-ken, 250-01, Japan.
%  (old address)
%   Department of Chemistry and Materials Technology, 
%   Kyoto Institute of Technology, \\
%   Matsugasaki, Sakyoku, Kyoto, 606 Japan
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \def\j@urnalname{sizeredc}
% \def\versi@ndate{June 12, 2001}
% \def\versi@nno{ver1.00}
% \def\copyrighth@lder{SF} % Shinsaku Fujita
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \def\j@urnalname{sizeredc}
% \def\versi@ndate{April 30, 2002}
% \def\versi@nno{ver1.01}
% \def\copyrighth@lder{SF} % Shinsaku Fujita
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \def\j@urnalname{sizeredc}
% \def\versi@ndate{August 30, 2004}
% \def\versi@nno{ver4.01}
% \def\copyrighth@lder{SF} % Shinsaku Fujita
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% \fi
%
% \CheckSum{428}
%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
%
% \setcounter{StandardModuleDepth}{1}
%
% \StopEventually{}
% \MakeShortVerb{\|}
%
% \iffalse
% \changes{v1.00}{2001/06/12}{first edition for LaTeX2e}
% \changes{v1.01}{2002/04/30}{2nd edition for XyMTeX v3.00}
% \changes{v4.01}{2004/08/30}{Adjust XyMTeX v4.01}
% \changes{v5.00}{2010/10/01}{the LaTeX Project Public License}
% \fi
%
% \iffalse
%<*driver>
\NeedsTeXFormat{pLaTeX2e}
% \fi
\ProvidesFile{sizeredc.dtx}[2010/10/01 v5.00 XyMTeX{} package file]
% \iffalse
\documentclass{ltxdoc}
\GetFileInfo{sizeredc.dtx}
%
% %%XyMTeX Logo: Definition 2%%%
\def\UPSILON{\char'7}
\def\XyM{X\kern-.30em\smash{%
\raise.50ex\hbox{\UPSILON}}\kern-.30em{M}}
\def\XyMTeX{\XyM\kern-.1em\TeX}
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\title{Size Reduction of Structural Formulas 
by {\sffamily sizeredc.sty} (\fileversion) of \XyMTeX{}}
\author{Shinsaku Fujita \\ 
Shonan Institute of Chemoinformatics and Mathematical Chemistry, \\
Kaneko 479-7 Ooimachi, Ashigara-Kami-Gun, Kanagawa 250-0019 Japan
% % (old address)
% %Department of Chemistry and Materials Technology, \\
% %Kyoto Institute of Technology, \\
% %Matsugasaki, Sakyoku, Kyoto, 606-8585 Japan
% %% (old address)
% %% Ashigara Research Laboratories, 
% %% Fuji Photo Film Co., Ltd., \\ 
% %% Minami-Ashigara, Kanagawa, 250-01 Japan
}
\date{\filedate}
%
\begin{document}
   \maketitle
   \DocInput{sizeredc.dtx}
\end{document}
%</driver>
% \fi
%
% \section{Introduction}\label{sizeredc:intro}
%
% \subsection{Options for {\sffamily docstrip}}
%
% \DeleteShortVerb{\|}
% \begin{center}
% \begin{tabular}{|l|l|}
% \hline
% \emph{option} & \emph{function}\\ \hline
% sizeredc & sizeredc.sty \\
% driver & driver for this dtx file \\
% \hline
% \end{tabular}
% \end{center}
% \MakeShortVerb{\|}
%
% \subsection{Version Information}
%
%    \begin{macrocode}
%<*sizeredc>
\typeout{XyMTeX for Drawing Chemical Structural Formulas. Version 5.00}
\typeout{       -- Released October 01, 2010 by Shinsaku Fujita}
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\j@urnalname{sizeredc}
\def\versi@ndate{October 01, 2010}
\def\versi@nno{ver5.00}
\def\copyrighth@lder{SF} % Shinsaku Fujita
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\typeout{XyMTeX Macro File `\j@urnalname' (\versi@nno) <\versi@ndate>%
\space[\copyrighth@lder]}
%    \end{macrocode}
%
% \section{Macros for Size Reduction}
% \subsection{Division of Integers}
%
% \begin{macro}{\DIVIDE}
% The macro |\DIVIDE| is used to the devision of an integer 
% by a divisor.  The result (rounded to an integer) is stored 
% in a control sequence such as |\Quatient|. 
% \begin{verbatim}
%  \DIVDE{integer}{divisor}\Quatient
% \end{verbatim}
% 
%    \begin{macrocode}
\newcount\@tempcntx \newcount\@tempcnty \newcount\@tempcntz
\newif\ifseifuflag \seifuflagfalse 
\def\DIVIDE#1#2#3{%
\seifuflagfalse \@tempcntx=#1
\ifnum\@tempcntx<0 \@tempcntx=-\@tempcntx\seifuflagtrue\fi
\divide\@tempcntx by#2\relax
\ifnum\@tempcntx<0 \@tempcntx=-\@tempcntx
\ifseifuflag \seifuflagfalse \else \seifuflagtrue\fi\fi
\@tempcntz=\@tempcntx%%store
\@tempcnty=\@tempcntx \multiply\@tempcnty by#2%
\ifnum\@tempcnty<0 \@tempcnty=-\@tempcnty\fi
\@tempcntx=#1%
\ifnum\@tempcntx<0 \@tempcntx=-\@tempcntx\fi
\advance\@tempcntx by-\@tempcnty%
\multiply\@tempcntx by10 \edef\s{\the\@tempcntx}%
\divide\@tempcntx by#2 
\ifnum\@tempcntx<0 \@tempcntx=-\@tempcntx\fi
\ifnum\@tempcntx>4\relax \advance\@tempcntz by1\fi
\ifseifuflag \xdef#3{-\the\@tempcntz}%
\else\xdef#3{\the\@tempcntz}\fi}
%    \end{macrocode}
% \end{macro}
%
% \subsection{Size Reduction of Formulas}
%
% \begin{macro}{\LineTemp}
% The macro |\LineTemp| is used to redefine the |\line| commond of 
% the \LaTeXe{} picture environment. Thereby, the macro 
% |\LineTemp(a,b){c}| is transformed into the macro 
% |\drawline(0,0)(c, ca/b)| for epic.sty, where |ca/b| is 
% calculated by the macro |\DIVIDE| defined above. 
%
%    \begin{macrocode}
\newcount\@xArg \newcount\@yArg
\def\LineTemp(#1,#2)#3{\begingroup
\@xArg #1\relax \@yArg #2\relax
\ifnum\@xArg<0 \@tempcntx=-#3 \else
\ifnum\@xArg>0 \@tempcntx=#3 \else \@tempcntx=0 \fi\fi
\@tempcnty=#3
\multiply\@tempcnty by\@yArg\relax
\ifnum\@tempcnty<0 \@tempcnty=-\@tempcnty\fi
\ifnum\@xArg<0 \@xArg=-\@xArg\fi
\ifnum\@xArg=0 \edef\RR{#3}\else
{\DIVIDE{\@tempcnty}{\@xArg}\RR}\fi
\@tempcnty=\RR%
\ifnum\@yArg<0 \ifnum\@tempcnty>0 \@tempcnty=-\@tempcnty\fi\fi
\drawline(0,0)(\the\@tempcntx,\the\@tempcnty)%
\endgroup}
%    \end{macrocode}
% \end{macro}
% 
% The if-phrase |\ifsizereduction| is to determine whether 
% size-reduction is carried out or not. 
% Then, |\LineTemp| is substituted for the original |\line| 
% if |\sizereductiontrue| is declared and if |\unitlength| 
% is smaller than 0.1pt. 
%
% \begin{macro}{\line}
% \begin{macro}{\ifsizereduction}
%    \begin{macrocode}
\RequirePackage{epic}%
\newif\ifsizereduction \sizereductionfalse
%\let\@ldline=\line
\def\reduced@line(#1,#2)#3{\ifsizereduction
\ifdim\unitlength<0.1pt \LineTemp(#1,#2){#3}\else
\@ldline(#1,#2){#3}\fi
\else\@ldline(#1,#2){#3}\fi}
\let\line=\reduced@line
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% The command |\changeunitlength| is used to set |\unitlength| 
% and to declare |\sizereductiontrue| 
% if |\unitlength| is smaller than 0.1pt. 
% The font size of substituents is changed by |\substfontsize| 
% according to the size reduction. 
%
% \changes{v4.00}{2002/5/30}{Added: \cs{substfontsize}}
%
% \begin{macro}{\@changeunitlength}
%    \begin{macrocode}
\def\@changeunitlength#1{\unitlength=#1\relax
\ifdim\unitlength<0.1pt \sizereductiontrue
\ifdim\unitlength<0.062pt \let\substfontsize=\tiny \else
\ifdim\unitlength<0.072pt \let\substfontsize=\scriptsize \else 
\ifdim\unitlength<0.082pt \let\substfontsize=\footnotesize 
\fi\fi\fi
\else\let\substfontsize=\normalsize
\fi}
\let\changeunitlength=\@changeunitlength
%    \end{macrocode}
% \end{macro}
%
% The reduced setting is the original LaTeX picture environment but 
% include the size-reduction mechanism. 
% To switch the size-reduction meachism and the pstricks mechanism, 
% we can use a switching command such as |\originalpicture|. 
% \changes{v3.00}{2002/4/30}{New environment: sfpicture}
%
% \begin{macro}{\reducedsizepicture}
%    \begin{macrocode}
\def\reducedsizepicture{%
\@ifnextchar[{\reduced@picture}{\reduced@picture[0.1pt]}}
\def\reduced@picture[#1]{%
\sizereductiontrue
\let\sfpicture=\picture
\let\endsfpicture=\endpicture
\let\Put@Direct=\put
\let\Multiput@Direct=\multiput
\let\thicklines=\@ldthicklines
\let\thinlines=\@ldthinlines
\let\line=\reduced@line
\let\dotorline=\d@t@rline
\let\Put@Line=\Put@@Line
\let\Put@sCircle=\Put@@sCircle
\let\Put@oCircle=\Put@@oCircle
\xymtexpsswfalse
\let\changeunitlength=\@changeunitlength
\changeunitlength{#1}}
\reducedsizepicture%size-reduction setting
%    \end{macrocode}
% \end{macro}
%
%
% The command |\lineslope| of epic.sty has been redefined 
% to give a more precise result. 
%
% \begin{macro}{\lineslope}
%    \begin{macrocode}
\let\oldlineslope=\lineslope%used only in the manual 
\def\lineslope(#1,#2){%
\begingroup
\ifdim #1 <0pt \@xdim= -#1 \else\@xdim=#1\fi
\ifdim #2 <0pt \@ydim= -#2 \else\@ydim=#2\fi
%\typeout{LLL= \the#1, \the#2}
\multiply\@xdim by10\relax%by S. Fujita 2001/6/20
\multiply\@ydim by10\relax%by S. Fujita 2001/6/20
%\typeout{xdim,ydim= \the\@xdim, \the\@ydim}
\ifdim\@xdim >\@ydim \@tempdima=\@xdim \@xdim=\@ydim \@ydim=\@tempdima
\@flippedargstrue\else\@flippedargsfalse\fi% x < y
\ifdim\@ydim >1pt \@tempcntx=\@ydim
            \divide\@tempcntx by 65536% now \@tempcntx=integral part of #1.
            \divide\@xdim \@tempcntx\fi
%\typeout{xdim: \the\@xdim}%
\ifdim\@xdim <.083333pt \@xarg=1 \@yarg=0
 \else\ifdim\@xdim <.183333pt	\@xarg=6 \@yarg=1
 \else\ifdim\@xdim <.225pt 	\@xarg=5 \@yarg=1
 \else\ifdim\@xdim <.291666pt 	\@xarg=4 \@yarg=1
 \else\ifdim\@xdim <.366666pt 	\@xarg=3 \@yarg=1
 \else\ifdim\@xdim <.45pt 	\@xarg=5 \@yarg=2
 \else\ifdim\@xdim <.55pt 	\@xarg=2 \@yarg=1
 \else\ifdim\@xdim <.633333pt 	\@xarg=5 \@yarg=3
 \else\ifdim\@xdim <.708333pt 	\@xarg=3 \@yarg=2
 \else\ifdim\@xdim <.775pt 	\@xarg=4 \@yarg=3
 \else\ifdim\@xdim <.816666pt 	\@xarg=5 \@yarg=4
 \else\ifdim\@xdim <.916666pt 	\@xarg=6 \@yarg=5
       \else			\@xarg=1 \@yarg=1%
\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
\if@flippedargs\relax\else\@tempcntx=\@xarg \@xarg=\@yarg
			  \@yarg=\@tempcntx\fi
\ifdim #1 <0pt \global\@xarg= -\@xarg\else\global\@xarg= \@xarg\fi
\ifdim #2 <0pt \global\@yarg= -\@yarg\else\global\@yarg= \@yarg\fi
%%\typeout{closest slope integers = \the\@xarg, \the\@yarg}
\endgroup}
%</sizeredc>
%    \end{macrocode}
% \end{macro}
%
% \Finale
%
\endinput