summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/fancytabs/fancytabs.dtx
blob: 71148945157726132dee16fe00c00dc97ef672f3 (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
% \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/16 1.1 Fancy page border tabs]
%
%<*driver>
\documentclass{ltxdoc}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\OnlyDescription
\begin{document}
 \DocInput{fancytabs.dtx}
\end{document}
%</driver>
% \fi
%
% \CheckSum{0}
%
% \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{\tabstyle}
%  The style of for the text in the tab.
%  Default is |\Large\scshape|.
%  You can set this value with:
%  |\renewcommand{\tabstyle}{<value>}|.
%
% \DescribeMacro{\tabheight}
%  Define the height of the tab.
%  Default is |4cm|.
%  You can set this value with
%  |\renewcommand{\tabheight}{<value>}|.
%
% \DescribeMacro{\tabwidth}
%  Define the height of the tab.
%  Default is |1cm|.
%  You can set this value with
%  |\renewcommand{\tabwidth}{<value>}|.
%
% \DescribeMacro{\tabcount}
%  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|.
%  You can set this value with
%  |\renewcommand{\tabcount}{<value>}|.
%
% \DescribeMacro{\tableftcolor}
%  Define the left color for the tab gradient.
%  Default is |white|.
%  You can set this value with
%  |\renewcommand{\tableftcolor}{<value>}|.
%
% \DescribeMacro{\tabrightcolor}
%  Define the right color for the tab gradient.
%  Default is |gray!50|.
%  You can set this value with
%  |\renewcommand{\tabrightcolor}{<value>}|.
%
% \DescribeMacro{\tabtop}
%  Define margin on top of the top tab.
%  Default is |\tabheight|.
%  You can set this value with
%  |\renewcommand{\tabtop}{<value>}|.
%
% \DescribeMacro{\tabtextvpos}
%  Define the relative vertical position
%  of the text in the tab.
%  Default is |0.5|.
%  You can set this value with
%  |\renewcommand{\tabtextvpos}{<value>}|.
%
% \DescribeMacro{\tabtexthpos}
%  Define the relative horizontal position
%  of the text in the tab.
%  Default is |\tabtextvpos|.
%  You can set this value with
%  |\renewcommand{\tabtexthpos}{<value>}|.
%
% \StopEventually{\PrintIndex}
%
% \section{Implementation}
% 
%  \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}
%  \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={-\tabtop-1*mod(#2-1,\tabcount)*\tabheight},
                  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