summaryrefslogtreecommitdiff
path: root/language/korean/kotex-oblivoir/memhangul-ucs/memucs-setspace.sty
blob: 8db9d17acfa281439d3e3f7948e669543baa9615 (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
%% File `memucs-setspace.sty`
%%
%% Copyright (c) 2007-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.
%%
%% =======================
%%
%% 이 스타일은 setspace 6.7을 바탕으로, memoir의
%% 출력루틴을 hooking하여 거의 동일하게 동작하도록
%% 수정한 스타일이다.
%% memoir 클래스에서 memhangul 스타일을 사용했을 때
%% 불린다. 다른 용도로는 사용할 수 없음.
%%
%% This style is a modified version of SETSTYLE ver 6.7 by Erica M. S. Harris
%% modified by Karnes Kim
%%
%% FEATURES:
%%    all the features of setstyle package
%%
%%	  NEW FEATURES:
%%
%%		1. [nofloatspacing] option
%%			disables the feature of SETSTYLE, turning off all the line spacing
%%			in the floats(figures, tables) and footnotes.
%%      \noadjustfloatfnspacing, \adjustfloatfnspacing
%%		2. [hangul] option
%%			When [hangul] option is on, the basic line spreading is set to
%%			a proper line spacing in Korean(Hangul) documents, which has
%%			a wider gap between the lines.
%%      \SetHangulspace
%%		3. quote and quotation environment
%%			quote and quotation environment have the same line spacing 
%%			with the floats and footnotes, verse.
%%      \noadjustquotespacing, \adjustquotespacing
%%		4. [adjustfootnotesep] option
%%			this option is meaningful only when [hangul] is on and 
%%			[nofloatspacing] off.
%%		5. [adjustverbatim] option.
%%			verbatim environment.
%%      \SetHangulVerbatimSpace.
%%    6. \ResetHangulspace, \RestoreHangulspace
%%

\NeedsTeXFormat {LaTeX2e}[1994/12/09]
\def \filename {memucs-setspace.sty}
\def \filedate {2007/09/21}
\def \fileversion {6.7-memucs8}
\ProvidesPackage {memucs-setspace}[\filedate\space\fileversion\space
  Contributed and Supported LaTeX2e package]
\typeout {Package: `memucs-setspace', a modified version of `setspace', \fileversion\space <\filedate>}

% BP: add nodisplayskipstretch option and \setdisplayskipstretch command.

\newcommand{\displayskipstretch}{\baselinestretch}
\newcommand{\setdisplayskipstretch}[1]{\renewcommand{\displayskipstretch}{#1}}
\DeclareOption{nodisplayskipstretch}{\setdisplayskipstretch{1.0}}

% GT: add George Pearsons' suggested options.

%% Karnes' 
\newif\if@singlespacefn
\DeclareOption{nofloatspacing}{\@singlespacefnfalse}
\newif\if@singlespacequote
\DeclareOption{quotespacing}{\@singlespacequotetrue}
\newif\if@hangul
\DeclareOption{hangul}{\@hangultrue\AtEndOfPackage{\hangulspacing}}
\newif\if@adjustfootnotesep
\DeclareOption{adjustfootnotesep}{\@adjustfootnoteseptrue}
\newif\if@adjustverbatim
\DeclareOption{adjustverbatim}{\@adjustverbatimtrue}

\DeclareOption{singlespacing}{\AtEndOfPackage{\singlespacing}}
\DeclareOption{onehalfspacing}{\AtEndOfPackage{\onehalfspacing}}
\DeclareOption{doublespacing}{\AtEndOfPackage{\doublespacing}}

\@singlespacefntrue
\@singlespacequotefalse
\@hangulfalse
\@adjustfootnotesepfalse
\@adjustverbatimfalse
\ProcessOptions

%%% provide memucsfninterwordhook
\ifx\undefined\memucsfninterwordhook
  \providecommand\memucsfninterwordhook{}%
\fi

\def\@floatfnspacinghook{%
	\if@singlespacefn
		\hangulfspacing
	\else
		\hangulspacing
	\fi
}

\newcommand\noadjustquotespacing{%
	\@singlespacequotefalse
}

\newcommand\adjustquotespacing{%
	\@singlespacequotetrue
}

\newcommand\adjustfloatfnspacing{%
	\@singlespacefntrue
}

\newcommand\noadjustfloatfnspacing{%
	\@singlespacefnfalse
}

% GT:  Sat 28 Sep 1996:  Widely using \newcommand, \renewcommand, and
% \newenvironment, instead of \def.

% ** Line space commands.

\newcommand{\setstretch}[1]{%
  \def\baselinestretch{#1}%
  \@currsize
}

% GT:  Sat 28 Sep 1996:  spacing commands and environments modified to
% use \setstretch instead of \baselinestretch.
%
% GT:  Sat 28 Sep 1996:  No, I don't know understand the line spacing
% algorithms!  If someone (LaTeX team) can enlighten me as to the
% general rule, please do!  It would be very pleasant if setspace.sty
% were suited for document font sizes other than 10, 11 and 12 pt.
%
% GT:  Tue 10 Dec 1996:  Instead of fixing singlespacing to exact unity,
% allow user to redefine it (only slightly, please!) from its initial
% value of unity, in the case when a particular font is slightly larger
% or slightly smaller than its point size would indicate.  This change
% affects setspace's single spacing commands, and LaTeX's footnote and
% float environments.  The one and a half, double, and arbitrary
% spacing commands are unaltered.

\newcommand{\SetSinglespace}[1]{%
  \def\setspace@singlespace{#1}%
}

%% Karnes.
\newcommand{\Set@Hangulspace}[2]{%
	\def\setspace@hangulspace{#1}%
	\def\setspace@hangulfspace{#2}%
	\setstretch{#1}%
}

\def\SetHangulspace#1#2{%
	\AtBeginDocument{%
		\gdef\setspace@hangulspace{#1}%
		\gdef\setspace@hangulfspace{#2}%
	}%
	\setstretch{#1}%
}

\newcommand{\SetHangulVerbatimSpace}[1]{%
	\def\setspace@hangulverbspace{#1}%
}

\let\tmp@current@hangulspace\setspace@hangulspace
\let\tmp@current@hangulfspace\setspace@hangulfspace

\newcommand{\ResetHangulspace}[2]{%
	\let\tmp@current@hangulspace\setspace@hangulspace%
	\let\tmp@current@hangulfspace\setspace@hangulfspace%
	\Set@Hangulspace{#1}{#2}%
}

\newcommand{\RestoreHangulspace}{%
	\Set@Hangulspace{\tmp@current@hangulspace}{\tmp@current@hangulfspace}%
}

% Here's the default single line spacing value.
\SetSinglespace{1}

%% Karnes.
\if@hangul
\Set@Hangulspace{1.333}{1.1}
\else
\Set@Hangulspace{1.0}{1.0}
\fi

\newcommand{\singlespacing}{%
  \setstretch {\setspace@singlespace}%  normally 1
  \vskip \baselineskip  % Correction for coming into singlespace
}

%% Karnes.
\newcommand{\hangulspacing}{%
	\setstretch{\setspace@hangulspace}% default
}

\newcommand{\hangulfspacing}{%
	\setstretch{\setspace@hangulfspace}%
}

\newcommand{\hangulverbspacing}{%
	\setstretch{\setspace@hangulverbspace}%
}

\newcommand{\onehalfspacing}{%
  \setstretch{1.25}%  default
  \ifcase \@ptsize \relax % 10pt
    \setstretch {1.25}%
  \or % 11pt
    \setstretch {1.213}%
  \or % 12pt
    \setstretch {1.241}%
  \fi
}

\newcommand{\doublespacing}{%
  \setstretch {1.667}%  default
  \ifcase \@ptsize \relax % 10pt
    \setstretch {1.667}%
  \or % 11pt
    \setstretch {1.618}%
  \or % 12pt
    \setstretch {1.655}%
  \fi
}

%% adjust verbatim
%% if and only if [nofloatspacing] and [adjustverbatim] is on,
%% the verbatim will be the same to the main text linestretch.
%% if [hangul] it will adjust the linestretch to the quote or quotation
%% the other case, it will be 1.0, I hope.
%%
\if@adjustverbatim
\SetHangulVerbatimSpace{\setspace@hangulfspace}%
\else
\SetHangulVerbatimSpace{1.0}
\fi

% ** Modification of the LaTeX command \@setsize.

%---Stretch the baseline BEFORE calculating the strut size. This improves
%   spacing below tabular environments etc., probably...
%   Comments are welcomed.

% GT:  Sun 29 Sep 1996:  Question:  Is this code anywhere near correct
% since this part of LaTeX (in, eg, latex.ltx) has been greatly changed?

% GT:  Sun 29 Sep 1996:  The meanings of the arguments to \@setsize
% appear to be (whatever these may signify) :
% current size; font baselineskip; ignored (!); and font size.

% GT:  Sun 29 Sep 1996:  Note that \@setsize (in latest LaTeX,
% \@setfontsize, which is called by \@setsize) seems to be the only
% place in purely modern LaTeX where \@currsize is set, and ltxguide.cls
% seems to be the only file in the LaTeX base distribution that uses it!

\def\@setsize#1#2#3#4{%
  % Modified 1993.04.07--GDG per KPC
  \@nomath#1%
  \let\@currsize#1%
  \baselineskip #2%
  \baselineskip \baselinestretch\baselineskip
  \parskip \baselinestretch\parskip
  \setbox\strutbox \hbox{%
    \vrule height.7\baselineskip
           depth.3\baselineskip
           width\z@}%
  \skip\footins \baselinestretch\skip\footins
  \normalbaselineskip\baselineskip#3#4}

% ** Float and footnote adjustments to compensate for a change in the
% ** main text's line spacing.

%---Increase the space between last line of text and footnote rule.
%\skip\footins 20pt plus4pt minus4pt

%---Reset baselinestretch within floats and footnotes.

% GT:  Tue 23 Jan 1996:  This is where the conflict with the combination
% of the color package and the figure environment used to occur.

% Floats.

% GT:  Sat 28 Sep 1996:  \@xfloat is the only place where \normalsize
% is still used in setspace.sty !

\if@singlespacefn
\let\latex@xfloat=\@xfloat
\def\@xfloat #1[#2]{%
  \latex@xfloat #1[#2]%
  \if@singlespacefn
  	\def\baselinestretch {\setspace@hangulfspace}
  \else
  	\def\baselinestretch {\setspace@hangulspace}
  \fi
  \normalsize
}
\else\fi

% Karnes: footnotesep for hangul
\if@adjustfootnotesep
\if@hangul
\if@singlespacefn
	\ifcase \@ptsize \relax
		\setlength\footnotesep{8.51 pt}% 10pt
	\or
		\setlength\footnotesep{9.6 pt}% 11pt
	\or
		\setlength\footnotesep{10.3 pt}% 12pt
	\fi
\else
\fi
\else\fi
\else\fi

% GT:  Wed 24 Jan 1996:  This footnote code was copied from LaTeX and
% modified rather naively.  It had to be brought up to date, not only
% because of LaTeX's new color ability, but also because ther had
% been major changes to this code in LaTeX at least as far back as
% March 1992.

% Normal, bottom of the page, footnotes.
%
% GT:  Based HEAVILY on original LaTeX (2e) code.  A standard hook would
% be MUCH preferred, so that LaTeX's footnote implementation needn't be
% copied each time it changes.
%
% GT:  The \protected@edef requires at least the December 1994 LaTeX.
% This is precisely the kind of VERSION DEPENDENCY situation that
% cannot (AFAIK) be avoided, because LaTeX (2e) LACKS appropriate
% standard hooks and/or context markers.
\if@singlespacefn
\def\m@mold@footnotetext{\@memsetspace@footnotetext}
\renewcommand{\@footnotetext}[1]{\m@mold@footnotetext{#1}\m@mmf@prepare} 
\long\def\@memsetspace@footnotetext#1{%
  \insert\footins{%
% GT:  Next line added.  Hook desired here!
	\@floatfnspacinghook\memucsfninterwordhook
%    \def\baselinestretch {\setspace@hangulfspace}%
%	\@SetFloatspaces
    \reset@font\footnotesize
    \interlinepenalty\interfootnotelinepenalty
    \splittopskip\footnotesep
    \splitmaxdepth \dp\strutbox \floatingpenalty \@MM
    \hsize\columnwidth
    \@parboxrestore
    \protected@edef\@currentlabel{%
      \csname p@footnote\endcsname\@thefnmark
    }%
    \color@begingroup
      \@makefntext{%
        \rule\z@\footnotesep\ignorespaces#1\@finalstrut\strutbox}%
    \color@endgroup}}

% Minipage footnotes.
\renewcommand{\@mpfootnotetext}[1]{%
  \global\setbox\@mpfootins\vbox{%
    \unvbox\@mpfootins
%  GT:  Next line added.  Hook desired here!
	\@floatfnspacinghook\memucsfninterwordhook
%    \def\baselinestretch {\setspace@hangulfspace}%
    \foottextfont \hsize\columnwidth \@parboxrestore
    \protected@edef\@currentlabel{\csname p@mpfootnote\endcsname\@thefnmark}%
  \color@begingroup
    \@makefntext{%
      \rule\z@\footnotesep\ignorespaces#1\@finalstrut\strutbox}%
  \color@endgroup}}

\else\fi

% ** Line space environments.

% A single spaced quote (say) is done by surrounding singlespace with quote.

\newenvironment{singlespace}{%
  \vskip \baselineskip
  \setstretch {\setspace@singlespace}%
  \vskip -\baselineskip
}{%
  \par
}

% GT (c/o Mark Olesen), Wed 15 April 1998.

\newenvironment{singlespace*}{%
  \setstretch {\setspace@singlespace}%
  \vskip -\baselineskip
}{%
  \vskip -0.5\baselineskip
}

%  spacing, doublespace and onehalfspace all are meant to INCREASE the
%  spacing (i.e. calling onehalfspace from within doublespace will not
%  produce a graceful transition between spacings)
%
% Next two definitions fixed for consistency with TeX 3.x

% In order to use \newenvironment, while easily using same code for
% end of each environment, the code that used to be in \endspacing has
% been moved into a new (but internal) macro, \restore@spacing.

\newcommand{\restore@spacing}{%
    \par
    \vskip \parskip
    \vskip \baselineskip
  \endgroup
  \vskip -\parskip
  \vskip -\baselineskip
}

\newenvironment{spacing}[1]{%
  \par
  \begingroup             % moved from \endspacing by PGBR 29-1-91
    \setstretch {#1}%
}{%
  \restore@spacing
}

% one and a half spacing is 1.5 x pt size
\newenvironment{onehalfspace}{%
  \begingroup
    \onehalfspacing
}{%
  \restore@spacing
}

% double spacing is 2 x pt size
\newenvironment{doublespace}{%
  \begingroup
    \doublespacing
}{%
  \restore@spacing
}

%% quote and quotation environment : Karnes.
\def\@quotespacinghook{%
	\if@singlespacequote
		\hangulfspacing%
	\else
		\hangulspacing%
	\fi
}

\renewenvironment{quotation}%
               {\list{}{\listparindent 1.5em%
                        \itemindent    \listparindent
                        \rightmargin   \leftmargin
                        \parsep        \z@ \@plus\p@}%
%								\memhangulinterwordhook
                \item[]%
                \@quotespacinghook
               }%
               {\endlist
                \if@singlespacequote\vskip-.2\onelineskip\fi}
\renewenvironment{quote}%
               {\list{}{\rightmargin\leftmargin}%
%                \memhangulinterwordhook
                \item[]
                \@quotespacinghook
               }%
               {\endlist
                \if@singlespacequote\vskip-.2\onelineskip\fi}
\renewenvironment{symbols}{\list{}%
    {\itemindent 0em \leftmargin 8em
     \labelsep 1em \labelwidth 5em
%     \memhangulinterwordhook
     \let\makelabel\symbollabel}%
     \@quotespacinghook
    }%
    {\endlist} 

%%%%%%%%%%%%%%%%%%%%
%%%% fix vertical spacing in the verse environment. mempatch 3.3
\renewenvironment{verse}[1][\linewidth]{%
  \refstepcounter{verse}%
  \setcounter{poemline}{0}\refstepcounter{poemline}%
  \setcounter{vslineno}{1}%
  \let\\=\@vscentercr
  \list{}{\itemsep      \z@
          \itemindent   -\vindent
          \listparindent\itemindent
          \parsep       \stanzaskip
          \ifdim #1<\linewidth %% short line
            \rightmargin        \z@
            \leftmargin         \linewidth
            \advance\leftmargin -#1\relax
            \advance\leftmargin -0.5\leftmargin
            \advance\leftmargin \vindent
          \else
            \ifdim #1>\linewidth %% long line
              \rightmargin \z@
              \leftmargin  \vindent
             \else               %% default
               \rightmargin        \leftmargin
               \advance\leftmargin \vindent
             \fi
          \fi}
  \item[]%
  \@quotespacinghook}{\endlist} 
%%%%%%%%%%%%%%

\renewenvironment{altverse}%
  {\starpatternfalse\patternfalse\altindenttrue\setcounter{vslineno}{1}%
   \@quotespacinghook
  }%
  {\altindentfalse} 

\def\@verbatim{\the\every@verbatim
	\trivlist
  \if@adjustverbatim\hangulverbspacing\else\fi%
  \item \relax
  \if@minipage\else\vskip\parskip\fi
  \@beginparpenalty \predisplaypenalty
  \leftskip\@totalleftmargin\rightskip\z@
  \parindent\z@\parfillskip\@flushglue\parskip\z@
  \@@par
  \def\par{%
    \if@tempswa
      \leavevmode\null\@@par\penalty\interlinepenalty
    \else
      \@tempswatrue
      \ifhmode\@@par\penalty\interlinepenalty\fi
    \fi}%
  \def\@noitemerr{\@warning{No verbatim text}}%
  \obeylines
  \let\do\@makeother \dospecials
  \verbatim@font
  \everypar \expandafter{\the\everypar \unpenalty}%
  \wrapright\the\afterevery@verbatim}

%% Karnes : epigraph
\newcommand\epigraphspacinghook{\setstretch{1.0}}
\newcommand\epigraphspacing[1]{%
	\renewcommand\epigraphspacinghook{\setstretch{#1}}%
}

\renewcommand{\epigraph}[2]{\vspace{\beforeepigraphskip}
  {\epigraphsize\begin{\epigraphflush}%
    \epigraphspacinghook
    \begin{minipage}{\epigraphwidth}
    \@epitext{#1}\\ \@episource{#2}
    \end{minipage}\end{\epigraphflush}
    \vspace{\afterepigraphskip}}} 

\renewenvironment{epigraphs}{%
  \vspace{\beforeepigraphskip}\begin{\epigraphflush}
  \epigraphsize
  \begin{minipage}{\epigraphwidth}
   \epigraphspacinghook
   \list{}%
    {\itemindent\z@ \labelwidth\z@ \labelsep\z@
     \leftmargin\z@ \rightmargin\z@
     \let\makelabel\qitemlabel}}%
  {\endlist\end{minipage}\end{\epigraphflush}
   \vspace{\afterepigraphskip}} 
 
% GT:  EMSH chose to omit display math part that follows.
% She wrote (see above) that the "altered spacing before and after displayed
% equations ... just looked too much".
%
% Fix up spacing before and after displayed math
% (arraystretch seems to do a fine job for inside LaTeX displayed math,
% since array and eqnarray seem to be affected as expected).
% Changing \baselinestretch and doing a font change also works if done here,
% but then you have to change @setsize to remove the call to @nomath)
%
% GT:  The \belowdisplayskip line was mistyped; now fixed, courtesy of
% David Hull.
%
% GT:  Brett Parnell has addressed EMSH's concern by replacing
% \baselinestretch by \displayskipstretch in displays, as follows.

\everydisplay\expandafter{%
  \the\everydisplay
  \abovedisplayskip \displayskipstretch\abovedisplayskip
  \belowdisplayskip \displayskipstretch\belowdisplayskip
  \abovedisplayshortskip \displayskipstretch\abovedisplayshortskip
  \belowdisplayshortskip \displayskipstretch\belowdisplayshortskip
}

\endinput

%%% EOF.