summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/bracketkey/bracketkey.sty
blob: 83806db22895b0c6ef1e285e46d7d144cb9c2d92 (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
%% bracketkey.sty
%% Copyright 2009 C. Heibl	
%
% 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.
%
% For a description of how to use bracketkey, see the files README and 
% Malva.txt
%
% Load required packages
\usepackage{calc}
\usepackage{xifthen}
\usepackage{coolstr}
\usepackage{hyperref}
\hypersetup{backref, pdfpagemode=FullScreen, colorlinks=true}
%
%\let\HyperRaiseLinkHook\@empty
%\def\HyperRaiseLinkDefault{\baselineskip}
%
\def\hang{\hangindent\parindent}
\newcounter{index}%
\newcounter{backindex}%
\newcounter{key}\setcounter{key}{0}
\newboolean{named}% 
\newboolean{back}%    
\newboolean{nameornumber}%         true if alternative results in a name
\newsavebox{\gprefix}%         Abbreviation of genus name, parameter for key
\newlength{\altindent}%        additional indentation of each key level
\setlength{\altindent}{0mm}
\newlength{\keylabelwidth}%    width of label of each key step
\setlength{\keylabelwidth}{2em}%
\newlength{\oldparindent}
%
% define command 'keytitle'
\newcommand{\keytitle}[2][it]{
	\vspace{2pt}
	\ifthenelse{\equal{#1}{it}}
		{\noindent\textbf{Key to \textit{#2}}} % taxonname in italis
		{\noindent\textbf{Key to #2}} % normal taxonname
	\vspace{2pt}
}
%
% define environment 'key'
\newenvironment{key}[1]%
  {\setcounter{index}{0}
  \stepcounter{key}
   \setboolean{nameornumber}{true}%
   \sbox{\gprefix}{\textit{\textbf{#1}}}%
   \setlength{\oldparindent}{\parindent}%
   \setlength{\hangindent}{0pt}%
   \setlength{\parindent}{0pt}%
  }
  {\par\setlength{\parindent}{\oldparindent}}
% 
% define command 'name'
\newcommand{\name}[4][\usebox{\gprefix}]%
 {\unskip\nobreak\hfil
  \penalty 150
  \leaders\hbox{\thinspace.\thinspace}\hskip 12pt plus 1fill
  \vadjust{}\hfil
   \isint{#3}{nameornumber}
   \ifthenelse{\boolean{nameornumber}}
	{#2\hspace{6pt}\textbf{\mbox{ \hyperlink{\thekey:#3}{#3}}}} %
   	{\hbox{\textbf{#2}\hspace{4pt}\textit{\textbf{#1}\textit{\textbf{\mbox{#3}}}}}\hspace{4pt}#4}%
  {\parfillskip=0pt\par}}
%
% define command 'leadONE'
\newcommand{\leadONE}[2]%
  {\par%
  \stepcounter{index}%
  \setcounter{backindex}{\theindex-1}
     \hspace*{-\keylabelwidth}\hspace*{-2mm}%
   %\parbox[t]{\keylabelwidth}{\hfill{\textbf{\hypertarget{\thekey:\theindex}{\theindex}}}}%
   %\parbox[t]{\keylabelwidth}{\hfill{\textbf{ \raisebox{\baselineskip}[0pt]{\hypertarget         
   %	{\thekey:\theindex}{}}\theindex}}}%
   \parbox[t]{\keylabelwidth}{\hfill{\textbf{\raisebox{\baselineskip}[0pt]{\hypertarget         
   	{\thekey:\theindex}{}}\hyperlink{\thekey:\thebackindex}{\theindex}}}}%
  \ifthenelse{\isempty{#1}}
   {\hspace*{2mm}#2}
  {\hspace*{1.4pt}\textbf{(\hyperlink{\thekey:#1}{#1})}\hspace*{2pt}#2}
}
%
% Anker nach oben verschieben:
% Instead of '\hypertarget{abc}{def}' you can also use
% '\raisebox{\baselineskip}[0pt]{\hypertarget{abc}{}}def'
%
% define command 'leadTWO'
\newcommand{\leadTWO}%
  {\par
   \hspace*{-\keylabelwidth}\hspace{-4mm}
   \parbox[t]{2em}{\hfill{\textbf{-}}}% die indexe eine Textbox
   \hspace*{2.7mm}% hier kommt der Text % \leadTWO
}%