\documentclass[12pt,twoside,openany,twocolumn]{book}
\usepackage{latexsym,fancyhdr,tabularx,equation,multicol,ifthen}
\usepackage{psfrag,color,graphicx,booktabs,colortbl}
\usepackage{answers,makeidx,url}
% \usepackage[mtbold]{mathpmn}
\usepackage[cam]{crop}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[nooneline,sf]{caption2}
\usepackage[small,sf]{titlesec}
\usepackage{titletoc}

\renewcommand{\captionfont}{\sz12\sffamily}
\renewcommand{\captionlabelfont}{\sz12\sffamily}

\usepackage{makeidx}
\makeindex

\usepackage{geometry}
\geometry{paperheight=23cm,paperwidth=16.5cm,textwidth=11cm,
    textheight=18.5cm,left=2cm,twosideshift=-.25cm,
    top=.3cm,footskip=1.75cm,marginparwidth=2cm,twoside}
%    textheight=18.5cm,nohead,left=2cm,twosideshift=-.25cm,
%    top=1.75cm,footskip=1.75cm,marginparwidth=2cm,twoside}

\addtolength{\headheight}{3pt}
% footnotesep=  new geometry option

\newcommand{\chfont}{\fontfamily{ppc}\fontseries{m}%
   \fontsize{30}{20pt}\selectfont}

\titleformat{\chapter}[hang]{\vspace*{-2cm}\hspace*{.2\textwidth}%
  \chfont}
  {\parbox{.12\textwidth}{\hfill%
   \textcolor{dark}{\thechapter}}}%
  {.09\textwidth}{\EMtitle}

\newcommand{\EMtitle}[1]{\parbox{.6\textwidth}{#1}}

\newcommand{\abs}{\fboxsep=0pt
  \colorbox{half}{\raisebox{1pt}{\rule{4.5pt}{0pt}\rule{0pt}{3.5pt}}}}

\newcommand{\triang}{\fboxsep=0pt
   \textcolor{half}{$\blacktriangleright$}}

\newcommand{\firstpage}[2]{\sz12
   \vspace*{-2mm}\hspace*{.4\textwidth}
   \leftmargini=.5cm
   \begin{minipage}{.6\textwidth}
    \begin{itemize}\itemsep=-3pt
     #1
    \end{itemize}
   \vspace{1cm}
   \parbox{\textwidth}{%
   \raggedright
   #2}
   \end{minipage}}

% TOC format for maintext
%
\newcommand{\mytitle}[1]{#1}
\contentsmargin{8mm}
\titlecontents{chapter}
   [5mm] %[10mm]
   {\vspace*{2mm}}
   {\llap{\textbf{\thecontentslabel}\rule{3mm}{0pt}}\mytitle}
   {}
   {~\titlerule*[2mm]{$\cdot$}\contentspage}
\titlecontents{section}
   [14mm] %[19mm]
   {\vspace*{1mm}}
   {\contentslabel{8mm}}
   {}
   {~\contentspage}
\titlecontents*{subsection}
   [14mm]  %[19mm]
   {\fontsize{10.95}{15pt}\selectfont\vspace*{.4mm}}{}{}
   {, \thecontentspage}[ ~~\triang{}~ ]


%%% answers
\renewcommand{\solutionstyle}[1]{#1.}


% % the environment for typesetting exercises and answers
% \Newassociation{so}{Solution}{anso}
% \Newassociation{se}{Solution}{anse}
% \renewcommand{\solutionstyle}[1]{#1.}
%
% \newenvironment{ex}
% {\setcounter{secnumdepth}{0}
%   %%% to handle the problem of so and se environment.
%  \renewcommand{\thesection}{}
%  \renewcommand{\theparagraph}{}
%  \Opensolutionfile{anso}[so\thechapter]
%  \Opensolutionfile{anse}[se\thechapter]}
% {\Closesolutionfile{anso}
%  \Closesolutionfile{anse}}
% %  \setcounter{secnumdepth}{2}}




\newcommand{\chkodd}{\clearpage\ifodd\count0 \else%
   \thispagestyle{empty} \mbox{}\clearpage \fi}
\newcommand{\chkeven}{\clearpage\ifodd\count0 \thispagestyle{empty}%
   \mbox{}\clearpage \else \fi}

% Next, we use fancyhdr.sty to setup header and footer
% Note that fancyhdr commands must be after \textwidth commands
%
\pagestyle{fancy} \fancyhf{}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]%
%    {\markright{\S~\thesection~ #1}}
     {\markright{\thesection~ #1}}
\fancyfoot[LE]{$\cdot$~\thepage~$\cdot$\rule{5mm}{0pt}\leftmark}
\fancyfoot[RO]{\rightmark\rule{5mm}{0pt}$\cdot$~\thepage~$\cdot$}
\renewcommand{\headrulewidth}{0pt}

\definecolor{heavy}{gray}{.3}
\definecolor{hheavy}{gray}{.2}
\definecolor{hlight}{gray}{.85}
\definecolor{light}{gray}{.7}
\definecolor{half}{gray}{.5}
\definecolor{dark}{gray}{.3}
\definecolor{white}{gray}{1}
\definecolor{gold}{named}{Goldenrod}
\definecolor{brown}{named}{Brown}
\renewcommand{\chaptername}{\chfont }
\def\dd{\kern 2pt\raise 3pt\hbox{\large .}\kern 2pt\ignorespaces}

\columnsep=20pt  %%% for wrapfig.sty

\newcommand{\bpara}[4]{ % #1 x; #2 y; #3 angle; #4 height
\begin{picture}(0,0)%
  \setlength{\unitlength}{1pt}%
  \put(#1,#2){\rotatebox{#3}{\raisebox{0mm}[0mm][0mm]{%
    \makebox[0mm]{$\left.\rule{0mm}{#4pt}\right\{$}}}}%
  \end{picture}}


%% the following value from epsLaTeX manual
\renewcommand{\textfraction}{0.15}
\renewcommand{\topfraction}{0.85}
\renewcommand{\bottomfraction}{0.65}
\renewcommand{\floatpagefraction}{0.60}
\abovecaptionskip=0pt
\belowcaptionskip=8pt


% \leftmargini=.6cm
\renewcommand{\theequation}{\arabic{equation}}
\fboxsep=15pt

\newcount\fs
\def\sz#1#2{\fs=#1#2
 \ifnum\fs=10\fontsize{10}{13.5pt plus.2pt minus .1pt}\selectfont
 \else\ifnum\fs=11\fontsize{10.95}{14.5pt plus.3pt minus.2pt}\selectfont
%  \else\ifnum\fs=12\fontsize{12}{18pt plus.3pt minus .2pt}\selectfont
%  \else\ifnum\fs=12\fontsize{11.5}{18pt plus.3pt minus .2pt}\selectfont
\else\ifnum\fs=12\fontsize{11.3}{18pt plus.3pt minus .2pt}\selectfont
 \else\ifnum\fs=14\fontsize{14.4}{20pt plus.4pt minus .3pt}\selectfont
 \else\ifnum\fs=17\fontsize{17.28}{22pt plus.5pt minus .3pt}\selectfont
 \else\ifnum\fs=20\fontsize{20.73}{28pt plus.6pt minus .4pt}\selectfont
 \else\ifnum\fs=25\fontsize{24.88}{33pt plus.7pt minus .4pt}\selectfont
 \else\ifnum\fs=09\fontsize{9}{11pt plus.3pt minus .3pt}\selectfont
 \else\ifnum\fs=08\fontsize{8}{9.5pt plus.3pt minus .2pt}\selectfont
 \else\ifnum\fs=07\fontsize{7}{9pt plus.3pt minus .2pt}\selectfont
 \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}

\setlength{\marginparwidth}{2.75cm} \setlength{\marginparsep}{5mm}
\def\key#1{\marginpar{\parbox[t]{2.95cm}{\rightskip .2cm plus.2cm minus.2cm #1}}}

% \renewcommand{\thechapter}{\arabic{chapter}}
% \renewcommand{\thesection}{\sf \thechapter.\arabic{section}}
% \renewcommand{\thesubsection}{\sf \thesection.\arabic{subsection}}
% \renewcommand{\headrulewidth}{0pt}

%
% The next 2 lines define the symbol in front of the Summary
%
\font\secsym=pmnr8r scaled 2074
%%% \def\nsec{\rule{0.3cm}{0pt}\secsym\char167\hspace*{.28cm}}
\def\nsec{\rule{0.3cm}{0pt}\hspace*{.28cm}}
%
% The next 2 lines are for the solutions.
\Newassociation{sol}{Solution}{ans}
% \Opensolutionfile{ans}[em-ans]

\def\tb#1#2{\mathop{#1\vphantom{\sum}}\limits_{\displaystyle #2}}

\def\ph#1{\phantom{#1}\ignorespaces}
\def\ni{\noindent}
\def\ms{\medskip}
\newcommand{\cw}{{\tt cw}\TeX\ }
\newcommand{\eskip}{\fontsize{12}{13.6pt plus .3pt minus .2pt}\selectfont}
%
% Move a long figure to the left in even page by .25\textwidth.
%
\newcommand{\chkpage}[1]{\label{#1}
\ifthenelse{\isodd{\pageref{#1}}}{\noindent\ignorespaces}%
    {\noindent\hspace*{-.25\textwidth}\ignorespaces}}

% \newcommand{\chkpage}{
%    \ifthenelse{\isodd{\value{page}}}{\noindent\ignorespaces}%
%     {\noindent\hspace*{-.25\textwidth}\ignorespaces}}

\newcommand{\chksum}[1]{\fboxsep=0pt \label{#1}
\noindent\ifthenelse{\isodd{\pageref{#1}}}%
 {\colorbox{gold}{\mbox{\rule{0pt}{3pt}\rule{1.25\textwidth}{0pt}}}%
  \par\fboxsep=15pt}
 {\hspace*{-.25\textwidth}%
  \colorbox{gold}{\mbox{\rule{0pt}{3pt}\rule{1.25\textwidth}{0pt}}}}%
  \par\fboxsep=15pt}

% \newcommand{\tabcaption}{%
%  \abovecaptionskip=0pt
%  \belowcaptionskip=10pt
%  \caption}

\newcommand{\fignote}[1]{
 \par\vspace*{-2mm}\parbox{\textwidth}{
  #1}}

\newcommand{\tabnote}[1]{
 \par\parbox{\textwidth}{
  #1}}

\newcommand{\mfig}[1]{
 \begin{figure}[t!]
 \centering
 \fboxsep=.05\textwidth
 \colorbox{hlight}{
 \begin{minipage}{.9\textwidth}
   #1
 \end{minipage}}
 \end{figure}}

\newcommand{\bfig}[2]{
\begin{figure}
 \centering
 \label{#1}
 \ifthenelse{\isodd{\pageref{#1}}}{\noindent\ignorespaces}%
  {\noindent\hspace*{-.2\textwidth}\ignorespaces}
  \fboxsep=.05\textwidth
  \colorbox{hlight}{\ignorespaces
  \begin{minipage}{1.1\textwidth}
  \centering
    #2
  \end{minipage}}
\end{figure}}

\newcommand{\sfig}[2]{
 \begin{figure}[t]
 \centering
 \fboxsep=.05\textwidth
 \colorbox{hlight}{
 \begin{minipage}[b]{.55\textwidth}
   #1
 \end{minipage}\hspace{.06\textwidth}
   \begin{minipage}[b]{.28\textwidth}  \raggedright
    #2
  \par\vspace*{3mm}
  \end{minipage}}
  \end{figure}}

% For figures in answers
%

\newcommand{\amfig}[1]{
 \begin{figure}[h!]
 \centering
 \fboxsep=.03\textwidth
 \colorbox{hlight}{
 \begin{minipage}{.41\textwidth}
   #1
 \end{minipage}}
 \end{figure}}

\newcommand{\abfig}[1]{
 \begin{figure*}
 \centering
 \fboxsep=.05\textwidth
 \colorbox{hlight}{
 \begin{minipage}{.9\textwidth}
   #1
 \end{minipage}}
 \end{figure*}}

\newcommand{\mtable}[1]{
\begin{table}
 \centering
  \fboxsep=.05\textwidth
  \colorbox{hlight}{\ignorespaces
  \begin{minipage}{.9\textwidth}
  \centering
    #1
  \end{minipage}}
\end{table}}

\newcommand{\btable}[2]{
\begin{table}
 \centering
 \label{#1}
 \ifthenelse{\isodd{\pageref{#1}}}{\noindent\ignorespaces}%
  {\noindent\hspace*{-.2\textwidth}\ignorespaces}
  \fboxsep=.05\textwidth
  \colorbox{hlight}{\ignorespaces
  \begin{minipage}{1.1\textwidth}
  \centering
    #2
  \end{minipage}}
\end{table}}

\newenvironment{num}
 {\leftmargini=6mm\leftmarginii=8mm
  \begin{enumerate}\itemsep=-2pt}
 {\end{enumerate}}

% for index
%

\newcommand\xitem{\par\noindent\hangindent=8mm}
\newcommand\xsubitem{\par\noindent\hspace*{4mm}\hangindent=8mm}
\newcommand\cindex[1]{\par\bigskip\noindent
  \hspace*{2mm}{\large #1}\par\medskip}
