Size Reduction of Structural Formulas by sizeredc.sty (v4.01) of XΥMTEX

Shinsaku Fujita Department of Chemistry and Materials Technology, Kyoto Institute of Technology, Matsugasaki, Sakyo-ku, 606-8585, Japan

2004/08/30

1 Introduction

1.1 Options for docstrip

option function
sizeredc sizeredc.sty
driver  driver for this dtx file

1.2 Version Information

1 ⟨∗sizeredc⟩

2 \typeout{XyMTeX for Drawing Chemical Structural Formulas. Version 4.01}
3 \typeout{       -- Released August 30, 2004 by Shinsaku Fujita}
4 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5 \def\j@urnalname{sizeredc}
6 \def\versi@ndate{August 30, 2004}
7 \def\versi@nno{ver4.01}
8 \def\copyrighth@lder{SF} % Shinsaku Fujita
9 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
10 \typeout{XyMTeX Macro File `\j@urnalname' (\versi@nno) <\versi@ndate>%
11 \space[\copyrighth@lder]}

2 Macros for Size Reduction

2.1 Division of Integers

\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.

 \DIVDE{integer}{divisor}\Quatient

12 \newcount\@tempcntx \newcount\@tempcnty \newcount\@tempcntz
13 \newif\ifseifuflag \seifuflagfalse
14 \def\DIVIDE#1#2#3{%
15 \seifuflagfalse \@tempcntx=#1

16 \ifnum\@tempcntx<0 \@tempcntx=-\@tempcntx\seifuflagtrue\fi
17 \divide\@tempcntx by#2\relax
18 \ifnum\@tempcntx<0 \@tempcntx=-\@tempcntx
19 \ifseifuflag \seifuflagfalse \else \seifuflagtrue\fi\fi
20 \@tempcntz=\@tempcntx%%store
21 \@tempcnty=\@tempcntx \multiply\@tempcnty by#2%
22 \ifnum\@tempcnty<0 \@tempcnty=-\@tempcnty\fi
23 \@tempcntx=#1%
24 \ifnum\@tempcntx<0 \@tempcntx=-\@tempcntx\fi
25 \advance\@tempcntx by-\@tempcnty%
26 \multiply\@tempcntx by10 \edef\s{\the\@tempcntx}%
27 \divide\@tempcntx by#2
28 \ifnum\@tempcntx<0 \@tempcntx=-\@tempcntx\fi
29 \ifnum\@tempcntx>4\relax \advance\@tempcntz by1\fi
30 \ifseifuflag \xdef#3{-\the\@tempcntz}%
31 \else\xdef#3{\the\@tempcntz}\fi}

2.2 Size Reduction of Formulas

\LineTemp The macro \LineTemp is used to redefine the \line commond of the L^{A}TEX 2ε 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.

32 \newcount\@xArg \newcount\@yArg
33 \def\LineTemp(#1,#2)#3{\begingroup
34 \@xArg #1\relax \@yArg #2\relax
35 \ifnum\@xArg<0 \@tempcntx=-#3 \else
36 \ifnum\@xArg>0 \@tempcntx=#3 \else \@tempcntx=0 \fi\fi
37 \@tempcnty=#3
38 \multiply\@tempcnty by\@yArg\relax
39 \ifnum\@tempcnty<0 \@tempcnty=-\@tempcnty\fi
40 \ifnum\@xArg<0 \@xArg=-\@xArg\fi
41 \ifnum\@xArg=0 \edef\RR{#3}\else
42 {\DIVIDE{\@tempcnty}{\@xArg}\RR}\fi
43 \@tempcnty=\RR%
44 \ifnum\@yArg<0 \ifnum\@tempcnty>0 \@tempcnty=-\@tempcnty\fi\fi
45 \drawline(0,0)(\the\@tempcntx,\the\@tempcnty)%
46 \endgroup}

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.

\line
\ifsizereduction
47 \RequirePackage{epic}%
48 \newif\ifsizereduction \sizereductionfalse
49 %\let\@ldline=\line
50 \def\reduced@line(#1,#2)#3{\ifsizereduction
51 \ifdim\unitlength<0.1pt \LineTemp(#1,#2){#3}\else
52 \@ldline(#1,#2){#3}\fi
53 \else\@ldline(#1,#2){#3}\fi}
54 \let\line=\reduced@line

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.

\@changeunitlength
55 \def\@changeunitlength#1{\unitlength=#1\relax
56 \ifdim\unitlength<0.1pt \sizereductiontrue
57 \ifdim\unitlength<0.062pt \let\substfontsize=\tiny \else
58 \ifdim\unitlength<0.072pt \let\substfontsize=\scriptsize \else
59 \ifdim\unitlength<0.082pt \let\substfontsize=\footnotesize
60 \fi\fi\fi
61 \else\let\substfontsize=\normalsize
62 \fi}
63 \let\changeunitlength=\@changeunitlength

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.

\reducedsizepicture
64 \def\reducedsizepicture{%
65 \@ifnextchar[{\reduced@picture}{\reduced@picture[0.1pt]}}
66 \def\reduced@picture[#1]{%
67 \sizereductiontrue
68 \let\sfpicture=\picture
69 \let\endsfpicture=\endpicture
70 \let\Put@Direct=\put
71 \let\Multiput@Direct=\multiput
72 \let\thicklines=\@ldthicklines
73 \let\thinlines=\@ldthinlines
74 \let\line=\reduced@line
75 \let\dotorline=\d@t@rline
76 \let\Put@Line=\Put@@Line
77 \let\Put@sCircle=\Put@@sCircle
78 \let\Put@oCircle=\Put@@oCircle
79 \xymtexpsswfalse
80 \let\changeunitlength=\@changeunitlength
81 \changeunitlength{#1}}
82 \reducedsizepicture%size-reduction setting

The command \lineslope of epic.sty has been redefined to give a more precise result.

\lineslope
83 \let\oldlineslope=\lineslope%used only in the manual
84 \def\lineslope(#1,#2){%
85 \begingroup
86 \ifdim #1 <0pt \@xdim= -#1 \else\@xdim=#1\fi
87 \ifdim #2 <0pt \@ydim= -#2 \else\@ydim=#2\fi
88 %\typeout{LLL= \the#1, \the#2}
89 \multiply\@xdim by10\relax%by S. Fujita 2001/6/20
90 \multiply\@ydim by10\relax%by S. Fujita 2001/6/20
91 %\typeout{xdim,ydim= \the\@xdim, \the\@ydim}
92 \ifdim\@xdim >\@ydim \@tempdima=\@xdim \@xdim=\@ydim \@ydim=\@tempdima

 93 \@flippedargstrue\else\@flippedargsfalse\fi% x < y
 94 \ifdim\@ydim >1pt \@tempcntx=\@ydim
 95  \divide\@tempcntx by 65536% now \@tempcntx=integral part of #1.
 96  \divide\@xdim \@tempcntx\fi
 97 %\typeout{xdim: \the\@xdim}%
 98 \ifdim\@xdim <.083333pt \@xarg=1 \@yarg=0
 99 \else\ifdim\@xdim <.183333pt \@xarg=6 \@yarg=1
100 \else\ifdim\@xdim <.225pt  \@xarg=5 \@yarg=1
101 \else\ifdim\@xdim <.291666pt  \@xarg=4 \@yarg=1
102 \else\ifdim\@xdim <.366666pt  \@xarg=3 \@yarg=1
103 \else\ifdim\@xdim <.45pt  \@xarg=5 \@yarg=2
104 \else\ifdim\@xdim <.55pt  \@xarg=2 \@yarg=1
105 \else\ifdim\@xdim <.633333pt  \@xarg=5 \@yarg=3
106 \else\ifdim\@xdim <.708333pt  \@xarg=3 \@yarg=2
107 \else\ifdim\@xdim <.775pt  \@xarg=4 \@yarg=3
108 \else\ifdim\@xdim <.816666pt  \@xarg=5 \@yarg=4
109 \else\ifdim\@xdim <.916666pt  \@xarg=6 \@yarg=5
110  \else \@xarg=1 \@yarg=1%
111 \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
112 \if@flippedargs\relax\else\@tempcntx=\@xarg \@xarg=\@yarg
113 \@yarg=\@tempcntx\fi
114 \ifdim #1 <0pt \global\@xarg= -\@xarg\else\global\@xarg= \@xarg\fi
115 \ifdim #2 <0pt \global\@yarg= -\@yarg\else\global\@yarg= \@yarg\fi
116 %%\typeout{closest slope integers = \the\@xarg, \the\@yarg}
117 \endgroup}

118 ⟨/sizeredc⟩