summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/kotex-oblivoir/memhangul-common/fapapersize.sty
blob: 7d072a293e2f6539559d463d70d2fbd635ed1f14 (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
%% File `fapapersize.sty`
%%    this file is a part of oblivoir-packages.
%%
%% Copyright (c) 2006-2022 Kangsoo Kim <modviv2k15 at gmail.com>
%%
%% 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 (2007)
%%   사륙배판, 국판, 신국판 정의.
%%   marginnote 영역 설정은 제외되어 있음.
%% ver 0.1 (2020)
%%   option 1in added
%% ver 0.2 (2022)
%%   option a4 added
%%   \definefageometry, \selectfageometry added.
%%
\ProvidesPackage{fapapersize}[2022/03/01 v0.2]
%%%
%%% 옵션
%%% dbl4x6 : 사륙배판
%%% mum : 국판
%%% newmum : 신국판
%%% 1in : margin 1in
%%% a4 : a4paper + 1in
%%% stock : stocksize
\DeclareOption{dbl4x6}{%
  \AtEndOfPackage{\usefapapersize{190mm,260mm,30mm,*,30mm,*}}%
}
\DeclareOption{mum}{%
  \AtEndOfPackage{\usefapapersize{148mm,210mm,25mm,*,25mm,*}}%
}
\DeclareOption{newmum}{%
  \AtEndOfPackage{\usefapapersize{154mm,225mm,25mm,*,25mm,*}}%
}
\DeclareOption{1in}{%
  \AtEndOfPackage{\usefapapersize{*,*,1in,*,1in,*}}%
}
\DeclareOption{a4}{%
  \AtEndOfPackage{\usefapapersize{210mm,290mm,1in,*,1in,*}}%
}
\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
}

%%%% 
%%% fapapersize.sty, 2021-06-21
%%% \deffageometry, \setfageometry
%%%
\ExplSyntaxOn
	\NewDocumentCommand \definefageometry { m o m o }
	{
		\IfValueTF{#2}
		{
			\tl_gset:cn { g_famarginsetopt_#1_tl } { #2 }
		}
		{
			\tl_gset:cn { g_famarginsetopt_#1_tl } {}
		}
		\tl_gset:cn { g_famarginset_#1_tl } { #3 }
		\IfValueTF { #4 }
		{
			\tl_gset:cn { g_famarginsetoptpost_#1_tl } { #4 }
		}
		{
			\tl_gset:cn { g_famarginsetoptpost_#1_tl } {}
		}
	}
	
	\NewDocumentCommand \selectfageometry { s m }
	{
		\IfBooleanT { #1 } { \clearpage }
		\tl_use:c { g_famarginsetopt_#2_tl }
		\exp_args:Nx \usefapapersize{*,*, \use:c{ g_famarginset_#2_tl } }
		\tl_if_empty:cF { g_famarginsetoptpost_#2_tl }
		{
			\tl_use:c { g_famarginsetoptpost_#2_tl }
		}
		\ch@ngetext
	}

\NewDocumentCommand \evenmarginsameasodd {}
{
	\setlength\evensidemargin{\oddsidemargin}
}

\ExplSyntaxOff

\endinput