%!TEX program = arara
% arara: xelatex: {synctex: yes}
% arara: xelatex: {synctex: yes}
% arara: makeindex: {style: istgame} 
% arara: xelatex: {synctex: yes}
% arara: xelatex: {synctex: yes}

% 2017/09/04  v1.0
\def\tmpdate{2017/09/04}
\def\tmpversion{1.0}

\documentclass[a4paper]{oblivoir}

\usepackage{fapapersize}
\usefapapersize{*,*,30mm,*,28mm,28mm}
\setsecnumdepth{subsubsection}
\settocdepth{subsubsection}
\setlength\cftsubsubsectionindent{4.5em}

\renewcommand\contentsname{Table of Contents}
\renewcommand\figurename{Figure}
\renewcommand\tablename{Table}
\renewcommand\abstractname{Abstract}
\renewcommand\indexname{Index}
\renewcommand\pagerefname{\kern-4pt}

\usepackage{tabu}
\usepackage{mathtools}
%\usepackage{xparse}  %% oblivoir will load xparse
%\usepackage{tikz}    %% istgame will load tikz
\usepackage{makecell}
\usepackage{capt-of}
\usepackage{multido}
\usepackage{ulem}
\usepackage{idxlayout}

\usepackage{istgame}

\usepackage{tcolorbox}
\tcbuselibrary{listings,breakable}
    \tcbset{breakable,listing above text,center upper,sidebyside gap=10pt,lower separated=true,center lower,
    listing options={
    	style=tcblatex,
      keywordstyle=\color{blue},
      commentstyle=\color{black!20!green},
      morekeywords={istgame,istroot,istrooto,istb,endist,xtdistance,
        istcntm,istcntmarc,setistgrowdirection,istgrowdirection,
        xtInfoset,xtInfosetO,xtActionLabel,
        xtSubgame,xtSubgameBox,xtSubgameOval,istgamefontsize,setistgamefontsize,
        xtgrow,setistgrowkey,xtInfosetOwner,xtOwner,xtPayoff,xtNode,
        xtShowEndPoints,xtHideEndPoints,
        xtShowTerminalNodes,xtHideTerminalNodes,
        xtlevdist,xtsibdist,
        setistDecisionNodeStyle,setistOvalNodeStyle,
        setistSolidNodeStyle,setistHollowNodeStyle,
        setistEllipseNodeStyle,setistNullNodeStyle,setistRectangleNodeStyle,
        cntmdistance,cntmlevdist,cntmsibdist,
        xtALpush,xtALshift,
        xtdefaultsubrootshiftoval,
        \tikzstyle,\draw,\node,\coordinate,\foreach,
        NewDocumentCommand,NewDocumentEnvironment,IfBooleanTF
        }
      }
    }

%\usepackage{tikz-qtree} %%% DO NOT USE

%%% to resolve the conflict with tikz-qtree
%\RenewDocumentEnvironment{istgame}{O{}}   % accepts tikzpicture options
%    {\begin{tikzpicture}[%
%        edge from parent path={(\tikzparentnode\istparentanchor) -- 
%        (\tikzchildnode\istchildanchor)}, % tikz-qtree conflict resolved
%        font=\istgamefontsize,>=stealth,#1
%        ]
%    }
%    {\end{tikzpicture}
%    }


\linespread{1}

\newcommand*\Tikz{Ti\textit{k}Z}
\let\tikz\Tikz

\newenvironment{keywords}{%
	\par\vskip2pt
	\noindent\hangfrom{\textsc{Keywords: }}%
}

\NewDocumentEnvironment{mytcblisting}{O{}}
{ \medskip
  \begin{tcblisting}{#1} 
}
{ \end{tcblisting} 
  \medskip
}

\NewExpandableDocumentCommand\xcol{mO{c|}m}
  {\multicolumn{#1}{#2}{\ensuremath{#3}}}

%% more lazy macros
\newcommand\mbigskip[1]{\multido{}{#1}\bigskip}
\def\hpara{\hangpara{1.52em}{1}}

\newcommand\remark{\noindent \textbf{Remark: }}

%% index
\renewcommand\cmd[1]{\cmdprint{#1}}
\newcommand\xword[1]{\cmd{#1}}
\newcommand\xw[1]{\cmd{#1}}
\newcommand\pkg[1]{\textsf{#1}}
\newcommand\env[1]{\textsf{#1}}
\newcommand\ixw[1]{\cmd{#1}\index{#1}}
\newcommand\isw[1]{#1\index{#1}}
\newcommand\ipkg[1]{\textsf{#1}\index{#1@\textsf{#1}}}
\newcommand\ienv[1]{\textsf{#1}\index{#1@\textsf{#1}}}

\makeatletter
\newcommand{\icmd}[1]{\cmdprint{#1}%
  \index{\expandafter\@gobble\string#1@\string\cmdprint{\string#1}}}
\makeatother

\makeindex

\title{\texttt{istgame.sty} \\
Drawing Game Trees with \tikz}
\author{In-Sung Cho \\  \texttt{ischo <at> ktug.org}}
\date{Economics, Kongju National University\\[3pt] \tmpdate\quad version \tmpversion}

%%=======================================================================
\begin{document}

\frontmatter
\maketitle

\begin{abstract}
This is a \LaTeX{} package that provides macros based on \Tikz\ to draw a game tree. The main idea underlying the core macros here is the completion of a whole tree by using a sequence of simple `parent-child' tree structures, with no longer nested relations involved like the use of grandchildren or great-grandchildren.
With the \ipkg{istgame} package, you can draw a game tree as if you were drawing a game tree with a pen and paper. 

\begin{keywords}
game trees, nodes, branches, information sets, subgames
\end{keywords}
\end{abstract}

\tableofcontents*

\mainmatter

%\input{istgame_test}
\include{istgame-doc-v1.0}

\printindex

\end{document}
