Debian Codegraph @

texmf-dist/source/latex/fancytabs/fancytabs.dtx

raw
1 % \iffalse meta-comment
2 %
3 % Copyright (C) 2011 by Raphaël Pinson <[email protected]>
4 % ---------------------------------------------------------------------------
5 % This work may be distributed and/or modified under the
6 % conditions of the LaTeX Project Public License, either version 1.3
7 % of this license or (at your option) any later version.
8 % The latest version of this license is in
9 % http://www.latex-project.org/lppl.txt
10 % and version 1.3 or later is part of all distributions of LaTeX
11 % version 2005/12/01 or later.
12 %
13 % This work has the LPPL maintenance status `maintained'.
14 %
15 % The Current Maintainer of this work is Raphaël Pinson.
16 %
17 % This work consists of the files fancytabs.dtx and fancytabs.ins
18 % and the derived filebase fancytabs.sty.
19 %
20 % \fi
21 %
22 % \iffalse
23 %<*driver>
24 \ProvidesFile{fancytabs.dtx}
25 %</driver>
26 %<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
27 %<package>\ProvidesPackage{fancytabs}
28 %<*package>
29 [2016/03/29 1.9 Fancy page border tabs with Tikz]
30 %</package>
31 %
32 %<*driver>
33 \documentclass{ltxdoc}
34 \usepackage{fancytabs}
35 \usepackage{scrpage2}
36 \makeatletter
37 \global\let\tikz@ensure@dollar@catcode=\relax
38 \makeatother
39 \EnableCrossrefs
40 \CodelineIndex
41 \RecordChanges
42 \begin{document}
43 \DocInput{fancytabs.dtx}
44 \PrintChanges
45 \PrintIndex
46 \end{document}
47 %</driver>
48 % \fi
49 %
50 % \CheckSum{142}
51 %
52 % \CharacterTable
53 % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
54 % Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
55 % Digits \0\1\2\3\4\5\6\7\8\9
56 % Exclamation \! Double quote \" Hash (number) \#
57 % Dollar \$ Percent \% Ampersand \&
58 % Acute accent \' Left paren \( Right paren \)
59 % Asterisk \* Plus \+ Comma \,
60 % Minus \- Point \. Solidus \/
61 % Colon \: Semicolon \; Less than \<
62 % Equals \= Greater than \> Question mark \?
63 % Commercial at \@ Left bracket \[ Backslash \\
64 % Right bracket \] Circumflex \^ Underscore \_
65 % Grave accent \` Left brace \{ Vertical bar \|
66 % Right brace \} Tilde \~}
67 %
68 %
69 % \changes{v1.9}{2016/03/29}{Add RTL support (thanks to Zvika Haramaty)}
70 % \changes{v1.8}{2012/09/17}{Use lengths were fit}
71 % \changes{v1.7}{2011/09/04}{Add Makefile}
72 % \changes{v1.6}{2011/09/03}{Bugfix: Fix babel for non-frenchb users (thanks to Marco Daniel)}
73 % \changes{v1.5}{2011/09/01}{Bugfix: Put rotate box around text only (thanks to Wolfgang Ulmer)}
74 % \changes{v1.4}{2011/04/20}{Protect internal macros. Display a fancytab in documentation. Make it babel-safe.}
75 % \changes{v1.3}{2011/04/18}{Add tabfloor and accessors}
76 % \changes{v1.2}{2011/04/17}{Add tabgap. Fix tabtop by adding tabheight/2}
77 % \changes{v1.1}{2011/04/16}{Add tabtextvpos and tabtexthpos macros}
78 % \changes{v1.0}{2011/04/14}{Initial version}
79
80 % \DoNotIndex{\newcommand,\newenvironment}
81 %
82 % \providecommand*{\url}{\texttt}
83 % \GetFileInfo{fancytabs.dtx}
84 % \title{The \textsf{fancytabs} package\thanks{This document
85 % corresponds to \textsf{fancytabs}~\fileversion,
86 % dated~\filedate.}}
87 % \author{Rapha\"el Pinson \\ \url{[email protected]}}
88 % \date{\fileversion~from \filedate}
89 %
90 % \fancytabsStyle{\small\scshape}
91 % \chead{\fancytab{The Fancytabs Manual}{1}}
92 % \pagestyle{scrheadings}
93 %
94 % \maketitle
95 %
96 % \thispagestyle{scrheadings}
97 %
98 % \begin{abstract}
99 % The \textsf{fancytabs} package allows to insert tabs
100 % on the border of pages.
101 % \end{abstract}
102 %
103 % \section{Usage}
104 %
105 % \subsection{Adding a tab}
106 %
107 % \DescribeMacro{\fancytab}
108 % The |\fancytab| macro adds a new tab.
109 % It takes two mandatory arguments, and one optional:
110 % |\fancytab[<LEFT,RIGHT>]{<text>}{<position>}|
111 % and displays the text in the tab, on given vertical position,
112 % at LEFT or RIGHT horizontal position. Default is RIGHT.
113 %
114 % \subsection{Adding a tab to all odd pages with scrpage2}
115 %
116 % The following code adds a tab with the chapter name,
117 % positioned by chapter order, on each odd page.
118 %
119 % \begin{verbatim}
120 % \documentclass{scrbook}
121 % \usepackage{scrpage2}
122 % \usepackage{fancytabs}
123 % \usepackage{lipsum}
124 %
125 % % Capture chapter head
126 % \let\oldchapter\chapter
127 % \newcommand\temphead{}
128 % \newcommand\chaphead{}
129 % \renewcommand\chapter[2][\temphead]{%
130 % \renewcommand\temphead{#2}%
131 % \renewcommand\chaphead{#2}%
132 % \oldchapter[#1]{#2}}
133 %
134 % % Set central right header to display tab
135 % % for both scrplain and scrheadings
136 % \cohead[\fancytab{\chaphead}{\thechapter}]
137 % {\fancytab{\chaphead}{\thechapter}}
138 % \renewcommand*{\chapterpagestyle}{scrplain}
139 % \pagestyle{scrheadings}
140 %
141 % \begin{document}
142 % \chapter{A chapter}
143 %
144 % \lipsum
145 % \lipsum
146 %
147 % \end{document}
148 % \end{verbatim}
149 %
150 % \subsection{Parameters}
151 %
152 % \DescribeMacro{\fancytabsStyle}
153 % The style of the text in the tab.
154 % Default is |\Large\scshape|.
155 %
156 % \DescribeMacro{\fancytabsHeight}
157 % Define the height of the tab.
158 % Default is |4cm|.
159 %
160 % \DescribeMacro{\fancytabsWidth}
161 % Define the height of the tab.
162 % Default is |1cm|.
163 %
164 % \DescribeMacro{\fancytabsCount}
165 % Define the maximum amount of tabs on a page.
166 % After |\tabcount| tabs are displayed,
167 % the next tab is displayed on top of the page again.
168 % Default is |6|.
169 %
170 % \DescribeMacro{\fancytabsLeftColor}
171 % Define the left color for the tab gradient.
172 % Default is |white|.
173 %
174 % \DescribeMacro{\fancytabsRightColor}
175 % Define the right color for the tab gradient.
176 % Default is |gray!50|.
177 %
178 % \DescribeMacro{\fancytabsTop}
179 % Define margin on top of the top tab.
180 % Default is |\tab@height|.
181 %
182 % \DescribeMacro{\fancytabsTextVPos}
183 % Define the relative vertical position
184 % of the text in the tab.
185 % Default is |0.5|.
186 %
187 % \DescribeMacro{\fancytabsTextHPos}
188 % Define the relative horizontal position
189 % of the text in the tab.
190 % Default is |\tab@textvpos|.
191 %
192 % \DescribeMacro{\fancytabsGap}
193 % Define the gap between two tabs.
194 % Default is |0in|.
195 %
196 % \DescribeMacro{\fancytabsFloor}
197 % Define the starting number for incrementation.
198 % This is useful if you want to pass for example
199 % |\arabic{chapter}| as counter but not put tabs
200 % for previous chapters.
201 % Default is |0|.
202 %
203 % \DescribeMacro{\fancytabsRotate}
204 % Define the text rotation.
205 % Default is |90|.
206 %
207 % \StopEventually{}
208 %
209 % \section{Implementation}
210 %
211 % \iffalse
212 %<*package>
213 % \fi
214 %
215 % \begin{macrocode}
216 \ProvidesPackage{fancytabs}
217 \RequirePackage{tikz}
218 \RequirePackage{etoolbox}
219 % \end{macrocode}
220 %
221 % \begin{macro}{Variables}
222 % \begin{macrocode}
223 \newcommand{\tab@style}{\Large\scshape}
224 \newlength{\tab@height}
225 \setlength{\tab@height}{4cm}
226 \newlength{\tab@width}
227 \setlength{\tab@width}{1cm}
228 \newcommand{\tab@count}{6}
229 \newcommand{\tab@leftcolor}{white}
230 \newcommand{\tab@rightcolor}{gray!50}
231 \newlength{\tab@top}
232 \setlength{\tab@top}{\the\tab@height}
233 \newcommand{\tab@textvpos}{0.5}
234 \newcommand{\tab@texthpos}{\tab@textvpos}
235 \newlength{\tab@gap}
236 \setlength{\tab@gap}{0in}
237 \newcommand{\tab@floor}{0}
238 \newcommand{\tab@rotate}{90}
239 % \end{macrocode}
240 % \end{macro}
241 %
242 %
243 % \begin{macro}{Accessors}
244 % \begin{macrocode}
245 \newcommand{\fancytabsStyle}[1]{\renewcommand{\tab@style}{#1}}
246 \newcommand{\fancytabsHeight}[1]{\setlength{\tab@height}{#1}}
247 \newcommand{\fancytabsWidth}[1]{\setlength{\tab@width}{#1}}
248 \newcommand{\fancytabsCount}[1]{\renewcommand{\tab@count}{#1}}
249 \newcommand{\fancytabsLeftColor}[1]{\renewcommand{\tab@leftcolor}{#1}}
250 \newcommand{\fancytabsRightColor}[1]{\renewcommand{\tab@rightcolor}{#1}}
251 \newcommand{\fancytabsTop}[1]{\setlength{\tab@top}{#1}}
252 \newcommand{\fancytabsTextVPos}[1]{\renewcommand{\tab@textvpos}{#1}}
253 \newcommand{\fancytabsTextHPos}[1]{\renewcommand{\tab@texthpos}{#1}}
254 \newcommand{\fancytabsGap}[1]{\setlength{\tab@gap}{#1}}
255 \newcommand{\fancytabsFloor}[1]{\renewcommand{\tab@floor}{#1}}
256 \newcommand{\fancytabsRotate}[1]{\renewcommand{\tab@rotate}{#1}}
257 % \end{macrocode}
258 % \end{macro}
259 %
260 %
261 % \begin{macro}{Babel safety}
262 %
263 % Some |babel| packages (such as |frenchb|) handle semi-colons which
264 % is incompatible with |tikz|. This part disables semi-colon handling
265 % by babel locally.
266 %
267 % \begin{macrocode}
268 \AtBeginDocument{\@ifpackageloaded{babel}
269 {\@ifundefined{active@char;}{}{%
270 \g@addto@macro\tikz@installcommands{%
271 \shorthandoff{;}}%
272 \g@addto@macro\tikz@uninstallcommands{%
273 \shorthandon{;}}%
274 }%
275 }{}%
276 }
277 % \end{macrocode}
278 % \end{macro}
279 %
280 % \begin{macro}{\fancytab}
281 % We define the |\fancytab| macro to generate a new tab.
282 % \begin{macrocode}
283 \newcommand{\fancytab}[3][RIGHT]{%
284 \ifstrequal{#1}{LEFT}
285 {
286 \newcommand{\eastwest}{west}
287 \newcommand{\multiplier}{0.5}
288 }
289 { %else
290 \newcommand{\eastwest}{east}
291 \newcommand{\multiplier}{-0.5}
292 }
293 \begin{tikzpicture}[remember picture,overlay]%
294 \node[yshift={-1*(\the\tab@top+\the\tab@height/2+
295 mod(#3-1-\tab@floor,\tab@count)*
296 (\the\tab@height+\the\tab@gap))},
297 xshift=\multiplier*\the\tab@width]
298 at (current page.north \eastwest) {
299 \tikz\shade[shading=axis,bottom color=\tab@leftcolor,
300 top color=\tab@rightcolor,shading angle=-90]
301 (0,0) rectangle (\the\tab@width,\the\tab@height)
302 node[rotate=0]
303 at (\tab@texthpos*\the\tab@width,\tab@textvpos*\the\tab@height)
304 {\rotatebox{\tab@rotate}{\tab@style#2}};%
305 };%
306 \end{tikzpicture}%
307 }
308 % \end{macrocode}
309 % \end{macro}
310 %
311 % \iffalse
312 %</package>
313 % \fi
314 %
315 % \Finale
316 \endinput