%%
%% This is file `seealso.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% seealso.dtx  (with options: `package')
%% 
%% This is a generated file.
%% 
%% Copyright (C) 2014, 2017 by Leo Liu <leoliu.pku@gmail.com>
%% --------------------------------------------------------------------------
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% 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.3 or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.
%% 
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{seealso}
    [2017/03/23 v1.2 makeidx's see and seealso with page number support.]
\RequirePackage{etoolbox}
\long\def\seealso@ifinlist@#1#2#3#4{%
  \def\next{#4}%
  \def\do##1{%
    \ifstrequal{##1}{#2}
      {\def\next{#3}\listbreak}
      {}}%
  \dolistloop{#1}%
  \next}
\protected\long\def\seealso@ifinlist#1#2{%
  \seealso@ifinlist@{#2}{#1}}
\protected\long\def\seealso@ifinlistcs#1#2{%
  \expandafter\seealso@ifinlist@\csname #2\endcsname{#1}}
\RequirePackage{kvoptions}
\SetupKeyvalOptions{
  family=seealso@opt,
  prefix=seealso@,
  setkeys=\kvsetkeys}
\DeclareBoolOption[true]{override}
\DeclareBoolOption[true]{activecr}
\ProcessKeyvalOptions*
\def\seealso@charlet#1{%
  \begingroup\lccode`\~=`#1\lowercase{\endgroup\let~}}
\let\seealso@macrolist\empty
\def\seealso@clearlist#1{%
  \global\cslet{seealso@#1@list}\empty}
\AtBeginDocument{\forlistloop\seealso@clearlist\seealso@macrolist}
\newcommand\SeealsoPrintList{%
  \forlistloop\seealso@printlist\seealso@macrolist
  \forlistloop\seealso@clearlist\seealso@macrolist}
\newif\ifseealso@gobblefirstlistsep
\newif\ifseealso@firstitem
\def\seealso@printlist#1{%
  \ifcsempty{seealso@#1@list}
    {}
    {\ifseealso@gobblefirstlistsep
       \seealso@gobblefirstlistsepfalse
     \else
       \csuse{seealso@#1@listsep}%
     \fi
     \csuse{seealso@#1@nameformat}{\csuse{#1name}}%
     \seealso@firstitemtrue
     \forlistcsloop{\seealso@listitem{#1}}{seealso@#1@list}}}
\def\seealso@listitem#1#2{%
  \ifseealso@firstitem
    \seealso@firstitemfalse
  \else
    \csuse{seealso@#1@itemsep}%
  \fi
  \csuse{seealso@#1@itemformat}{#2}}
\newcommand\DeclareSeealsoMacro[3]{%
  \newcommand#1[2]{%
    \seealso@setactivecr
    \seealso@ifinlistcs{##1}{seealso@#2@list}
      {}
      {\listcsgadd{seealso@#2@list}{##1}}%
    \csuse{seealso@#2@pageformat}{##2}}%
  \listadd\seealso@macrolist{#2}%
  \define@key{seealso@#2}{name}{%
    \csdef{#2name}{##1}}%
  \ifcsdef{#2name}
    {}
    {\kvsetkeys{seealso@#2}{name=#3}}%
  \def\do##1{%
    \define@key{seealso@#2}{##1}{%
      \csdef{seealso@#2@##1}{####1}}%
    \kvsetkeys{seealso@#2}{##1=\csuse{seealso@##1}}}%
  \docsvlist{listsep,itemsep}%
  \def\do##1{%
    \define@key{seealso@#2}{##1}{%
      \csdef{seealso@#2@##1}########1{####1}}%
      \kvsetkeys{seealso@#2}{##1=\csuse{seealso@##1}{####1}}}%
  \docsvlist{nameformat,itemformat,pageformat}}
\@onlypreamble{\DeclareSeealsoMacro}
\newif\ifseealso@iscractive
\def\seealso@setactivecr{%
  \ifseealso@activecr
    \unless\ifseealso@iscractive
      \catcode`\^^M=\active
      \seealso@charlet\^^M\seealso@cr
      \seealso@iscractivetrue
    \fi
  \fi}
\def\seealso@cr{%
  \futurelet\next\seealso@cr@aux}
\def\seealso@cr@aux{%
  \seealso@testwrap
  \ifseealso@wrap
    \space
  \else
    \catcode`\^^M=5
    \seealso@iscractivefalse
    \SeealsoPrintList
  \fi}
\newif\ifseealso@wrap
\def\seealso@testwrap{%
  \seealso@wraptrue
  \forlistloop\seealso@testwrap@aux\seealso@enditemlist}
\def\seealso@testwrap@aux#1{%
  \ifx#1\next
    \seealso@wrapfalse
    \expandafter\listbreak
  \fi}
\let\seealso@enditemlist\empty
\def\seealso@enditemlistadd#1{%
  \seealso@ifinlist{#1}\seealso@enditemlist
    {}
    {\listadd\seealso@enditemlist{#1}}}
\define@key{seealso}{enditem}{%
  \let\seealso@enditemlist\empty
  \listadd\seealso@enditemlist{\seealso@cr}%
  \forcsvlist\seealso@enditemlistadd{#1}}
\define@key{seealso}{enditem+}{%
  \forcsvlist\seealso@enditemlistadd{#1}}
\kvsetkeys{seealso}{%
  enditem={\indexspace,\item,\subitem,\subsubitem,\end}}
\def\seealso@listsep{,\space}
\def\seealso@itemsep{,\space}
\def\seealso@nameformat#1{\emph{#1}\space}
\def\seealso@itemformat#1{#1}
\def\seealso@pageformat#1{#1}
\def\seealso@define@key#1{%
  \define@key{seealso}{#1}{%
    \csdef{seealso@#1}{##1}}}
\def\seealso@define@keyarg#1{%
  \define@key{seealso}{#1}{%
    \csdef{seealso@#1}####1{##1}}}
\forcsvlist\seealso@define@key{listsep,itemsep}
\forcsvlist\seealso@define@keyarg{nameformat,itemformat,pageformat}
\AtBeginDocument{%
  \ifundef\hyperindexformat{%
    \let\SeealsoGobble\seealso@gobble
  }{%
    \def\SeealsoGobble#1{\seealso@swap{\seealso@gobble{#1}}}%
    \def\seealso@swap#1#2#3#4{#2#3#4#1}%
  }}
\def\seealso@gobble#1{%
  \@ifnextchar#1%
    {\seealso@gobbleignorespaces}
    {\ifseealso@activecr
       \ifx\@let@token\seealso@cr
         \seealso@gobblefirstlistseptrue
       \fi
     \else
       \ifx\@let@token\SeealsoPrintList
         \seealso@gobblefirstlistseptrue
       \fi
     \fi}}
\def\seealso@gobbleignorespaces#1{%
  \@ifnextchar\seealso@cr{\seealso@gobbleignorespaces}{\ignorespaces}}
\newcommand\seealsosetup[2][]{%
  \ifstrempty{#1}{%
    \kvsetkeys{seealso}{#2}%
  }{%
    \edef\do##1{%
      \noexpand\kvsetkeys{seealso@##1}{\unexpanded{#2}}}%
    \docsvlist{#1}}}
\let\seenopage\see
\let\seealsonopage\seealso
\DeclareSeealsoMacro\seepage{see}{see}
\DeclareSeealsoMacro\seealsopage{also}{see also}
\ifseealso@override
  \def\see{\seepage}
  \def\seealso{\seealsopage}
\fi
\endinput
%%
%% End of file `seealso.sty'.
