summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/fgruler/fgruler.sty
blob: c76775e9dd54231bbcbbcf9566475d2fbf808188 (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
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
%%
%% This is file `fgruler.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% ./fgruler.dtx  (with options: `package')
%% This is a generated file.
%% 
%% Copyright 2017- by Tibor Tomacs
%% 
%% 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 Tibor Tomacs.
%% 
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{fgruler}[2017/01/16 v1.0 Package for drawing rulers on the foreground or in the text]
%%
\@ifpackageloaded{kvoptions}{}{\RequirePackage{kvoptions}}
\@ifpackageloaded{etoolbox}{}{\RequirePackage{etoolbox}}

\SetupKeyvalOptions{family=fgruler,prefix=fgruler@}
\DeclareStringOption[.4pt]{markthick}
\DeclareStringOption[\scriptsize\sffamily]{numfont}
\DeclareStringOption[black]{color}
\DeclareStringOption[2mm]{marklength}
\DeclareStringOption[3pt]{numsep}
\DeclareStringOption[0pt]{hshift}
\DeclareStringOption[0pt]{vshift}
\DeclareStringOption[upperleft]{type}
\DeclareStringOption[cm]{unit}
\DeclareBoolOption{nonefgrulers}
\DeclareBoolOption{showframe}
\ProcessKeyvalOptions{fgruler}

\newlength{\fgruler@marklth}
\newlength{\fgruler@sep}
\newlength{\fgruler@width}
\newlength{\fgruler@fg@width}
\newlength{\fgruler@fg@height}

\def\fgruler@set#1#2#3#4#5{%
\def\fgruler@markthickness{\linethickness{#1}}%
\def\fgruler@font{#2}%
\def\fgruler@rulercolor{\color{#3}}%
\setlength{\fgruler@marklth}{#4}%
\setlength{\fgruler@sep}{#5}%
\def\fgruler@font@{\normalfont\normalsize\fgruler@font}%
\addtolength{\fgruler@sep}{\fgruler@marklth}%
\ifx\thefgrulernum\@empty\setlength{\fgruler@width}{\fgruler@marklth}\else%
\settoheight{\fgruler@width}{\fgruler@font@\thefgrulernum}%
\addtolength{\fgruler@width}{\fgruler@sep}\fi}

\def\rulerparams#1#2#3#4#5{%
\ifx#1\@empty\else\def\fgruler@markthick@{#1}\fi%
\ifx#2\@empty\else\def\fgruler@numfont@{#2}\fi%
\ifx#3\@empty\else\def\fgruler@color@{#3}\fi%
\ifx#4\@empty\else\def\fgruler@marklength@{#4}\fi%
\ifx#5\@empty\else\def\fgruler@numsep@{#5}\fi%
\ignorespaces}

\rulerparams{.4pt}{\scriptsize\sffamily}{black}{2mm}{3pt}

\def\fgruler@fgsetting{%
\fgruler@set{\fgruler@markthick}{\fgruler@numfont}{\fgruler@color}{\fgruler@marklength}{\fgruler@numsep}%
\rulernorotatenum}

\def\fgruler@intextsetting{%
\fgruler@set{\fgruler@markthick@}{\fgruler@numfont@}{\fgruler@color@}{\fgruler@marklength@}{\fgruler@numsep@}}

\def\fgruler@activate@type{%
\def\fgruler@check{cm}\ifx\fgruler@unit\fgruler@check\else%
\def\fgruler@check{in}\ifx\fgruler@unit\fgruler@check\else%
\@latexerr{Undefined unit: \fgruler@unit\space(Defined units: cm, in)}{}\fi\fi%
\def\fgruler@check{upperleft}\ifx\fgruler@type\fgruler@check\else%
\def\fgruler@check{upperright}\ifx\fgruler@type\fgruler@check\else%
\def\fgruler@check{lowerleft}\ifx\fgruler@type\fgruler@check\else%
\def\fgruler@check{lowerright}\ifx\fgruler@type\fgruler@check\else%
\def\fgruler@check{none}\ifx\fgruler@type\fgruler@check\else%
\@latexerr{Undefined type: \fgruler@type\space(Defined types: upperleft, upperright, lowerleft, lowerright, none)}{}\fi\fi\fi\fi\fi%
\def\fgruler@output{\csname fgruler@\fgruler@unit @\fgruler@type @fg\endcsname}}

\def\fgrulerratiocm#1#2{%
\ifx#1\@empty\else\def\fgruler@cm@ratio@i{#1}\fi%
\ifx#2\@empty\else\def\fgruler@cm@ratio@ii{#2}\fi%
\ignorespaces}

\fgrulerratiocm{.5}{.75}

\def\fgrulerratioin#1#2#3#4{%
\ifx#1\@empty\else\def\fgruler@in@ratio@i{#1}\fi%
\ifx#2\@empty\else\def\fgruler@in@ratio@ii{#2}\fi%
\ifx#3\@empty\else\def\fgruler@in@ratio@iii{#3}\fi%
\ifx#4\@empty\else\def\fgruler@in@ratio@iv{#4}\fi%
\ignorespaces}

\fgrulerratioin{.25}{.375}{.625}{.75}

\def\fgrulerthickcm#1#2#3{%
\ifx#1\@empty\else\def\fgruler@cm@thick@i{\linethickness{#1}}\fi%
\ifx#2\@empty\else\def\fgruler@cm@thick@ii{\linethickness{#2}}\fi%
\ifx#3\@empty\else\def\fgruler@cm@thick@iii{\linethickness{#3}}\fi%
\ignorespaces}

\def\fgruler@cm@thick@i{}
\def\fgruler@cm@thick@ii{}
\def\fgruler@cm@thick@iii{}

\def\fgrulerthickin#1#2#3#4#5{%
\ifx#1\@empty\else\def\fgruler@in@thick@i{\linethickness{#1}}\fi%
\ifx#2\@empty\else\def\fgruler@in@thick@ii{\linethickness{#2}}\fi%
\ifx#3\@empty\else\def\fgruler@in@thick@iii{\linethickness{#3}}\fi%
\ifx#4\@empty\else\def\fgruler@in@thick@iv{\linethickness{#4}}\fi%
\ifx#5\@empty\else\def\fgruler@in@thick@v{\linethickness{#5}}\fi%
\ignorespaces}

\def\fgruler@in@thick@i{}
\def\fgruler@in@thick@ii{}
\def\fgruler@in@thick@iii{}
\def\fgruler@in@thick@iv{}
\def\fgruler@in@thick@v{}

\def\fgrulercolorcm#1#2#3{%
\ifx#1\@empty\else\def\fgruler@cm@color@i{\color{#1}}\fi%
\ifx#2\@empty\else\def\fgruler@cm@color@ii{\color{#2}}\fi%
\ifx#3\@empty\else\def\fgruler@cm@color@iii{\color{#3}}\fi%
\ignorespaces}

\def\fgruler@cm@color@i{}
\def\fgruler@cm@color@ii{}
\def\fgruler@cm@color@iii{}

\def\fgrulercolorin#1#2#3#4#5{%
\ifx#1\@empty\else\def\fgruler@in@color@i{\color{#1}}\fi%
\ifx#2\@empty\else\def\fgruler@in@color@ii{\color{#2}}\fi%
\ifx#3\@empty\else\def\fgruler@in@color@iii{\color{#3}}\fi%
\ifx#4\@empty\else\def\fgruler@in@color@iv{\color{#4}}\fi%
\ifx#5\@empty\else\def\fgruler@in@color@v{\color{#5}}\fi%
\ignorespaces}

\def\fgruler@in@color@i{}
\def\fgruler@in@color@ii{}
\def\fgruler@in@color@iii{}
\def\fgruler@in@color@iv{}
\def\fgruler@in@color@v{}

\def\setfgruler#1{\setkeys{fgruler}{#1}\fgruler@activate@type\ignorespaces}

\newcommand\fgruler@div[2]{%
\@tempdima=#1\relax\@tempdimb=\unitlength\relax
\@tempdimb=#2\@tempdimb\divide\@tempdima by \@tempdimb
\@tempcnta\@tempdima\advance\@tempcnta\@ne}

\def\fgruler@check@param#1#2{%
\def\fgruler@param{#1}%
\def\fgruler@check{cm}\ifx\fgruler@param\fgruler@check\else%
\def\fgruler@check{in}\ifx\fgruler@param\fgruler@check\else%
\@latexerr{Invalid parameter: \fgruler@param\space(Defined parameters: cm, in)}{}%
\fi\fi%
\def\fgruler@param{#2}%
\def\fgruler@check{rightdown}\ifx\fgruler@param\fgruler@check\else%
\def\fgruler@check{rightup}\ifx\fgruler@param\fgruler@check\else%
\def\fgruler@check{leftdown}\ifx\fgruler@param\fgruler@check\else%
\def\fgruler@check{leftup}\ifx\fgruler@param\fgruler@check\else%
\def\fgruler@check{downright}\ifx\fgruler@param\fgruler@check\else%
\def\fgruler@check{downleft}\ifx\fgruler@param\fgruler@check\else%
\def\fgruler@check{upright}\ifx\fgruler@param\fgruler@check\else%
\def\fgruler@check{upleft}\ifx\fgruler@param\fgruler@check\else%
\@latexerr{Invalid parameter: \fgruler@param\space(Defined parameters: rightdown, rightup, leftdown, leftup, downright, downleft, upright, upleft)}{}%
\fi\fi\fi\fi\fi\fi\fi\fi}

\def\fgruler@check@param@#1#2{%
\def\fgruler@param{#1}%
\def\fgruler@check{cm}\ifx\fgruler@param\fgruler@check\else%
\def\fgruler@check{in}\ifx\fgruler@param\fgruler@check\else%
\@latexerr{Invalid parameter: \fgruler@param\space(Defined parameters: cm, in)}{}%
\fi\fi%
\def\fgruler@param{#2}%
\def\fgruler@check{upperleft}\ifx\fgruler@param\fgruler@check\else%
\def\fgruler@check{upperright}\ifx\fgruler@param\fgruler@check\else%
\def\fgruler@check{lowerleft}\ifx\fgruler@param\fgruler@check\else%
\def\fgruler@check{lowerright}\ifx\fgruler@param\fgruler@check\else%
\@latexerr{Invalid parameter: \fgruler@param\space(Defined parameters: upperleft, upperright, lowerleft, lowerright)}{}%
\fi\fi\fi\fi}

\newcommand{\fgruler@ruler}[3][cm]{\fgruler@check@param{#1}{#2}\fgruler@intextsetting\csname fgruler@#1@#2@\endcsname{#3}}
\newcommand{\fgruler@ruler@}[3][cm]{\fgruler@check@param{#1}{#2}\fgruler@intextsetting\csname fgruler@#1@#2@@\endcsname{#3}}
\def\ruler{\@ifstar{\fgruler@ruler@}{\fgruler@ruler}}

\newcommand{\fgruler@squareruler}[4][cm]{\fgruler@check@param@{#1}{#2}\fgruler@intextsetting\csname fgruler@#1@#2@\endcsname{#3}{#4}}
\newcommand{\fgruler@squareruler@}[4][cm]{\fgruler@check@param@{#1}{#2}\fgruler@intextsetting\csname fgruler@#1@#2@@\endcsname{#3}{#4}}
\def\squareruler{\@ifstar{\fgruler@squareruler@}{\fgruler@squareruler}}

\newcommand{\fgruler}[4][cm]{\fgruler@check@param@{#1}{#2}\g@addto@macro\fgruler@output@{\csname fgruler@#1@#2@fg@\endcsname{#3}{#4}}}

\def\fgrulercaptioncm#1{\def\fgruler@caption@cm{#1}\ignorespaces}
\def\fgruler@caption@cm{cm}
\def\fgrulercaptionin#1{\def\fgruler@caption@in{#1}\ignorespaces}
\def\fgruler@caption@in{inch}

\newif\iffgruler@borderline
\def\fgrulernoborderline{\fgruler@borderlinefalse\ignorespaces}
\def\fgrulerborderline{\fgruler@borderlinetrue\ignorespaces}
\fgruler@borderlinetrue

\newcounter{fgrulernum}
\newcounter{fgruler@check}

\def\fgruler@ifnot@divisible@five#1{%
\setcounter{fgruler@check}{\value{fgrulernum}}%
\divide\value{fgruler@check}by5\relax%
\multiply\value{fgruler@check}by5\relax%
\ifnum\value{fgruler@check}=\value{fgrulernum}\else#1\fi\stepcounter{fgrulernum}}

\def\fgruler@ifodd#1{\ifodd\value{fgrulernum}#1\fi\stepcounter{fgrulernum}}

\def\fgruler@lentounit#1{\strip@pt\dimexpr#1*\p@/\unitlength}

\def\fgrulerstartnum#1{\def\fgruler@startnum{#1}\ignorespaces}
\def\fgruler@startnum{0}

\def\fgrulerdefnum#1{\def\thefgrulernum{#1}\ignorespaces}

\def\fgruler@rotatebox#1#2{#2}%

\def\rulernorotatenum{%
\ifx\@onlypreamble\@notprerr%
\def\fgruler@rotatebox##1##2{##2}%
\else\@latexerr{Don't use \protect\rulernorotatenum\space in preamble!}{}\fi%
\ignorespaces}

\def\rulerrotatenum{%
\ifx\@onlypreamble\@notprerr%
\def\fgruler@rotatebox##1##2{\rotatebox{##1}{##2}}%
\else\@latexerr{Don't use \protect\rulerrotatenum\space in preamble!}{}\fi%
\ignorespaces}

\def\fgrulerreset{%
\ifx\@onlypreamble\@notprerr%
\def\fgruler@cm@ratio@i{.5}%
\def\fgruler@cm@ratio@ii{.75}%
\def\fgruler@in@ratio@i{.25}%
\def\fgruler@in@ratio@ii{.375}%
\def\fgruler@in@ratio@iii{.625}%
\def\fgruler@in@ratio@iv{.75}%
\def\fgruler@cm@thick@i{}%
\def\fgruler@cm@thick@ii{}%
\def\fgruler@cm@thick@iii{}%
\def\fgruler@in@thick@i{}%
\def\fgruler@in@thick@ii{}%
\def\fgruler@in@thick@iii{}%
\def\fgruler@in@thick@iv{}%
\def\fgruler@in@thick@v{}%
\def\fgruler@cm@color@i{}%
\def\fgruler@cm@color@ii{}%
\def\fgruler@cm@color@iii{}%
\def\fgruler@in@color@i{}%
\def\fgruler@in@color@ii{}%
\def\fgruler@in@color@iii{}%
\def\fgruler@in@color@iv{}%
\def\fgruler@in@color@v{}%
\def\fgruler@rotatebox##1##2{\rotatebox{##1}{##2}}%
\def\fgruler@markthick@{.4pt}%
\def\fgruler@numfont@{\scriptsize\sffamily}%
\def\fgruler@color@{black}%
\def\fgruler@marklength@{2mm}%
\def\fgruler@numsep@{3pt}%
\def\fgruler@type{upperleft}%
\def\fgruler@unit{cm}%
\def\fgruler@markthick{.4pt}%
\def\fgruler@numfont{\scriptsize\sffamily}%
\def\fgruler@color{black}%
\def\fgruler@marklength{2mm}%
\def\fgruler@hshift{0pt}%
\def\fgruler@vshift{0pt}%
\def\fgruler@numsep{3pt}%
\def\thefgrulernum{\arabic{fgrulernum}}%
\def\fgruler@caption@cm{cm}%
\def\fgruler@caption@in{inch}%
\def\fgruler@startnum{0}%
\fgruler@borderlinetrue%
\fgruler@showframefalse%
\else\@latexerr{Don't use \protect\fgrulerreset\space in preamble!}{}\fi%
\ignorespaces}

\AtEndPreamble{

\@ifpackageloaded{xcolor}{}{\RequirePackage{xcolor}}
\@ifpackageloaded{graphicx}{}{\RequirePackage{graphicx}}

\def\fgruler@rotatebox#1#2{\rotatebox{#1}{#2}}

\iffgruler@nonefgrulers

\renewcommand{\fgruler}[4][cm]{}
\providecommand{\AtPageLowerLeft}[1]{#1}

\else

\@ifpackageloaded{eso-pic}{}{\RequirePackage{eso-pic}}

\def\fgruler@frame{%
  \begingroup
    \fgruler@fgsetting
    \fgruler@rulercolor%
    \fgruler@markthickness%
    \AtPageLowerLeft{%
      \framebox(\fgruler@lentounit{\paperwidth},\fgruler@lentounit{\paperheight}){}}%
    \AtTextLowerLeft{%
      \framebox(\fgruler@lentounit{\textwidth},\fgruler@lentounit{\textheight}){}}%
    \AtTextUpperLeft{%
      \put(0,\fgruler@lentounit{\headsep}){%
        \framebox(\fgruler@lentounit{\textwidth},\fgruler@lentounit{\headheight}){}}}%
    \AtTextLowerLeft{%
      \put(0,\fgruler@lentounit{-\footskip}){%
        \line(1,0){\fgruler@lentounit{\textwidth}}}}%
    \AtTextLowerLeft{%
      \@tempdima=\textwidth\advance\@tempdima\marginparsep%
      \if@twoside
        \ifodd\c@page\else
          \if@mparswitch
            \@tempdima=-\marginparsep\advance\@tempdima-\marginparwidth
          \fi
        \fi
      \fi
      \put(\fgruler@lentounit{\@tempdima},0)%
        {\framebox(\fgruler@lentounit{\marginparwidth},\fgruler@lentounit{\textheight}){}}%
    }%
  \endgroup
}

\let\fgruler@shipout\AtBeginShipoutUpperLeftForeground
\def\fgruler@output@{}
\ESO@isMEMOIR{%
\def\AtBeginShipoutUpperLeftForeground#1{%
    \fgruler@shipout{#1%
        \put(\fgruler@lentounit{\@tempdima},\fgruler@lentounit{\@tempdimb}){%
            \iffgruler@showframe\fgruler@frame\fi%
            \fgruler@output%
            \fgruler@output@%
            \global\let\fgruler@output@\@empty%
            }%
        }%
    }%
}{%
\def\AtBeginShipoutUpperLeftForeground#1{%
    \fgruler@shipout{#1%
        \put(0,\fgruler@lentounit{\ESO@yoffsetI}){%
            \iffgruler@showframe\fgruler@frame\fi%
            \fgruler@output%
            \fgruler@output@%
            \global\let\fgruler@output@\@empty%
            }%
        }%
    }%
}

\fgruler@activate@type

\fi
}

%% RIGHTDOWN CM
\def\fgruler@cm@rightdown#1{%
\fgruler@rulercolor%
\fgruler@markthickness%
\fgruler@div{#1}{1}%
\setcounter{fgrulernum}{0}%
\multiput(0,0)(1,0){\@tempcnta}{\fgruler@ifnot@divisible@five{\fgruler@cm@thick@i\fgruler@cm@color@i\line(0,-1){\fgruler@lentounit{\fgruler@cm@ratio@i\fgruler@marklth}}}}%
\fgruler@div{#1}{5}%
\setcounter{fgrulernum}{0}%
\multiput(0,0)(5,0){\@tempcnta}{\fgruler@ifodd{\fgruler@cm@thick@ii\fgruler@cm@color@ii\line(0,-1){\fgruler@lentounit{\fgruler@cm@ratio@ii\fgruler@marklth}}}}%
\fgruler@div{#1}{10}%
\multiput(0,0)(10,0){\@tempcnta}{\fgruler@cm@thick@iii\fgruler@cm@color@iii\line(0,-1){\fgruler@lentounit{\fgruler@marklth}}}%
\iffgruler@borderline\put(0,0){\line(1,0){\fgruler@lentounit{#1}}}\fi%
\setcounter{fgrulernum}{\fgruler@startnum}\stepcounter{fgrulernum}%
\multiput(10,-\fgruler@lentounit{\fgruler@sep})(10,0){\@tempdima}{\makebox(0,0)[t]{\fgruler@font@\thefgrulernum\stepcounter{fgrulernum}}}}

\def\fgruler@cm@rightdown@#1{%
\setlength{\unitlength}{1mm}%
\begin{picture}(\fgruler@lentounit{#1},\fgruler@lentounit{\fgruler@width})(0,-\fgruler@lentounit{\fgruler@width})%
\fgruler@cm@rightdown{#1}%
\setcounter{fgrulernum}{\fgruler@startnum}%
\put(0,-\fgruler@lentounit{\fgruler@sep}){\makebox(0,0)[t]{\fgruler@font@\thefgrulernum}}%
\ifdim#1>.5cm\put(5,-\fgruler@lentounit{\fgruler@sep}){\makebox(0,0)[t]{\fgruler@font@\fgruler@caption@cm}}\fi%
\end{picture}}

\def\fgruler@cm@rightdown@@#1{\leavevmode\hbox{}\lower\fgruler@width\hbox{\fgruler@cm@rightdown@{#1}}}

%% RIGHTDOWN IN
\def\fgruler@in@rightdown#1{%
\fgruler@rulercolor%
\fgruler@markthickness%
\fgruler@div{#1}{1}%
\setcounter{fgrulernum}{0}%
\multiput(0,0)(1,0){\@tempcnta}{\fgruler@ifodd{\fgruler@in@thick@i\fgruler@in@color@i\line(0,-1){\fgruler@lentounit{\fgruler@in@ratio@i\fgruler@marklth}}}}%
\fgruler@div{#1}{2}%
\setcounter{fgrulernum}{0}%
\multiput(0,0)(2,0){\@tempcnta}{\fgruler@ifodd{\fgruler@in@thick@ii\fgruler@in@color@ii\line(0,-1){\fgruler@lentounit{\fgruler@in@ratio@ii\fgruler@marklth}}}}%
\fgruler@div{#1}{4}%
\setcounter{fgrulernum}{0}%
\multiput(0,0)(4,0){\@tempcnta}{\fgruler@ifodd{\fgruler@in@thick@iii\fgruler@in@color@iii\line(0,-1){\fgruler@lentounit{\fgruler@in@ratio@iii\fgruler@marklth}}}}%
\fgruler@div{#1}{8}%
\setcounter{fgrulernum}{0}%
\multiput(0,0)(8,0){\@tempcnta}{\fgruler@ifodd{\fgruler@in@thick@iv\fgruler@in@color@iv\line(0,-1){\fgruler@lentounit{\fgruler@in@ratio@iv\fgruler@marklth}}}}%
\fgruler@div{#1}{16}%
\multiput(0,0)(16,0){\@tempcnta}{\fgruler@in@thick@v\fgruler@in@color@v\line(0,-1){\fgruler@lentounit{\fgruler@marklth}}}%
\iffgruler@borderline\put(0,0){\line(1,0){\fgruler@lentounit{#1}}}\fi%
\setcounter{fgrulernum}{\fgruler@startnum}\stepcounter{fgrulernum}%
\multiput(16,-\fgruler@lentounit{\fgruler@sep})(16,0){\@tempdima}{\makebox(0,0)[t]{\fgruler@font@\thefgrulernum\stepcounter{fgrulernum}}}}

\def\fgruler@in@rightdown@#1{%
\setlength{\unitlength}{.0625in}%
\begin{picture}(\fgruler@lentounit{#1},\fgruler@lentounit{\fgruler@width})(0,-\fgruler@lentounit{\fgruler@width})%
\fgruler@in@rightdown{#1}%
\setcounter{fgrulernum}{\fgruler@startnum}%
\put(0,-\fgruler@lentounit{\fgruler@sep}){\makebox(0,0)[t]{\fgruler@font@\thefgrulernum}}%
\ifdim#1>.5in\put(8,-\fgruler@lentounit{\fgruler@sep}){\makebox(0,0)[t]{\fgruler@font@\fgruler@caption@in}}\fi%
\end{picture}}

\def\fgruler@in@rightdown@@#1{\leavevmode\hbox{}\lower\fgruler@width\hbox{\fgruler@in@rightdown@{#1}}}

%% RIGHTUP CM
\def\fgruler@cm@rightup#1{%
\fgruler@rulercolor%
\fgruler@markthickness%
\fgruler@div{#1}{1}%
\setcounter{fgrulernum}{0}%
\multiput(0,0)(1,0){\@tempcnta}{\fgruler@ifnot@divisible@five{\fgruler@cm@thick@i\fgruler@cm@color@i\line(0,1){\fgruler@lentounit{\fgruler@cm@ratio@i\fgruler@marklth}}}}%
\fgruler@div{#1}{5}%
\setcounter{fgrulernum}{0}%
\multiput(0,0)(5,0){\@tempcnta}{\fgruler@ifodd{\fgruler@cm@thick@ii\fgruler@cm@color@ii\line(0,1){\fgruler@lentounit{\fgruler@cm@ratio@ii\fgruler@marklth}}}}%
\fgruler@div{#1}{10}%
\multiput(0,0)(10,0){\@tempcnta}{\fgruler@cm@thick@iii\fgruler@cm@color@iii\line(0,1){\fgruler@lentounit{\fgruler@marklth}}}%
\iffgruler@borderline\put(0,0){\line(1,0){\fgruler@lentounit{#1}}}\fi%
\setcounter{fgrulernum}{\fgruler@startnum}\stepcounter{fgrulernum}%
\multiput(10,\fgruler@lentounit{\fgruler@sep})(10,0){\@tempdima}{\makebox(0,0)[b]{\fgruler@font@\thefgrulernum\stepcounter{fgrulernum}}}}

\def\fgruler@cm@rightup@#1{%
\setlength{\unitlength}{1mm}%
\begin{picture}(\fgruler@lentounit{#1},\fgruler@lentounit{\fgruler@width})%
\fgruler@cm@rightup{#1}%
\setcounter{fgrulernum}{\fgruler@startnum}%
\put(0,\fgruler@lentounit{\fgruler@sep}){\makebox(0,0)[b]{\fgruler@font@\thefgrulernum}}%
\ifdim#1>.5cm\put(5,\fgruler@lentounit{\fgruler@sep}){\makebox(0,0)[b]{\fgruler@font@\fgruler@caption@cm}}\fi%
\end{picture}}

\def\fgruler@cm@rightup@@#1{\leavevmode\hbox{}\lower\fgruler@width\hbox{\fgruler@cm@rightup@{#1}}}

%% RIGHTUP IN
\def\fgruler@in@rightup#1{%
\fgruler@rulercolor%
\fgruler@markthickness%
\fgruler@div{#1}{1}%
\setcounter{fgrulernum}{0}%
\multiput(0,0)(1,0){\@tempcnta}{\fgruler@ifodd{\fgruler@in@thick@i\fgruler@in@color@i\line(0,1){\fgruler@lentounit{\fgruler@in@ratio@i\fgruler@marklth}}}}%
\fgruler@div{#1}{2}%
\setcounter{fgrulernum}{0}%
\multiput(0,0)(2,0){\@tempcnta}{\fgruler@ifodd{\fgruler@in@thick@ii\fgruler@in@color@ii\line(0,1){\fgruler@lentounit{\fgruler@in@ratio@ii\fgruler@marklth}}}}%
\fgruler@div{#1}{4}%
\setcounter{fgrulernum}{0}%
\multiput(0,0)(4,0){\@tempcnta}{\fgruler@ifodd{\fgruler@in@thick@iii\fgruler@in@color@iii\line(0,1){\fgruler@lentounit{\fgruler@in@ratio@iii\fgruler@marklth}}}}%
\fgruler@div{#1}{8}%
\setcounter{fgrulernum}{0}%
\multiput(0,0)(8,0){\@tempcnta}{\fgruler@ifodd{\fgruler@in@thick@iv\fgruler@in@color@iv\line(0,1){\fgruler@lentounit{\fgruler@in@ratio@iv\fgruler@marklth}}}}%
\fgruler@div{#1}{16}%
\multiput(0,0)(16,0){\@tempcnta}{\fgruler@in@thick@v\fgruler@in@color@v\line(0,1){\fgruler@lentounit{\fgruler@marklth}}}%
\iffgruler@borderline\put(0,0){\line(1,0){\fgruler@lentounit{#1}}}\fi%
\setcounter{fgrulernum}{\fgruler@startnum}\stepcounter{fgrulernum}%
\multiput(16,\fgruler@lentounit{\fgruler@sep})(16,0){\@tempdima}{\makebox(0,0)[b]{\fgruler@font@\thefgrulernum\stepcounter{fgrulernum}}}}

\def\fgruler@in@rightup@#1{%
\setlength{\unitlength}{.0625in}%
\begin{picture}(\fgruler@lentounit{#1},\fgruler@lentounit{\fgruler@width})%
\fgruler@in@rightup{#1}%
\setcounter{fgrulernum}{\fgruler@startnum}%
\put(0,\fgruler@lentounit{\fgruler@sep}){\makebox(0,0)[b]{\fgruler@font@\thefgrulernum}}%
\ifdim#1>.5in\put(8,\fgruler@lentounit{\fgruler@sep}){\makebox(0,0)[b]{\fgruler@font@\fgruler@caption@in}}\fi%
\end{picture}}

\def\fgruler@in@rightup@@#1{\leavevmode\hbox{}\lower\fgruler@width\hbox{\fgruler@in@rightup@{#1}}}

%% LEFTDOWN CM
\def\fgruler@cm@leftdown#1{%
\fgruler@rulercolor%
\fgruler@markthickness%
\fgruler@div{#1}{1}%
\setcounter{fgrulernum}{0}%
\multiput(0,0)(-1,0){\@tempcnta}{\fgruler@ifnot@divisible@five{\fgruler@cm@thick@i\fgruler@cm@color@i\line(0,-1){\fgruler@lentounit{\fgruler@cm@ratio@i\fgruler@marklth}}}}%
\fgruler@div{#1}{5}%
\setcounter{fgrulernum}{0}%
\multiput(0,0)(-5,0){\@tempcnta}{\fgruler@ifodd{\fgruler@cm@thick@ii\fgruler@cm@color@ii\line(0,-1){\fgruler@lentounit{\fgruler@cm@ratio@ii\fgruler@marklth}}}}%
\fgruler@div{#1}{10}%
\multiput(0,0)(-10,0){\@tempcnta}{\fgruler@cm@thick@iii\fgruler@cm@color@iii\line(0,-1){\fgruler@lentounit{\fgruler@marklth}}}%
\iffgruler@borderline\put(0,0){\line(-1,0){\fgruler@lentounit{#1}}}\fi%
\setcounter{fgrulernum}{\fgruler@startnum}\stepcounter{fgrulernum}%
\multiput(-10,-\fgruler@lentounit{\fgruler@sep})(-10,0){\@tempdima}{\makebox(0,0)[t]{\fgruler@font@\thefgrulernum\stepcounter{fgrulernum}}}}

\def\fgruler@cm@leftdown@#1{%
\setlength{\unitlength}{1mm}%
\begin{picture}(\fgruler@lentounit{#1},\fgruler@lentounit{\fgruler@width})(-\fgruler@lentounit{#1},-\fgruler@lentounit{\fgruler@width})%
\fgruler@cm@leftdown{#1}%
\setcounter{fgrulernum}{\fgruler@startnum}%
\put(0,-\fgruler@lentounit{\fgruler@sep}){\makebox(0,0)[t]{\fgruler@font@\thefgrulernum}}%
\ifdim#1>.5cm\put(-5,-\fgruler@lentounit{\fgruler@sep}){\makebox(0,0)[t]{\fgruler@font@\fgruler@caption@cm}}\fi%
\end{picture}}

\def\fgruler@cm@leftdown@@#1{\leavevmode\hbox{}\lower\fgruler@width\hbox{\fgruler@cm@leftdown@{#1}}}

%% LEFTDOWN IN
\def\fgruler@in@leftdown#1{%
\fgruler@rulercolor%
\fgruler@markthickness%
\fgruler@div{#1}{1}%
\setcounter{fgrulernum}{0}%
\multiput(0,0)(-1,0){\@tempcnta}{\fgruler@ifodd{\fgruler@in@thick@i\fgruler@in@color@i\line(0,-1){\fgruler@lentounit{\fgruler@in@ratio@i\fgruler@marklth}}}}%
\fgruler@div{#1}{2}%
\setcounter{fgrulernum}{0}%
\multiput(0,0)(-2,0){\@tempcnta}{\fgruler@ifodd{\fgruler@in@thick@ii\fgruler@in@color@ii\line(0,-1){\fgruler@lentounit{\fgruler@in@ratio@ii\fgruler@marklth}}}}%
\fgruler@div{#1}{4}%
\setcounter{fgrulernum}{0}%
\multiput(0,0)(-4,0){\@tempcnta}{\fgruler@ifodd{\fgruler@in@thick@iii\fgruler@in@color@iii\line(0,-1){\fgruler@lentounit{\fgruler@in@ratio@iii\fgruler@marklth}}}}%
\fgruler@div{#1}{8}%
\setcounter{fgrulernum}{0}%
\multiput(0,0)(-8,0){\@tempcnta}{\fgruler@ifodd{\fgruler@in@thick@iv\fgruler@in@color@iv\line(0,-1){\fgruler@lentounit{\fgruler@in@ratio@iv\fgruler@marklth}}}}%
\fgruler@div{#1}{16}%
\multiput(0,0)(-16,0){\@tempcnta}{\fgruler@in@thick@v\fgruler@in@color@v\line(0,-1){\fgruler@lentounit{\fgruler@marklth}}}%
\iffgruler@borderline\put(0,0){\line(-1,0){\fgruler@lentounit{#1}}}\fi%
\setcounter{fgrulernum}{\fgruler@startnum}\stepcounter{fgrulernum}%
\multiput(-16,-\fgruler@lentounit{\fgruler@sep})(-16,0){\@tempdima}{\makebox(0,0)[t]{\fgruler@font@\thefgrulernum\stepcounter{fgrulernum}}}}

\def\fgruler@in@leftdown@#1{%
\setlength{\unitlength}{.0625in}%
\begin{picture}(\fgruler@lentounit{#1},\fgruler@lentounit{\fgruler@width})(-\fgruler@lentounit{#1},-\fgruler@lentounit{\fgruler@width})%
\fgruler@in@leftdown{#1}%
\setcounter{fgrulernum}{\fgruler@startnum}%
\put(0,-\fgruler@lentounit{\fgruler@sep}){\makebox(0,0)[t]{\fgruler@font@\thefgrulernum}}%
\ifdim#1>.5in\put(-8,-\fgruler@lentounit{\fgruler@sep}){\makebox(0,0)[t]{\fgruler@font@\fgruler@caption@in}}\fi%
\end{picture}}

\def\fgruler@in@leftdown@@#1{\leavevmode\hbox{}\lower\fgruler@width\hbox{\fgruler@in@leftdown@{#1}}}

%% LEFTUP CM
\def\fgruler@cm@leftup#1{%
\fgruler@rulercolor%
\fgruler@markthickness%
\fgruler@div{#1}{1}%
\setcounter{fgrulernum}{0}%
\multiput(0,0)(-1,0){\@tempcnta}{\fgruler@ifnot@divisible@five{\fgruler@cm@thick@i\fgruler@cm@color@i\line(0,1){\fgruler@lentounit{\fgruler@cm@ratio@i\fgruler@marklth}}}}%
\fgruler@div{#1}{5}%
\setcounter{fgrulernum}{0}%
\multiput(0,0)(-5,0){\@tempcnta}{\fgruler@ifodd{\fgruler@cm@thick@ii\fgruler@cm@color@ii\line(0,1){\fgruler@lentounit{\fgruler@cm@ratio@ii\fgruler@marklth}}}}%
\fgruler@div{#1}{10}%
\multiput(0,0)(-10,0){\@tempcnta}{\fgruler@cm@thick@iii\fgruler@cm@color@iii\line(0,1){\fgruler@lentounit{\fgruler@marklth}}}%
\iffgruler@borderline\put(0,0){\line(-1,0){\fgruler@lentounit{#1}}}\fi%
\setcounter{fgrulernum}{\fgruler@startnum}\stepcounter{fgrulernum}%
\multiput(-10,\fgruler@lentounit{\fgruler@sep})(-10,0){\@tempdima}{\makebox(0,0)[b]{\fgruler@font@\thefgrulernum\stepcounter{fgrulernum}}}}

\def\fgruler@cm@leftup@#1{%
\setlength{\unitlength}{1mm}%
\begin{picture}(\fgruler@lentounit{#1},\fgruler@lentounit{\fgruler@width})(-\fgruler@lentounit{#1},0)%
\fgruler@cm@leftup{#1}%
\setcounter{fgrulernum}{\fgruler@startnum}%
\put(0,\fgruler@lentounit{\fgruler@sep}){\makebox(0,0)[b]{\fgruler@font@\thefgrulernum}}%
\ifdim#1>.5cm\put(-5,\fgruler@lentounit{\fgruler@sep}){\makebox(0,0)[b]{\fgruler@font@\fgruler@caption@cm}}\fi%
\end{picture}}

\def\fgruler@cm@leftup@@#1{\leavevmode\hbox{}\lower\fgruler@width\hbox{\fgruler@cm@leftup@{#1}}}

%% LEFTUP IN
\def\fgruler@in@leftup#1{%
\fgruler@rulercolor%
\fgruler@markthickness%
\fgruler@div{#1}{1}%
\setcounter{fgrulernum}{0}%
\multiput(0,0)(-1,0){\@tempcnta}{\fgruler@ifodd{\fgruler@in@thick@i\fgruler@in@color@i\line(0,1){\fgruler@lentounit{\fgruler@in@ratio@i\fgruler@marklth}}}}%
\fgruler@div{#1}{2}%
\setcounter{fgrulernum}{0}%
\multiput(0,0)(-2,0){\@tempcnta}{\fgruler@ifodd{\fgruler@in@thick@ii\fgruler@in@color@ii\line(0,1){\fgruler@lentounit{\fgruler@in@ratio@ii\fgruler@marklth}}}}%
\fgruler@div{#1}{4}%
\setcounter{fgrulernum}{0}%
\multiput(0,0)(-4,0){\@tempcnta}{\fgruler@ifodd{\fgruler@in@thick@iii\fgruler@in@color@iii\line(0,1){\fgruler@lentounit{\fgruler@in@ratio@iii\fgruler@marklth}}}}%
\fgruler@div{#1}{8}%
\setcounter{fgrulernum}{0}%
\multiput(0,0)(-8,0){\@tempcnta}{\fgruler@ifodd{\fgruler@in@thick@iv\fgruler@in@color@iv\line(0,1){\fgruler@lentounit{\fgruler@in@ratio@iv\fgruler@marklth}}}}%
\fgruler@div{#1}{16}%
\multiput(0,0)(-16,0){\@tempcnta}{\fgruler@in@thick@v\fgruler@in@color@v\line(0,1){\fgruler@lentounit{\fgruler@marklth}}}%
\iffgruler@borderline\put(0,0){\line(-1,0){\fgruler@lentounit{#1}}}\fi%
\setcounter{fgrulernum}{\fgruler@startnum}\stepcounter{fgrulernum}%
\multiput(-16,\fgruler@lentounit{\fgruler@sep})(-16,0){\@tempdima}{\makebox(0,0)[b]{\fgruler@font@\thefgrulernum\stepcounter{fgrulernum}}}}

\def\fgruler@in@leftup@#1{%
\setlength{\unitlength}{.0625in}%
\begin{picture}(\fgruler@lentounit{#1},\fgruler@lentounit{\fgruler@width})(-\fgruler@lentounit{#1},0)%
\fgruler@in@leftup{#1}%
\setcounter{fgrulernum}{\fgruler@startnum}%
\put(0,\fgruler@lentounit{\fgruler@sep}){\makebox(0,0)[b]{\fgruler@font@\thefgrulernum}}%
\ifdim#1>.5in\put(-8,\fgruler@lentounit{\fgruler@sep}){\makebox(0,0)[b]{\fgruler@font@\fgruler@caption@in}}\fi%
\end{picture}}

\def\fgruler@in@leftup@@#1{\leavevmode\hbox{}\lower\fgruler@width\hbox{\fgruler@in@leftup@{#1}}}

%% DOWNRIGHT CM
\def\fgruler@cm@downright#1{%
\fgruler@rulercolor%
\fgruler@markthickness%
\fgruler@div{#1}{1}%
\setcounter{fgrulernum}{0}%
\multiput(0,0)(0,-1){\@tempcnta}{\fgruler@ifnot@divisible@five{\fgruler@cm@thick@i\fgruler@cm@color@i\line(1,0){\fgruler@lentounit{\fgruler@cm@ratio@i\fgruler@marklth}}}}%
\fgruler@div{#1}{5}%
\setcounter{fgrulernum}{0}%
\multiput(0,0)(0,-5){\@tempcnta}{\fgruler@ifodd{\fgruler@cm@thick@ii\fgruler@cm@color@ii\line(1,0){\fgruler@lentounit{\fgruler@cm@ratio@ii\fgruler@marklth}}}}%
\fgruler@div{#1}{10}%
\multiput(0,0)(0,-10){\@tempcnta}{\fgruler@cm@thick@iii\fgruler@cm@color@iii\line(1,0){\fgruler@lentounit{\fgruler@marklth}}}%
\iffgruler@borderline\put(0,0){\line(0,-1){\fgruler@lentounit{#1}}}\fi%
\setcounter{fgrulernum}{\fgruler@startnum}\stepcounter{fgrulernum}%
\multiput(\fgruler@lentounit{\fgruler@sep},-10)(0,-10){\@tempdima}{\makebox(0,0)[l]{\fgruler@rotatebox{90}{\fgruler@font@\thefgrulernum\stepcounter{fgrulernum}}}}}

\def\fgruler@cm@downright@#1{%
\setlength{\unitlength}{1mm}%
\begin{picture}(\fgruler@lentounit{\fgruler@width},\fgruler@lentounit{#1})(0,-\fgruler@lentounit{#1})%
\fgruler@cm@downright{#1}%
\setcounter{fgrulernum}{\fgruler@startnum}%
\put(\fgruler@lentounit{\fgruler@sep},0){\makebox(0,0)[l]{\fgruler@rotatebox{90}{\fgruler@font@\thefgrulernum}}}%
\ifdim#1>.5cm\put(\fgruler@lentounit{\fgruler@sep},-5){\makebox(0,0)[l]{\fgruler@rotatebox{90}{\fgruler@font@\fgruler@caption@cm}}}\fi%
\end{picture}}

\def\fgruler@cm@downright@@#1{\leavevmode\hbox{}\lower#1\hbox{\fgruler@cm@downright@{#1}}}

%% DOWNRIGHT IN
\def\fgruler@in@downright#1{%
\fgruler@rulercolor%
\fgruler@markthickness%
\fgruler@div{#1}{1}%
\setcounter{fgrulernum}{0}%
\multiput(0,0)(0,-1){\@tempcnta}{\fgruler@ifodd{\fgruler@in@thick@i\fgruler@in@color@i\line(1,0){\fgruler@lentounit{\fgruler@in@ratio@i\fgruler@marklth}}}}%
\fgruler@div{#1}{2}%
\setcounter{fgrulernum}{0}%
\multiput(0,0)(0,-2){\@tempcnta}{\fgruler@ifodd{\fgruler@in@thick@ii\fgruler@in@color@ii\line(1,0){\fgruler@lentounit{\fgruler@in@ratio@ii\fgruler@marklth}}}}%
\fgruler@div{#1}{4}%
\setcounter{fgrulernum}{0}%
\multiput(0,0)(0,-4){\@tempcnta}{\fgruler@ifodd{\fgruler@in@thick@iii\fgruler@in@color@iii\line(1,0){\fgruler@lentounit{\fgruler@in@ratio@iii\fgruler@marklth}}}}%
\fgruler@div{#1}{8}%
\setcounter{fgrulernum}{0}%
\multiput(0,0)(0,-8){\@tempcnta}{\fgruler@ifodd{\fgruler@in@thick@iv\fgruler@in@color@iv\line(1,0){\fgruler@lentounit{\fgruler@in@ratio@iv\fgruler@marklth}}}}%
\fgruler@div{#1}{16}%
\multiput(0,0)(0,-16){\@tempcnta}{\fgruler@in@thick@v\fgruler@in@color@v\line(1,0){\fgruler@lentounit{\fgruler@marklth}}}%
\iffgruler@borderline\put(0,0){\line(0,-1){\fgruler@lentounit{#1}}}\fi%
\setcounter{fgrulernum}{\fgruler@startnum}\stepcounter{fgrulernum}%
\multiput(\fgruler@lentounit{\fgruler@sep},-16)(0,-16){\@tempdima}{\makebox(0,0)[l]{\fgruler@rotatebox{90}{\fgruler@font@\thefgrulernum\stepcounter{fgrulernum}}}}}

\def\fgruler@in@downright@#1{%
\setlength{\unitlength}{.0625in}%
\begin{picture}(\fgruler@lentounit{\fgruler@width},\fgruler@lentounit{#1})(0,-\fgruler@lentounit{#1})%
\fgruler@in@downright{#1}%
\setcounter{fgrulernum}{\fgruler@startnum}%
\put(\fgruler@lentounit{\fgruler@sep},0){\makebox(0,0)[l]{\fgruler@rotatebox{90}{\fgruler@font@\thefgrulernum}}}%
\ifdim#1>.5in\put(\fgruler@lentounit{\fgruler@sep},-8){\makebox(0,0)[l]{\fgruler@rotatebox{90}{\fgruler@font@\fgruler@caption@in}}}\fi%
\end{picture}}

\def\fgruler@in@downright@@#1{\leavevmode\hbox{}\lower#1\hbox{\fgruler@in@downright@{#1}}}

%% DOWNLEFT CM
\def\fgruler@cm@downleft#1{%
\fgruler@rulercolor%
\fgruler@markthickness%
\fgruler@div{#1}{1}%
\setcounter{fgrulernum}{0}%
\multiput(0,0)(0,-1){\@tempcnta}{\fgruler@ifnot@divisible@five{\fgruler@cm@thick@i\fgruler@cm@color@i\line(-1,0){\fgruler@lentounit{\fgruler@cm@ratio@i\fgruler@marklth}}}}%
\fgruler@div{#1}{5}%
\setcounter{fgrulernum}{0}%
\multiput(0,0)(0,-5){\@tempcnta}{\fgruler@ifodd{\fgruler@cm@thick@ii\fgruler@cm@color@ii\line(-1,0){\fgruler@lentounit{\fgruler@cm@ratio@ii\fgruler@marklth}}}}%
\fgruler@div{#1}{10}%
\multiput(0,0)(0,-10){\@tempcnta}{\fgruler@cm@thick@iii\fgruler@cm@color@iii\line(-1,0){\fgruler@lentounit{\fgruler@marklth}}}%
\iffgruler@borderline\put(0,0){\line(0,-1){\fgruler@lentounit{#1}}}\fi%
\setcounter{fgrulernum}{\fgruler@startnum}\stepcounter{fgrulernum}%
\multiput(-\fgruler@lentounit{\fgruler@sep},-10)(0,-10){\@tempdima}{\makebox(0,0)[r]{\fgruler@rotatebox{-90}{\fgruler@font@\thefgrulernum\stepcounter{fgrulernum}}}}}

\def\fgruler@cm@downleft@#1{%
\setlength{\unitlength}{1mm}%
\begin{picture}(\fgruler@lentounit{\fgruler@width},\fgruler@lentounit{#1})(-\fgruler@lentounit{\fgruler@width},-\fgruler@lentounit{#1})%
\fgruler@cm@downleft{#1}%
\setcounter{fgrulernum}{\fgruler@startnum}%
\put(-\fgruler@lentounit{\fgruler@sep},0){\makebox(0,0)[r]{\fgruler@rotatebox{-90}{\fgruler@font@\thefgrulernum}}}%
\ifdim#1>.5cm\put(-\fgruler@lentounit{\fgruler@sep},-5){\makebox(0,0)[r]{\fgruler@rotatebox{-90}{\fgruler@font@\fgruler@caption@cm}}}\fi%
\end{picture}}

\def\fgruler@cm@downleft@@#1{\leavevmode\hbox{}\lower#1\hbox{\fgruler@cm@downleft@{#1}}}

%% DOWNLEFT IN
\def\fgruler@in@downleft#1{%
\fgruler@rulercolor%
\fgruler@markthickness%
\fgruler@div{#1}{1}%
\setcounter{fgrulernum}{0}%
\multiput(0,0)(0,-1){\@tempcnta}{\fgruler@ifodd{\fgruler@in@thick@i\fgruler@in@color@i\line(-1,0){\fgruler@lentounit{\fgruler@in@ratio@i\fgruler@marklth}}}}%
\fgruler@div{#1}{2}%
\setcounter{fgrulernum}{0}%
\multiput(0,0)(0,-2){\@tempcnta}{\fgruler@ifodd{\fgruler@in@thick@ii\fgruler@in@color@ii\line(-1,0){\fgruler@lentounit{\fgruler@in@ratio@ii\fgruler@marklth}}}}%
\fgruler@div{#1}{4}%
\setcounter{fgrulernum}{0}%
\multiput(0,0)(0,-4){\@tempcnta}{\fgruler@ifodd{\fgruler@in@thick@iii\fgruler@in@color@iii\line(-1,0){\fgruler@lentounit{\fgruler@in@ratio@iii\fgruler@marklth}}}}%
\fgruler@div{#1}{8}%
\setcounter{fgrulernum}{0}%
\multiput(0,0)(0,-8){\@tempcnta}{\fgruler@ifodd{\fgruler@in@thick@iv\fgruler@in@color@iv\line(-1,0){\fgruler@lentounit{\fgruler@in@ratio@iv\fgruler@marklth}}}}%
\fgruler@div{#1}{16}%
\multiput(0,0)(0,-16){\@tempcnta}{\fgruler@in@thick@v\fgruler@in@color@v\line(-1,0){\fgruler@lentounit{\fgruler@marklth}}}%
\iffgruler@borderline\put(0,0){\line(0,-1){\fgruler@lentounit{#1}}}\fi%
\setcounter{fgrulernum}{\fgruler@startnum}\stepcounter{fgrulernum}%
\multiput(-\fgruler@lentounit{\fgruler@sep},-16)(0,-16){\@tempdima}{\makebox(0,0)[r]{\fgruler@rotatebox{-90}{\fgruler@font@\thefgrulernum\stepcounter{fgrulernum}}}}}

\def\fgruler@in@downleft@#1{%
\setlength{\unitlength}{.0625in}%
\begin{picture}(\fgruler@lentounit{\fgruler@width},\fgruler@lentounit{#1})(-\fgruler@lentounit{\fgruler@width},-\fgruler@lentounit{#1})%
\fgruler@in@downleft{#1}%
\setcounter{fgrulernum}{\fgruler@startnum}%
\put(-\fgruler@lentounit{\fgruler@sep},0){\makebox(0,0)[r]{\fgruler@rotatebox{-90}{\fgruler@font@\thefgrulernum}}}%
\ifdim#1>.5in\put(-\fgruler@lentounit{\fgruler@sep},-8){\makebox(0,0)[r]{\fgruler@rotatebox{-90}{\fgruler@font@\fgruler@caption@in}}}\fi%
\end{picture}}

\def\fgruler@in@downleft@@#1{\leavevmode\hbox{}\lower#1\hbox{\fgruler@in@downleft@{#1}}}

%% UPRIGHT CM
\def\fgruler@cm@upright#1{%
\fgruler@rulercolor%
\fgruler@markthickness%
\fgruler@div{#1}{1}%
\setcounter{fgrulernum}{0}%
\multiput(0,0)(0,1){\@tempcnta}{\fgruler@ifnot@divisible@five{\fgruler@cm@thick@i\fgruler@cm@color@i\line(1,0){\fgruler@lentounit{\fgruler@cm@ratio@i\fgruler@marklth}}}}%
\fgruler@div{#1}{5}%
\setcounter{fgrulernum}{0}%
\multiput(0,0)(0,5){\@tempcnta}{\fgruler@ifodd{\fgruler@cm@thick@ii\fgruler@cm@color@ii\line(1,0){\fgruler@lentounit{\fgruler@cm@ratio@ii\fgruler@marklth}}}}%
\fgruler@div{#1}{10}%
\multiput(0,0)(0,10){\@tempcnta}{\fgruler@cm@thick@iii\fgruler@cm@color@iii\line(1,0){\fgruler@lentounit{\fgruler@marklth}}}%
\iffgruler@borderline\put(0,0){\line(0,1){\fgruler@lentounit{#1}}}\fi%
\setcounter{fgrulernum}{\fgruler@startnum}\stepcounter{fgrulernum}%
\multiput(\fgruler@lentounit{\fgruler@sep},10)(0,10){\@tempdima}{\makebox(0,0)[l]{\fgruler@rotatebox{90}{\fgruler@font@\thefgrulernum\stepcounter{fgrulernum}}}}}

\def\fgruler@cm@upright@#1{%
\setlength{\unitlength}{1mm}%
\begin{picture}(\fgruler@lentounit{\fgruler@width},\fgruler@lentounit{#1})%
\fgruler@cm@upright{#1}%
\setcounter{fgrulernum}{\fgruler@startnum}%
\put(\fgruler@lentounit{\fgruler@sep},0){\makebox(0,0)[l]{\fgruler@rotatebox{90}{\fgruler@font@\thefgrulernum}}}%
\ifdim#1>.5cm\put(\fgruler@lentounit{\fgruler@sep},5){\makebox(0,0)[l]{\fgruler@rotatebox{90}{\fgruler@font@\fgruler@caption@cm}}}\fi%
\end{picture}}

\def\fgruler@cm@upright@@#1{\leavevmode\hbox{}\lower#1\hbox{\fgruler@cm@upright@{#1}}}

%% UPRIGHT IN
\def\fgruler@in@upright#1{%
\fgruler@rulercolor%
\fgruler@markthickness%
\fgruler@div{#1}{1}%
\setcounter{fgrulernum}{0}%
\multiput(0,0)(0,1){\@tempcnta}{\fgruler@ifodd{\fgruler@in@thick@i\fgruler@in@color@i\line(1,0){\fgruler@lentounit{\fgruler@in@ratio@i\fgruler@marklth}}}}%
\fgruler@div{#1}{2}%
\setcounter{fgrulernum}{0}%
\multiput(0,0)(0,2){\@tempcnta}{\fgruler@ifodd{\fgruler@in@thick@ii\fgruler@in@color@ii\line(1,0){\fgruler@lentounit{\fgruler@in@ratio@ii\fgruler@marklth}}}}%
\fgruler@div{#1}{4}%
\setcounter{fgrulernum}{0}%
\multiput(0,0)(0,4){\@tempcnta}{\fgruler@ifodd{\fgruler@in@thick@iii\fgruler@in@color@iii\line(1,0){\fgruler@lentounit{\fgruler@in@ratio@iii\fgruler@marklth}}}}%
\fgruler@div{#1}{8}%
\setcounter{fgrulernum}{0}%
\multiput(0,0)(0,8){\@tempcnta}{\fgruler@ifodd{\fgruler@in@thick@iv\fgruler@in@color@iv\line(1,0){\fgruler@lentounit{\fgruler@in@ratio@iv\fgruler@marklth}}}}%
\fgruler@div{#1}{16}%
\multiput(0,0)(0,16){\@tempcnta}{\fgruler@in@thick@v\fgruler@in@color@v\line(1,0){\fgruler@lentounit{\fgruler@marklth}}}%
\iffgruler@borderline\put(0,0){\line(0,1){\fgruler@lentounit{#1}}}\fi%
\setcounter{fgrulernum}{\fgruler@startnum}\stepcounter{fgrulernum}%
\multiput(\fgruler@lentounit{\fgruler@sep},16)(0,16){\@tempdima}{\makebox(0,0)[l]{\fgruler@rotatebox{90}{\fgruler@font@\thefgrulernum\stepcounter{fgrulernum}}}}}

\def\fgruler@in@upright@#1{%
\setlength{\unitlength}{.0625in}%
\begin{picture}(\fgruler@lentounit{\fgruler@width},\fgruler@lentounit{#1})%
\fgruler@in@upright{#1}%
\setcounter{fgrulernum}{\fgruler@startnum}%
\put(\fgruler@lentounit{\fgruler@sep},0){\makebox(0,0)[l]{\fgruler@rotatebox{90}{\fgruler@font@\thefgrulernum}}}%
\ifdim#1>.5in\put(\fgruler@lentounit{\fgruler@sep},8){\makebox(0,0)[l]{\fgruler@rotatebox{90}{\fgruler@font@\fgruler@caption@in}}}\fi%
\end{picture}}

\def\fgruler@in@upright@@#1{\leavevmode\hbox{}\lower#1\hbox{\fgruler@in@upright@{#1}}}

%% UPLEFT CM
\def\fgruler@cm@upleft#1{%
\fgruler@rulercolor%
\fgruler@markthickness%
\fgruler@div{#1}{1}%
\setcounter{fgrulernum}{0}%
\multiput(0,0)(0,1){\@tempcnta}{\fgruler@ifnot@divisible@five{\fgruler@cm@thick@i\fgruler@cm@color@i\line(-1,0){\fgruler@lentounit{\fgruler@cm@ratio@i\fgruler@marklth}}}}%
\fgruler@div{#1}{5}%
\setcounter{fgrulernum}{0}%
\multiput(0,0)(0,5){\@tempcnta}{\fgruler@ifodd{\fgruler@cm@thick@ii\fgruler@cm@color@ii\line(-1,0){\fgruler@lentounit{\fgruler@cm@ratio@ii\fgruler@marklth}}}}%
\fgruler@div{#1}{10}%
\multiput(0,0)(0,10){\@tempcnta}{\fgruler@cm@thick@iii\fgruler@cm@color@iii\line(-1,0){\fgruler@lentounit{\fgruler@marklth}}}%
\iffgruler@borderline\put(0,0){\line(0,1){\fgruler@lentounit{#1}}}\fi%
\setcounter{fgrulernum}{\fgruler@startnum}\stepcounter{fgrulernum}%
\multiput(-\fgruler@lentounit{\fgruler@sep},10)(0,10){\@tempdima}{\makebox(0,0)[r]{\fgruler@rotatebox{-90}{\fgruler@font@\thefgrulernum\stepcounter{fgrulernum}}}}}

\def\fgruler@cm@upleft@#1{%
\setlength{\unitlength}{1mm}%
\begin{picture}(\fgruler@lentounit{\fgruler@width},\fgruler@lentounit{#1})(-\fgruler@lentounit{\fgruler@width},0)%
\fgruler@cm@upleft{#1}%
\setcounter{fgrulernum}{\fgruler@startnum}%
\put(-\fgruler@lentounit{\fgruler@sep},0){\makebox(0,0)[r]{\fgruler@rotatebox{-90}{\fgruler@font@\thefgrulernum}}}%
\ifdim#1>.5cm\put(-\fgruler@lentounit{\fgruler@sep},5){\makebox(0,0)[r]{\fgruler@rotatebox{-90}{\fgruler@font@\fgruler@caption@cm}}}\fi%
\end{picture}}

\def\fgruler@cm@upleft@@#1{\leavevmode\hbox{}\lower#1\hbox{\fgruler@cm@upleft@{#1}}}

%% UPLEFT IN
\def\fgruler@in@upleft#1{%
\fgruler@rulercolor%
\fgruler@markthickness%
\fgruler@div{#1}{1}%
\setcounter{fgrulernum}{0}%
\multiput(0,0)(0,1){\@tempcnta}{\fgruler@ifodd{\fgruler@in@thick@i\fgruler@in@color@i\line(-1,0){\fgruler@lentounit{\fgruler@in@ratio@i\fgruler@marklth}}}}%
\fgruler@div{#1}{2}%
\setcounter{fgrulernum}{0}%
\multiput(0,0)(0,2){\@tempcnta}{\fgruler@ifodd{\fgruler@in@thick@ii\fgruler@in@color@ii\line(-1,0){\fgruler@lentounit{\fgruler@in@ratio@ii\fgruler@marklth}}}}%
\fgruler@div{#1}{4}%
\setcounter{fgrulernum}{0}%
\multiput(0,0)(0,4){\@tempcnta}{\fgruler@ifodd{\fgruler@in@thick@iii\fgruler@in@color@iii\line(-1,0){\fgruler@lentounit{\fgruler@in@ratio@iii\fgruler@marklth}}}}%
\fgruler@div{#1}{8}%
\setcounter{fgrulernum}{0}%
\multiput(0,0)(0,8){\@tempcnta}{\fgruler@ifodd{\fgruler@in@thick@iv\fgruler@in@color@iv\line(-1,0){\fgruler@lentounit{\fgruler@in@ratio@iv\fgruler@marklth}}}}%
\fgruler@div{#1}{16}%
\multiput(0,0)(0,16){\@tempcnta}{\fgruler@in@thick@v\fgruler@in@color@v\line(-1,0){\fgruler@lentounit{\fgruler@marklth}}}%
\iffgruler@borderline\put(0,0){\line(0,1){\fgruler@lentounit{#1}}}\fi%
\setcounter{fgrulernum}{\fgruler@startnum}\stepcounter{fgrulernum}%
\multiput(-\fgruler@lentounit{\fgruler@sep},16)(0,16){\@tempdima}{\makebox(0,0)[r]{\fgruler@rotatebox{-90}{\fgruler@font@\thefgrulernum\stepcounter{fgrulernum}}}}}

\def\fgruler@in@upleft@#1{%
\setlength{\unitlength}{.0625in}%
\begin{picture}(\fgruler@lentounit{\fgruler@width},\fgruler@lentounit{#1})(-\fgruler@lentounit{\fgruler@width},0)%
\fgruler@in@upleft{#1}%
\setcounter{fgrulernum}{\fgruler@startnum}%
\put(-\fgruler@lentounit{\fgruler@sep},0){\makebox(0,0)[r]{\fgruler@rotatebox{-90}{\fgruler@font@\thefgrulernum}}}%
\ifdim#1>.5in\put(-\fgruler@lentounit{\fgruler@sep},8){\makebox(0,0)[r]{\fgruler@rotatebox{-90}{\fgruler@font@\fgruler@caption@in}}}\fi%
\end{picture}}

\def\fgruler@in@upleft@@#1{\leavevmode\hbox{}\lower#1\hbox{\fgruler@in@upleft@{#1}}}

%% UPPERLEFT CM
\def\fgruler@cm@upperleft@#1#2{%
\setlength{\unitlength}{1mm}%
\begin{picture}(\fgruler@lentounit{#1},\fgruler@lentounit{#2})(0,-\fgruler@lentounit{#2})%
\fgruler@cm@rightdown{#1}%
\fgruler@cm@downright{#2}%
\ifdim#1>.5cm\put(5,-\fgruler@lentounit{\fgruler@sep}){\makebox(0,0)[t]{\fgruler@font@\fgruler@caption@cm}}\fi%
\end{picture}}

\def\fgruler@cm@upperleft@@#1#2{\leavevmode\hbox{}\lower#2\hbox{\fgruler@cm@upperleft@{#1}{#2}}}

\def\fgruler@cm@upperleft@fg@#1#2{%
\begingroup%
\setlength{\fgruler@fg@width}{\paperwidth}%
\addtolength{\fgruler@fg@width}{-#1}%
\setlength{\fgruler@fg@height}{\paperheight}%
\addtolength{\fgruler@fg@height}{-#2}%
\fgruler@fgsetting%
\AtPageLowerLeft{\put(\fgruler@lentounit{#1},0){%
\fgruler@cm@upperleft@{\fgruler@fg@width}{\fgruler@fg@height}}}%
\endgroup}

\def\fgruler@cm@upperleft@fg{\fgruler@cm@upperleft@fg@{\fgruler@hshift}{\fgruler@vshift}}

%% UPPERLEFT IN
\def\fgruler@in@upperleft@#1#2{%
\setlength{\unitlength}{.0625in}%
\begin{picture}(\fgruler@lentounit{#1},\fgruler@lentounit{#2})(0,-\fgruler@lentounit{#2})%
\fgruler@in@rightdown{#1}%
\fgruler@in@downright{#2}%
\ifdim#1>.5in\put(8,-\fgruler@lentounit{\fgruler@sep}){\makebox(0,0)[t]{\fgruler@font@\fgruler@caption@in}}\fi%
\end{picture}}

\def\fgruler@in@upperleft@@#1#2{\leavevmode\hbox{}\lower#2\hbox{\fgruler@in@upperleft@{#1}{#2}}}

\def\fgruler@in@upperleft@fg@#1#2{%
\begingroup%
\setlength{\fgruler@fg@width}{\paperwidth}%
\addtolength{\fgruler@fg@width}{-#1}%
\setlength{\fgruler@fg@height}{\paperheight}%
\addtolength{\fgruler@fg@height}{-#2}%
\fgruler@fgsetting%
\AtPageLowerLeft{\put(\fgruler@lentounit{#1},0){%
\fgruler@in@upperleft@{\fgruler@fg@width}{\fgruler@fg@height}}}%
\endgroup}

\def\fgruler@in@upperleft@fg{\fgruler@in@upperleft@fg@{\fgruler@hshift}{\fgruler@vshift}}

%% UPPERRIGHT CM
\def\fgruler@cm@upperright@#1#2{%
\setlength{\unitlength}{1mm}%
\begin{picture}(\fgruler@lentounit{#1},\fgruler@lentounit{#2})(-\fgruler@lentounit{#1},-\fgruler@lentounit{#2})%
\fgruler@cm@leftdown{#1}%
\fgruler@cm@downleft{#2}%
\ifdim#1>.5cm\put(-5,-\fgruler@lentounit{\fgruler@sep}){\makebox(0,0)[t]{\fgruler@font@\fgruler@caption@cm}}\fi%
\end{picture}}

\def\fgruler@cm@upperright@@#1#2{\leavevmode\hbox{}\lower#2\hbox{\fgruler@cm@upperright@{#1}{#2}}}

\def\fgruler@cm@upperright@fg@#1#2{%
\begingroup%
\setlength{\fgruler@fg@width}{\paperwidth}%
\addtolength{\fgruler@fg@width}{-#1}%
\setlength{\fgruler@fg@height}{\paperheight}%
\addtolength{\fgruler@fg@height}{-#2}%
\fgruler@fgsetting%
\AtPageLowerLeft{\fgruler@cm@upperright@{\fgruler@fg@width}{\fgruler@fg@height}}%
\endgroup}

\def\fgruler@cm@upperright@fg{\fgruler@cm@upperright@fg@{\fgruler@hshift}{\fgruler@vshift}}

%% UPPERRIGHT IN
\def\fgruler@in@upperright@#1#2{%
\setlength{\unitlength}{.0625in}%
\begin{picture}(\fgruler@lentounit{#1},\fgruler@lentounit{#2})(-\fgruler@lentounit{#1},-\fgruler@lentounit{#2})%
\fgruler@in@leftdown{#1}%
\fgruler@in@downleft{#2}%
\ifdim#1>.5in\put(-8,-\fgruler@lentounit{\fgruler@sep}){\makebox(0,0)[t]{\fgruler@font@\fgruler@caption@in}}\fi%
\end{picture}}

\def\fgruler@in@upperright@@#1#2{\leavevmode\hbox{}\lower#2\hbox{\fgruler@in@upperright@{#1}{#2}}}

\def\fgruler@in@upperright@fg@#1#2{%
\begingroup%
\setlength{\fgruler@fg@width}{\paperwidth}%
\addtolength{\fgruler@fg@width}{-#1}%
\setlength{\fgruler@fg@height}{\paperheight}%
\addtolength{\fgruler@fg@height}{-#2}%
\fgruler@fgsetting%
\AtPageLowerLeft{\fgruler@in@upperright@{\fgruler@fg@width}{\fgruler@fg@height}}%
\endgroup}

\def\fgruler@in@upperright@fg{\fgruler@in@upperright@fg@{\fgruler@hshift}{\fgruler@vshift}}

%% LOWERLEFT CM
\def\fgruler@cm@lowerleft@#1#2{%
\setlength{\unitlength}{1mm}%
\begin{picture}(\fgruler@lentounit{#1},\fgruler@lentounit{#2})%
\fgruler@cm@rightup{#1}%
\fgruler@cm@upright{#2}%
\ifdim#1>.5cm\put(5,\fgruler@lentounit{\fgruler@sep}){\makebox(0,0)[b]{\fgruler@font@\fgruler@caption@cm}}\fi%
\end{picture}}

\def\fgruler@cm@lowerleft@@#1#2{\leavevmode\hbox{}\lower#2\hbox{\fgruler@cm@lowerleft@{#1}{#2}}}

\def\fgruler@cm@lowerleft@fg@#1#2{%
\begingroup%
\setlength{\fgruler@fg@width}{\paperwidth}%
\addtolength{\fgruler@fg@width}{-#1}%
\setlength{\fgruler@fg@height}{\paperheight}%
\addtolength{\fgruler@fg@height}{-#2}%
\fgruler@fgsetting%
\AtPageLowerLeft{\put(\fgruler@lentounit{#1},\fgruler@lentounit{#2}){%
\fgruler@cm@lowerleft@{\fgruler@fg@width}{\fgruler@fg@height}}}%
\endgroup}

\def\fgruler@cm@lowerleft@fg{\fgruler@cm@lowerleft@fg@{\fgruler@hshift}{\fgruler@vshift}}

%% LOWERLEFT IN
\def\fgruler@in@lowerleft@#1#2{%
\setlength{\unitlength}{.0625in}%
\begin{picture}(\fgruler@lentounit{#1},\fgruler@lentounit{#2})%
\fgruler@in@rightup{#1}%
\fgruler@in@upright{#2}%
\ifdim#1>.5in\put(8,\fgruler@lentounit{\fgruler@sep}){\makebox(0,0)[b]{\fgruler@font@\fgruler@caption@in}}\fi%
\end{picture}}

\def\fgruler@in@lowerleft@@#1#2{\leavevmode\hbox{}\lower#2\hbox{\fgruler@in@lowerleft@{#1}{#2}}}

\def\fgruler@in@lowerleft@fg@#1#2{%
\begingroup%
\setlength{\fgruler@fg@width}{\paperwidth}%
\addtolength{\fgruler@fg@width}{-#1}%
\setlength{\fgruler@fg@height}{\paperheight}%
\addtolength{\fgruler@fg@height}{-#2}%
\fgruler@fgsetting%
\AtPageLowerLeft{\put(\fgruler@lentounit{#1},\fgruler@lentounit{#2}){%
\fgruler@in@lowerleft@{\fgruler@fg@width}{\fgruler@fg@height}}}%
\endgroup}

\def\fgruler@in@lowerleft@fg{\fgruler@in@lowerleft@fg@{\fgruler@hshift}{\fgruler@vshift}}

%% LOWERRIGHT CM
\def\fgruler@cm@lowerright@#1#2{%
\setlength{\unitlength}{1mm}%
\begin{picture}(\fgruler@lentounit{#1},\fgruler@lentounit{#2})(-\fgruler@lentounit{#1},0)%
\fgruler@cm@leftup{#1}%
\fgruler@cm@upleft{#2}%
\ifdim#1>.5cm\put(-5,\fgruler@lentounit{\fgruler@sep}){\makebox(0,0)[b]{\fgruler@font@\fgruler@caption@cm}}\fi%
\end{picture}}

\def\fgruler@cm@lowerright@@#1#2{\leavevmode\hbox{}\lower#2\hbox{\fgruler@cm@lowerright@{#1}{#2}}}

\def\fgruler@cm@lowerright@fg@#1#2{%
\begingroup%
\setlength{\fgruler@fg@width}{\paperwidth}%
\addtolength{\fgruler@fg@width}{-#1}%
\setlength{\fgruler@fg@height}{\paperheight}%
\addtolength{\fgruler@fg@height}{-#2}%
\fgruler@fgsetting%
\AtPageLowerLeft{\put(0,\fgruler@lentounit{#2}){%
\fgruler@cm@lowerright@{\fgruler@fg@width}{\fgruler@fg@height}}}%
\endgroup}

\def\fgruler@cm@lowerright@fg{\fgruler@cm@lowerright@fg@{\fgruler@hshift}{\fgruler@vshift}}

%% LOWERRIGHT IN
\def\fgruler@in@lowerright@#1#2{%
\setlength{\unitlength}{.0625in}%
\begin{picture}(\fgruler@lentounit{#1},\fgruler@lentounit{#2})(-\fgruler@lentounit{#1},0)%
\fgruler@in@leftup{#1}%
\fgruler@in@upleft{#2}%
\ifdim#1>.5in\put(-8,\fgruler@lentounit{\fgruler@sep}){\makebox(0,0)[b]{\fgruler@font@\fgruler@caption@in}}\fi%
\end{picture}}

\def\fgruler@in@lowerright@@#1#2{\leavevmode\hbox{}\lower#2\hbox{\fgruler@in@lowerright@{#1}{#2}}}

\def\fgruler@in@lowerright@fg@#1#2{%
\begingroup%
\setlength{\fgruler@fg@width}{\paperwidth}%
\addtolength{\fgruler@fg@width}{-#1}%
\setlength{\fgruler@fg@height}{\paperheight}%
\addtolength{\fgruler@fg@height}{-#2}%
\fgruler@fgsetting%
\AtPageLowerLeft{\put(0,\fgruler@lentounit{#2}){%
\fgruler@in@lowerright@{\fgruler@fg@width}{\fgruler@fg@height}}}%
\endgroup}

\def\fgruler@in@lowerright@fg{\fgruler@in@lowerright@fg@{\fgruler@hshift}{\fgruler@vshift}}
\endinput
%%
%% End of file `fgruler.sty'.