%% My Section Style
%%  written by Karnes.
%%  2004/07/26

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{mysectionstyle}[2004/07/26]

\newif\if@printcopy\@printcopyfalse
\DeclareOption{printcopy}{\@printcopytrue}
\ProcessOptions

%% Loads external Packages.
%%  eso-pic, hangul-k,
%%  hyperref, hsetspace, hlatex-interword, hitshape,
%%  graphicx, color, xcolor, moresize, calc, ifthen, geometry,
%%  chngpage, fancyhdr, crop.
%\RequirePackage{picinpar}
\RequirePackage{eso-pic}
%\RequirePackage{lineno}
\RequirePackage{hangul-k}
	\kscntformat{chapter}{}{}
	\ksnamedef{contentsname}{��~��}
	\ksnamedef{listoffigurename}{�׸� ����}
	\ksnamedef{listoftablename}{ǥ ����}
\RequirePackage[dvipdfm,bookmarks=false,colorlinks]{hyperref}
\if@printcopy
\hypersetup{%
 linkcolor=black,%
 anchorcolor=black,%
 citecolor=black,%
 filecolor=black,%
 menucolor=black,%
 pagecolor=black,%
 urlcolor=darkblue%
}
\else\fi

\RequirePackage[hangul]{hsetspace}
\RequirePackage[HWP]{hlatex-interword}
%\RequirePackage{hitshape}

%% fonts.
%\RequirePackage{yrttf,mathpazo}
\RequirePackage{unttf,mathpazo}
\RequirePackage{graphicx,color}
\RequirePackage[dvipsnames]{xcolor}
\RequirePackage{moresize}
\RequirePackage{calc,ifthen}
\RequirePackage{geometry}
%% Papersize and Layout setting.
\geometry{
	paperwidth=176mm,
	paperheight=250mm,
	inner=23mm,
	outer=30mm,
	top=30truemm,
	bottom=25mm,
	headsep=8mm,
	headheight=16pt,
}

%\RequirePackage{afterpage}
\RequirePackage{chngpage}

\RequirePackage{fancyhdr}
%% Pagestyle setting.
\fancyhead{} \fancyfoot{}
\fancyhead[LE,RO]{%
	\fancyplain%
	  {\textsf{\fbox{\large\itshape\thepage}}%
	  }%
	  {\textsf{\fbox{\large\itshape\thepage}}%
	  }%
}
\fancyhead[LO]{\sffamily\textcolor{Blue}{\leftmark}}
%\pagestyle{fancyplain}
\fancypagestyle{plain}{%
	\fancyhf{}%
%	\fancyfoot[C]{\textsf{\large\itshape\thepage}}%
	\renewcommand\headrulewidth{0pt}%
}
\pagestyle{fancy}

%% crop.
%\RequirePackage[frame,a4,center]{crop}

\providecommand{\makethinhangul}{\relax}
\providecommand{\cedp}{%
	\newpage{%
		\thispagestyle{empty}%
		\AddToShipoutPicture*{%
			\setlength\unitlength{1mm}%
			\put(20,25){%
			   \parbox[b]{\textwidth}{%
				\vfill
				\centering
				\includegraphics[width=.3\textwidth]{whitepage}
				\vfill
			}}}%
		\cleardoublepage
	}%
}

\newcommand\interhwordwider{%
    \interhword{.38em}{.2em}{.2em}%
}

%%
%% CHAPTER.
%%
%\makeatletter
\def\@makechapterhead#1{%
  {\parindent \z@ \raggedright
    \normalfont
    \interlinepenalty\@M
    \parbox[t]{24pt}{\centering\HUGE\bf\textcolor{MidnightBlue}{\thechapter}\\[-20pt] \textcolor{Cerulean}{\rule{24pt}{24pt}}}
    \hskip 15pt \raisebox{-62pt}{\rule{.6pt}{82pt}} \hskip 10pt
    \parbox[t]{100mm}{%
    \spacing{1.1}\raggedright \huge \bfseries\hfontseries{bc}\interhwordwider #1\endspacing}
%    \vskip 40\p@
    \vskip 80mm
  }}
\def\@makeschapterhead#1{%
  {\parindent \z@ \raggedright
    \normalfont
    \interlinepenalty\@M
    \parbox[t]{24pt}{\centering\textcolor{Cerulean}{\raisebox{-6pt}{\rule{24pt}{24pt}}}}
    \hskip 15pt \raisebox{-62pt}{\rule{.6pt}{80pt}}\hskip 10pt
    \parbox[t]{100mm}{%
    \spacing{1.1}\raggedright \huge \bfseries\hfontseries{bc}\interhwordwider\textcolor{NavyBlue}{#1}\endspacing}
%    \vskip 40\p@
    \vskip 80mm
  }}

%% PART.
%% \msmppart{parttitle}{partpagegraphic}
%%  parttitle : part title
%%  partpagegraphic : EPS graphic file.

\newcommand\mprt@grp{}%
\newcommand\mprtgrp[1]{%
	\@bsphack
	\renewcommand\mprt@grp{#1}%
	\@esphack
}

\newcommand\msmppart[2]{%
	\mprtgrp{#2}%
	\part{#1}%
	\thispagestyle{empty}%
	\cedp
}

\def\@part[#1]#2{%
	\AddToShipoutPicture*{%
		\setlength\unitlength{1mm}%
		\put(0,125){%
			\parbox[b]{\paperwidth}{%
				\vfill
				\centering
				\includegraphics[width=\paperwidth + 6pt,%
					height=130mm]{\mprt@grp}
				\vfill
			}}%
		}			
    \ifnum \c@secnumdepth >\m@ne
      \refstepcounter{part}%
      \addcontentsline{toc}{part}{\thepart\hspace{1em}#1}%
    \else
      \addcontentsline{toc}{part}{#1}%
    \fi
    {\parindent \z@ \raggedright
     \interlinepenalty \@M
     \normalfont
     \vspace*{.6\textheight}%
     \flushright
     \ifnum \c@secnumdepth >\m@ne
       \Huge\hfontfamily{sh}\bfseries %\partname\nobreakspace\thepart
       \flushright
%       \rotatebox{-33}{%
       	\resizebox{17pt}{35pt}{%
       		\textcolor{red}{\thepart}
       	}%
%       }%
       \par\nobreak
     \fi
     \vskip 24\p@
     \minipage{.95\textwidth}
     \flushright\hfontfamily{sh}\huge \bfseries 
     \textcolor{RoyalBlue}{#2}\endminipage%
     \markboth{}{}\par}%
    \nobreak
    \vskip 3ex
    \@afterheading}
\def\@spart#1{%
    {\parindent \z@ \raggedright
     \interlinepenalty \@M
     \normalfont
     \hfontfamily{sh}\huge \bfseries #1\par}%
     \nobreak
     \vskip 3ex
     \@afterheading}

%%%
%%% SECTION, SUBSECTION
%%%
\definecolor{Gryten}{gray}{.8}
\def\Gryten{\color{Gryten}}
\definecolor{Grynine}{gray}{.25}
\def\Grynine{\color{Grynine}}

%\def\sectionfont{\normalfont\fontsize{11.5}{11.5}\selectfont\bfseries\sffamily}% 
\def\sectionfont{\normalfont\Large\bfseries\hfontfamily{yt}}
\def\subsectionfont{\normalfont\large\bfseries\sffamily\Grynine}
%\renewcommand\thesubsection{\HArabic{subsection}}
\renewcommand\thesubsection{}
\renewcommand \thesection {\@arabic\c@section}

%% for toc.
\renewcommand*\l@section{\@dottedtocline{1}{2em}{2em}}
\renewcommand*\l@subsection{\@dottedtocline{2}{3em}{2em}}

\newlength\mylen\setlength\mylen{30mm}
\newlength\mymlen\setlength\mymlen{23mm}
\newlength\myrevlen\setlength\myrevlen{24mm}
\newlength\mymrevlen\setlength\mymrevlen{17mm}

\renewcommand\section{%
	\ifthenelse{\isodd{\value{page}}}
		{\@startsection {section}{1}{-\mymlen}}%
		{\@startsection {section}{1}{-\mylen}}%
                      {-12pt \@plus -2pt \@minus -.5pt}%
                      {5pt \@plus 1\p@ \@minus .4\p@}%
                      {\sectionfont}}
\def\@seccntformat#1{\csname the#1\endcsname}

\renewcommand\subsection{%
	\ifthenelse{\isodd{\value{page}}}
		{\@startsection {subsection}{2}{-\mymlen}}%
		{\@startsection {subsection}{2}{-\mylen}}%
                      {-12pt \@plus -2pt \@minus -.5pt}%
                      {5pt \@plus .1\p@ \@minus .4\p@}%
                      {\subsectionfont}}

\def\@sect#1#2#3#4#5#6[#7]#8{\ifnum #2>\c@secnumdepth
     \let\@svsec\@empty\else
     \refstepcounter{#1}%
     \let\@@protect\protect
     \def\protect{\noexpand\protect\noexpand}%
     \edef\@svsec{\@seccntformat{#1}}%
     \let\protect\@@protect\fi
     \@tempskipa #5\relax
      \ifdim \@tempskipa>\z@
        \begingroup #6\relax
          \noindent\hskip #3%
          \ifthenelse{\isodd{\value{page}}}
          	{%
          	\@hangfrom{\hbox to \mymrevlen{\hfill{\Gryten%
          \ifnum #2 = 1 \vrule height12pt depth4pt width\mymrevlen%
          \else%\ifnum #2 > 1
         \vrule height0pt depth0pt width\mymrevlen\fi
          }\llap{\@svsec\hskip2pt}}\hspace*{6mm}}%
          }%
          	{%
          	\@hangfrom{\hbox to \myrevlen{\hfill{\Gryten%
          \ifnum #2 = 1 \vrule height12pt depth4pt width\myrevlen%
          \else%\ifnum #2 > 1
         \vrule height0pt depth0pt width\myrevlen\fi
          }\llap{\@svsec\hskip2pt}}\hspace*{6mm}}%
          }%
                    {\interlinepenalty \@M \hangindent0pt#8\par}%
        \endgroup
       \csname #1mark\endcsname{#7}\addcontentsline
         {toc}{#1}{\ifnum #2>\c@secnumdepth \else
                      \protect\numberline{\csname the#1\endcsname}\fi
                    #7}\else
        \def\@svsechd{#6\hskip #3\relax  %% \relax added 2 May 90
                   \@svsec #8\csname #1mark\endcsname
                      {#7}\addcontentsline
                           {toc}{#1}{\ifnum #2>\c@secnumdepth \else
                           \protect\numberline{\csname the#1\endcsname}%
                                     \fi
                       #7}}\fi
     \@xsect{#5}}

\newcommand\msmpsection[1]{%
	\section{#1}%
}
%\makeatother


%%
%% bnm, cntrdot, sparen commands
%%
\newcommand\cnm[1]{%
	\leavevmode
%	\hspace{-.4em}��\nolinebreak #1\nolinebreak��\hspace{-.36em}% �Ѿ�۲��� ���.
	��\nolinebreak #1\nolinebreak��% ���۲��� ���.
}
\newcommand\snm[1]{%
	\leavevmode
%	\hspace{-.4em}��\nolinebreak #1\nolinebreak��\hspace{-.36em}%
	��\nolinebreak #1\nolinebreak��%
}
\newcommand\bnm[1]{%
	\leavevmode
%	\hspace{-.4em}��\nolinebreak #1\nolinebreak��\hspace{-.36em}%
	��\nolinebreak #1\nolinebreak��
}
\newcommand\cntrdot{%
	$\,\cdot\,$%
}
\newcommand\sparen[1]{%
	\,({\small #1})\,%
}

\let\msmpchapter\chapter
\let\msmpsection\section

%%
%% chapter and section marks.
%%
%\makeatletter
\renewcommand{\chaptermark}[1]{\markboth{{\small\ksTHE\,\HArabic{chapter}\,\@chapapp}\ #1}{}}
%\makeatother
\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}}

\raggedbottom

\endinput

%% end of `mysectionstyle.sty'