summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/fancytabs/fancytabs.dtx
blob: 25539c7b08818ed57dd747d83d7ff1d3c50e8c5a (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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
% \iffalse meta-comment
%
% Copyright (C) 2011 by Raphaël Pinson
%
% This file may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
% version 1.2 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.2 or later is part of all distributions of
% LaTeX version 1999/12/01 or later.
%
% \fi
%
% \iffalse
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\ProvidesPackage{fancytabs}
%<package>   [2011/04/17 1.2 Fancy page border tabs]
%
%<*driver>
\documentclass{ltxdoc}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\OnlyDescription
\begin{document}
 \DocInput{fancytabs.dtx}
\end{document}
%</driver>
% \fi
%
% \CheckSum{0}
%
% \changes{v1.3}{2011/04/18}{Add tabfloor and accessors}
% \changes{v1.2}{2011/04/17}{Add tabgap. Fix tabtop by adding tabheight/2}
% \changes{v1.1}{2011/04/16}{Add tabtextvpos and tabtexthpos macros}
% \changes{v1.0}{2011/04/14}{Initial version}
%
% \GetFileInfo{fancytabs.dtx}
%
% \title{The \textsf{fancytabs} package\thanks{This document
%  corresponds to \textsf{fancytabs}~\fileversion,
%  dated~\filedate.}}
% \author{Rapha\"el Pinson \\ \texttt{raphink@gmail.com}}
%
% \maketitle
% 
% \begin{abstract}
%  The \textsf{fancytabs} package allows to insert tabs
%  on the border of pages.
% \end{abstract}
%
% \section{Usage}
%
% \subsection{Adding a tab}
%
% \DescribeMacro{\fancytab}
%  The |\fancytab| macro adds a new tab.
%  It takes two arguments:
%  |\fancytab{<text>}{<position>}|
%  and displays the text in the tab, on given vertical position.
%
% \subsection{Adding a tab to all odd pages with scrpage2}
%
% The following code adds a tab with the chapter name,
% positioned by chapter order, on each odd page.
%
% \begin{verbatim}
% \documentclass{scrbook}
% \usepackage{scrpage2}
% \usepackage{fancytabs}
% \usepackage{lipsum}
% 
% % Capture chapter head
% \let\oldchapter\chapter
% \newcommand\temphead{}
% \newcommand\chaphead{}
% \renewcommand\chapter[2][\temphead]{%
%    \renewcommand\temphead{#2}%
%    \renewcommand\chaphead{#2}%
%    \oldchapter[#1]{#2}}
%
% % Set central right header to display tab
% % for both scrplain and scrheadings
% \cohead[\fancytab{\chaphead}{\thechapter}]
%        {\fancytab{\chaphead}{\thechapter}}
% \renewcommand*{\chapterpagestyle}{scrplain}
% \pagestyle{scrheadings}
% 
% \begin{document}
% \chapter{My sample chapter}
% 
% \lipsum
% \lipsum
%
% \end{document}
% \end{verbatim}
%
% \subsection{Parameters}
%
% \DescribeMacro{\fancytabsStyle}
%  The style of for the text in the tab.
%  Default is |\Large\scshape|.
%
% \DescribeMacro{\fancytabsHeight}
%  Define the height of the tab.
%  Default is |4cm|.
%
% \DescribeMacro{\fancytabsWidth}
%  Define the height of the tab.
%  Default is |1cm|.
%
% \DescribeMacro{\fancytabsCount}
%  Define the maximum amount of tabs on a page.
%  After |\tabcount| tabs are displayed,
%  the next tab is displayed on top of the page again.
%  Default is |6|.
%
% \DescribeMacro{\fancytabsLeftColor}
%  Define the left color for the tab gradient.
%  Default is |white|.
%
% \DescribeMacro{\fancytabsRightColor}
%  Define the right color for the tab gradient.
%  Default is |gray!50|.
%
% \DescribeMacro{\fancytabsTop}
%  Define margin on top of the top tab.
%  Default is |\tabheight|.
%
% \DescribeMacro{\fancytabsTextVPos}
%  Define the relative vertical position
%  of the text in the tab.
%  Default is |0.5|.
%
% \DescribeMacro{\fancytabsTextHPos}
%  Define the relative horizontal position
%  of the text in the tab.
%  Default is |\tabtextvpos|.
%
% \DescribeMacro{\fancytabsGap}
%  Define the gap between two tabs.
%  Default is |0in|.
%
% \DescribeMacro{\fancytabsFloor}
%  Define the starting number for incrementation.
%  This is useful if you want to pass for example
%  |\arabic{chapter}| as counter but not put tabs
%  for previous chapters.
%  Default is |0|.
%
% \StopEventually{\PrintIndex}
%
% \section{Implementation}
% 
% \subsection{Variables}
%
%  \begin{macrocode}
\RequirePackage{tikz}
\newcommand{\tabstyle}{\Large\scshape}
\newcommand{\tabheight}{4cm}
\newcommand{\tabwidth}{1cm}
\newcommand{\tabcount}{6}
\newcommand{\tableftcolor}{white}
\newcommand{\tabrightcolor}{gray!50}
\newcommand{\tabtop}{\tabheight}
\newcommand{\tabtextvpos}{0.5}
\newcommand{\tabtexthpos}{\tabtextvpos}
\newcommand{\tabgap}{0in}
\newcommand{\tabfloor}{0}
%  \end{macrocode}
%
% \subsection{Accessors}
%
%  \begin{macrocode}
\newcommand{\fancytabsStyle}[1]{\renewcommand{\tabstyle}{#1}}
\newcommand{\fancytabsHeight}[1]{\renewcommand{\tabheight}{#1}}
\newcommand{\fancytabsWidth}[1]{\renewcommand{\tabwidth}{#1}}
\newcommand{\fancytabsCount}[1]{\renewcommand{\tabcount}{#1}}
\newcommand{\fancytabsLeftColor}[1]{\renewcommand{\tableftcolor}{#1}}
\newcommand{\fancytabsRightColor}[1]{\renewcommand{\tabrightcolor}{#1}}
\newcommand{\fancytabsTop}[1]{\renewcommand{\tabtop}{#1}}
\newcommand{\fancytabsTextVPos}[1]{\renewcommand{\tabtextvpos}{#1}}
\newcommand{\fancytabsTextHPos}[1]{\renewcommand{\tabtexthpos}{#1}}
\newcommand{\fancytabsGap}[1]{\renewcommand{\tabgap}{#1}}
\newcommand{\fancytabsFloor}[1]{\renewcommand{\tabfloor}{#1}}
%  \end{macrocode}
%
% \begin{macro}{\fancytab}
% We define the |\fancytab| macro to generate a new tab.
%  \begin{macrocode}
\newcommand{\fancytab}[2]{%
  \begin{tikzpicture}[remember picture,overlay]
    \node[yshift={-1*(\tabtop+\tabheight/2+
                 mod(#2-1-\tabfloor,\tabcount)*
                 (\tabheight+\tabgap))},
                  xshift=-0.5*\tabwidth]
      at (current page.north east) {
      \tikz\shade[shading=axis,bottom color=\tableftcolor,
                  top color=\tabrightcolor,shading angle=-90] 
        (0,0) rectangle (\tabwidth,\tabheight)
           node[rotate=90]
                  at (\tabtexthpos*\tabwidth,\tabtextvpos*\tabheight)
                      {\tabstyle#1};
    };
  \end{tikzpicture}%
}
%  \end{macrocode}
% \end{macro}
%
% \Finale
\endinput