summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/seealso/seealso.sty
blob: ae67167b76fa38b465d884ef86ffeaee83ea30a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
%%
%% 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 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}
    [2014/04/06 v1.0 makeidx's see and seealso with page number support.]
\RequirePackage{etoolbox}
\RequirePackage{kvoptions}
\SetupKeyvalOptions{
  family=seealso@opt,
  prefix=seealso@}
\DeclareBoolOption[true]{override}
\DeclareBoolOption[true]{activecr}
\ProcessKeyvalOptions*
\def\seealso@charlet#1{%
  \begingroup\lccode`\~=`#1\lowercase{\endgroup\let~}}
\let\seealso@macrolist\empty
\def\seealso@clearlists{%
  \def\do##1{\cslet{seealso@##1@list}\empty}%
  \dolistloop\seealso@macrolist}
\AtBeginDocument{\seealso@clearlists}
\newcommand\SeealsoPrintList{%
  \forlistloop\seealso@printlist\seealso@macrolist
  \seealso@clearlists}
\newif\ifseealso@firstitem
\def\seealso@printlist#1{%
  \ifcsempty{seealso@#1@list}
    {}
    {\csuse{seealso@#1@listsep}%
     \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
    \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}
    {}
    {\setkeys{seealso@#2}{name=#3}}%
  \def\do##1{%
    \define@key{seealso@#2}{##1}{%
      \csdef{seealso@#2@##1}{####1}}%
    \setkeys{seealso@#2}{##1=\csuse{seealso@##1}}}%
  \docsvlist{listsep,itemsep}%
  \def\do##1{%
    \define@key{seealso@#2}{##1}{%
      \csdef{seealso@#2@##1}########1{####1}}%
      \setkeys{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{%
  \catcode`\^^M=5
  \seealso@iscractivefalse
  \SeealsoPrintList}
\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}
\def\SeealsoGobble#1{\@ifnextchar#1{\seealso@gobbleignorespaces}{}}
\def\seealso@gobbleignorespaces#1{\ignorespaces}
\newcommand\seealsosetup[2][]{%
  \ifstrempty{#1}{%
    \setkeys{seealso}{#2}%
  }{%
    \def\do##1{\setkeys{seealso@##1}{#2}}%
    \forcsvlist{\do}{#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'.