%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%55
% nucoverwithwindow.sty 
%  This provides somecommands to make a title page for a cover with window.
% Usage:
%  \setWindowTopPosition[1in]{top position (include 1in)}
%  \setWindowRightPosition[1in]{left position (include 1in)}
%  \setWindowWidth{width}
%  \setWindowHeight{height}
% % and then
%  \begin{blockoverwindow}[t/c/b]...\end{blockoverwindow}
%  \begin{blockofwindow}[c/t/b]...\end{blockofwindow}
% % or
% %  \begin{centerblockoverwindow}[t/c/b]...\end{centerblockoverwindow}
% %  \begin{blockofwindow}[c/t/b]...\end{blockofwindow}
% %  \begin{centerblockbellowwindow}[t/c/b]...\end{centerblockbellowwindow}
%
% Author: NUmata, yacehide (nu+y at math.shinshu-u.ac.jp)
% Version: 2014/04/08.
% Lisence: GPL.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newlength{\hskip@blockoverwindow@nu}
\newlength{\width@blockoverwindow@nu}
\newlength{\vskip@blockoverwindow@nu}
\newlength{\height@blockoverwindow@nu}
\newlength{\hskip@window@nu}
\newlength{\vskip@window@nu}
\newlength{\width@window@nu}
\newlength{\height@window@nu}
\newlength{\height@blockbellowwindow@nu}

\newcommand{\adjustheightbellowwindow@nu}{%
\setlength{\height@blockbellowwindow@nu}{\textheight}
\addtolength{\height@blockbellowwindow@nu}{-\topskip}
\addtolength{\height@blockbellowwindow@nu}{-\vskip@blockoverwindow@nu}
\addtolength{\height@blockbellowwindow@nu}{-\baselineskip}
\addtolength{\height@blockbellowwindow@nu}{-\vskip@window@nu}
\addtolength{\height@blockbellowwindow@nu}{-\baselineskip}%
}
\newcommand{\adjustcenterposition@nu}{%
\setlength{\width@blockoverwindow@nu}{\textwidth}
\setlength{\hskip@blockoverwindow@nu}{\hskip@window@nu}
\addtolength{\hskip@blockoverwindow@nu}{\hskip@window@nu}
\addtolength{\hskip@blockoverwindow@nu}{\width@window@nu}
\addtolength{\hskip@blockoverwindow@nu}{-\textwidth}
\ifdim\hskip@blockoverwindow@nu>0pt%
\addtolength{\width@blockoverwindow@nu}{-\hskip@blockoverwindow@nu}%
\else%
\addtolength{\width@blockoverwindow@nu}{\hskip@blockoverwindow@nu}
\setlength{\hskip@blockoverwindow@nu}{\z@}%
\fi%
}

\newcommand{\setWindowTopPosition}[2][1in]{%
\setlength{\height@blockoverwindow@nu}{#2}
\addtolength{\height@blockoverwindow@nu}{-#1}
\addtolength{\height@blockoverwindow@nu}{-\topmargin}
\addtolength{\height@blockoverwindow@nu}{-\headheight}
\addtolength{\height@blockoverwindow@nu}{-\headsep}
\addtolength{\height@blockoverwindow@nu}{-\topskip}
\setlength{\vskip@blockoverwindow@nu}{\height@blockoverwindow@nu}%
\addtolength{\vskip@blockoverwindow@nu}{-\baselineskip}
\adjustheightbellowwindow@nu%
}
\newcommand{\setWindowRightPosition}[2][1in]{%
\setlength{\hskip@window@nu}{#2}
\addtolength{\hskip@window@nu}{-#1}
\addtolength{\hskip@window@nu}{-\oddsidemargin}%
\adjustcenterposition@nu%
}
\newcommand{\setWindowHeight}[1]{%
\setlength{\height@window@nu}{#1}
\setlength{\vskip@window@nu}{#1}%
%\addtolength{\vskip@window@nu}{-\baselineskip}
\adjustheightbellowwindow@nu%
}
\newcommand{\setWindowWidth}[1]{%
\setlength{\width@window@nu}{#1}%
\adjustcenterposition@nu%
}


%usage:
%\begin{blockbox@nu}[c|b|t]{width}{height}{leftskip} ... \end{blockbox@nu}
%\vskip heightskip
\newenvironment{blockbox@nu}[4][c]{\noindent\hskip#4\begin{minipage}[b][0cm][t]{#2}\begin{minipage}[#1][#3]{#2}}{\end{minipage}\end{minipage}}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% front end of the mactos:
\newenvironment{centerblockoverwindow}[1][t]{\begin{blockbox@nu}[#1]{\width@blockoverwindow@nu}{\height@blockoverwindow@nu}{\hskip@blockoverwindow@nu}}{\end{blockbox@nu}\vskip-\baselineskip}
\newenvironment{blockoverwindow}[1][t]{\begin{blockbox@nu}[#1]{\textwidth}{\height@blockoverwindow@nu}{0cm}}{\end{blockbox@nu}\vskip-\baselineskip}
\newenvironment{blockofwindow}[1][c]{\makebox{}\vskip\vskip@blockoverwindow@nu\begin{blockbox@nu}[#1]{\width@window@nu}{\height@window@nu}{\hskip@window@nu}}{\end{blockbox@nu}\vskip\vskip@window@nu}
\newenvironment{centerblockbellowwindow}[1][t]{\begin{blockbox@nu}[#1]{\width@blockoverwindow@nu}{\height@blockbellowwindow@nu}{\hskip@blockoverwindow@nu}}{\end{blockbox@nu}\vskip\height@blockbellowwindow@nu}

% front end of the mactos:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%
%default setting
\setWindowTopPosition{6.1cm}
\setWindowRightPosition{6.1cm}
\setWindowWidth{9.8cm}
\setWindowHeight{5cm}
%default setting
%%%%%%%%%%%%%%%%


