summaryrefslogtreecommitdiff
path: root/language/korean/kotex-oblivoir/memhangul-ucs/fapapersize.sty
blob: 4cb7d1ffd6b115ea7e800ddf1507e1f6f1d62474 (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
%% File `fapapersize.sty`
%%
%% Copyright (c) 2006-2013 Kangsoo Kim <karnes at ktug org>
%%
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3c
%% 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.3c or later is part of all distributions of LaTeX
%% version 2006/05/20 or later.
%%
%% ver 0.031 (2006/12/04)
%%   trivial bug fix.
%% ver 0.03 (2006/11/24)
%%   stocksize를 별도 지정할 수 있게 함
%%   option [stock], command \usefastocksize{<width>}{<height>}
%% ver 0.02
%%   사륙배판, 국판, 신국판 정의.
%%   marginnote 영역 설정은 제외되어 있음.
\ProvidesPackage{fapapersize}
%%%
%%% 옵션
%%% dbl4x6 : 사륙배판
%%% mum : 국판
%%% newmum : 신국판
\DeclareOption{dbl4x6}{%
  \AtEndOfPackage{\usefapapersize{190mm,260mm,30mm,*,30mm,*}}%
}
\DeclareOption{mum}{%
  \AtEndOfPackage{\usefapapersize{148mm,210mm,25mm,*,25mm,*}}%
}
\DeclareOption{newmum}{%
  \AtEndOfPackage{\usefapapersize{154mm,225mm,25mm,*,25mm,*}}%
}
\newif\ifStockSize@\StockSize@false
\DeclareOption{stock}{%
  \StockSize@true
}
\newif\if@showtrim\@showtrimfalse
%\DeclareOption{trimmark}{\@showtrimtrue}
\DeclareOption{showtrims}{\@showtrimtrue}
\ProcessOptions

\newlength\fa@stockheight\newlength\fa@stockwidth
\newlength\fa@paperheight\newlength\fa@paperwidth
\newlength\fa@leftmargin\newlength\fa@rightmargin
\newlength\fa@uppermargin\newlength\fa@lowermargin
\newlength\fa@tmplenwd\newlength\fa@tmplenht

\newdimen\tmp@dim

\def\set@paper@size{%
 \ifnum\fa@paperwidth>\fa@tmplenwd
  \if@showtrim
   \typeout{the page size is too small. Trim mark will not be shown.}
   \@showtrimfalse\trimNone
  \fi
 \fi
 \if@showtrim
   \setstocksize{\fa@tmplenht}{\fa@tmplenwd}
   \settrimmedsize{\fa@paperheight}{\fa@paperwidth}{*}
   \setlrmarginsandblock{\fa@leftmargin}{\fa@rightmargin}{*}
   \setulmarginsandblock{\fa@uppermargin}{\fa@lowermargin}{*}
   \setlength{\trimtop}{\stockheight}
   \addtolength{\trimtop}{-\paperheight}
   \setlength{\trimedge}{\stockwidth}
   \addtolength{\trimedge}{-\paperwidth}
   \settrims{.5\trimtop}{.5\trimedge}
   \trimLmarks 
 \else
   \setstocksize{\fa@paperheight}{\fa@paperwidth}
   \settrimmedsize{\stockheight}{\stockwidth}{*}
   \setlrmarginsandblock{\fa@leftmargin}{\fa@rightmargin}{*}
   \setulmarginsandblock{\fa@uppermargin}{\fa@lowermargin}{*}
   \trimNone
 \fi
 \tmp@dim=\headheight\advance\tmp@dim by\headsep\advance\tmp@dim by1mm
 \ifdim\fa@uppermargin<\tmp@dim
   \setheaderspaces{*}{10pt}{*}
   \tmp@dim=\fa@uppermargin\advance\tmp@dim by-\headsep\advance\tmp@dim by-1mm
   \setheadfoot{\tmp@dim}{\tmp@dim}
 \fi
 \checkandfixthelayout
}

\def\@usefastocksize#1#2{%
 \setlength\fa@stockheight{#2}%
 \setlength\fa@stockwidth{#1}%
}

\newcommand*{\usefastocksize}[1]{%
 \set@fa@stocksizeparameters#1\@nil
}

\def\set@fa@stocksizeparameters#1,#2\@nil{%
 \setlength{\fa@stockwidth}{#1}%
 \setlength{\fa@stockheight}{#2}%
}

\def\@usefapapersize#1#2#3[#4]#5[#6]{%
 \setlength\fa@paperwidth{#1}
 \setlength\fa@paperheight{#2}
 \setlength\fa@leftmargin{#3}
 \setlength\fa@rightmargin{#4}
 \setlength\fa@uppermargin{#5}
 \setlength\fa@lowermargin{#6}
}

\newcommand*\usefapapersize[1]{%
 \get@stocksize
 \set@fa@papersizeparameters#1\@nil
 \set@paper@size
}

\def\get@stocksize{%
 \ifStockSize@
  \def\fa@tmplenwd{\fa@stockwidth}\def\fa@tmplenht{\fa@stockheight}
 \else
  \def\fa@tmplenwd{\stockwidth}\def\fa@tmplenht{\stockheight}
 \fi
}

\def\set@fa@papersizeparameters#1,#2,#3,#4,#5,#6\@nil{%
 \ifx*#1\def\@tmp@pgwidth{\fa@tmplenwd}\else\def\@tmp@pgwidth{#1}\fi
 \ifx*#2\def\@tmp@pgheight{\fa@tmplenht}\else\def\@tmp@pgheight{#2}\fi
 \ifx*#4
  \ifx*#6
     \@usefapapersize{\@tmp@pgwidth}{\@tmp@pgheight}{#3}[{#3}]{#5}[{#5}]
   \else
     \@usefapapersize{\@tmp@pgwidth}{\@tmp@pgheight}{#3}[{#3}]{#5}[{#6}]
  \fi\else
  \ifx*#6
     \@usefapapersize{\@tmp@pgwidth}{\@tmp@pgheight}{#3}[{#4}]{#5}[{#5}]
  \else
     \@usefapapersize{\@tmp@pgwidth}{\@tmp@pgheight}{#3}[{#4}]{#5}[{#6}]
  \fi
 \fi
}

\endinput