Debian Codegraph @

texmf-dist/doc/latex/progressbar/progressbar.tex

raw
1 %% progressbar.tex
2 %% Copyright 2010-2014 Marcel Jira
3 %
4 % This work may be distributed and/or modified under the
5 % conditions of the LaTeX Project Public License, either version 1.3c
6 % of this license or (at your option) any later version.
7 % The latest version of this license is in
8 % http://www.latex-project.org/lppl.txt
9 % and version 1.3c or later is part of all distributions of LaTeX
10 % version 2005/12/01 or later.
11 %
12 % This work has the LPPL maintenance status `maintained'.
13 %
14 % The Current Maintainer of this work is Marcel Jira.
15 %
16 % This work consists of the files progressbar.sty and progressbar.tex.
17 %
18 \documentclass{ltxdoc}
19
20 \usepackage[T1]{fontenc}
21 \usepackage[utf8]{inputenc}
22 \usepackage[english]{babel}
23
24 \usepackage{listings}
25 \lstset{basicstyle=\ttfamily\small\mdseries,linewidth=\linewidth,breaklines=true,escapeinside={(*}{*)},}
26
27 \usepackage{progressbar}
28
29 \usepackage{hyperref}
30
31 \title{\texttt{progressbar}}
32 \author{by Marcel Jira}
33 \date{2013/01/06}
34
35 \begin{document}
36
37 \maketitle
38
39 \begin{abstract}
40 This package allows you to easily visualize shares of total amounts in the form of a bar. So basically you can convert a number like $0.735$ to \progressbar{0.735} using the command \lstinline+\progressbar{0.735}+.
41
42 Of course also a lot of customizations are possible (like this: \progressbar[emptycolor=yellow,filledcolor=red,linecolor=blue,subdivisions=4,roundnessr=0.5,tickscolor=green,tickswidth=1,ticksheight=1]{0.735}).
43 \end{abstract}
44
45 \noindent\progressbar[width=\textwidth,heighta=3cm,filledcolor=red,emptycolor=green,borderwidth=5pt,tickswidth=2.5pt,roundnessr=0.5,subdivisions=20]{0.55}
46 \begin{lstlisting}[basicstyle=\ttfamily\normalsize\mdseries]
47 \progressbar[width=textwidth, heighta=3cm, filledcolor=red, emptycolor=green, borderwidth=5pt, tickswidth=2.5pt, roundnessr=0.5, subdivisions=20]{0.55}
48 \end{lstlisting}
49
50 \tableofcontents
51
52 \section{Installation}
53 Make sure the file \texttt{progressbar.sty} is placed somewhere, where \LaTeX can find it. Usually that means, you simply download the package \texttt{progressbar} with the \LaTeX-package-manager of your choice.
54
55 \subsection{Dependencies}
56 You also have to ensure that all packages needed by \texttt{progressbar} are present (some package-managers do this for you).
57 The dependencies are:
58 \begin{itemize}
59 \item calc
60 \item kvsetkeys
61 \item kvoptions
62 \item tikz
63 \end{itemize}
64 \section{How to use \texttt{progressbar}}
65 \DescribeMacro{\usepackage\{progressbar\}}
66 \DescribeMacro{\usepackage[]\{progressbar\}}
67 Like any other package, to use \texttt{progressbar}, you have to load it first. You do this with
68 \begin{lstlisting}
69 \usepackage{progressbar}
70 \end{lstlisting}
71 or
72 \begin{lstlisting}
73 \usepackage[<options>]{progressbar}
74 \end{lstlisting}
75 (You can find an explanation of all options in the section \ref{options}.)
76
77 Once you have loaded \texttt{progressbar}, you can use two different commands, described in the following.
78 \subsection{\texttt{\textbackslash{}progressbar}}\label{commandprogressbar}
79 \DescribeMacro{\progressbar\{\}}
80 \DescribeMacro{\progressbar[]\{\}}
81 The command
82 \begin{lstlisting}
83 \progressbar{<number>}
84 \end{lstlisting}
85 will draw you a progressbar with the share \texttt{<number>}. For example \lstinline+\progressbar{0.666}+ gives you this \progressbar{0.666}. You would want to use only numbers in the interval $[0,1]$, although other numbers are also possible (but will look just the same as \lstinline+\progressbar{0}+ or \lstinline+\progressbar{1}+).
86
87 If you want one specific progressbar to look different than the others, use
88 \begin{lstlisting}
89 \progressbar[<options>]{<number>}
90 \end{lstlisting}
91 instead. This command is just the same as \lstinline+\progressbar{<number>}+ but allows you to manipulate the appearance of the current progressbar. So \lstinline+\progressbar[width=5cm,heightr=1,filledcolor=red,emptycolor=blue!30]{0.75}+ would look like this: \progressbar[width=5cm,heightr=1,filledcolor=red,emptycolor=blue!30]{0.75}. In this case the options are only changed locally. (You can find an explanation of all options in the section \ref{options}.)
92
93 \subsection{\texttt{\textbackslash{}progressbarchange}}
94 \DescribeMacro{\progressbarchange\{\}}
95 In principle, the command \lstinline+\progressbar{<number>}+ uses the options specified with \lstinline+\usepackage[<options>]{progressbar}+ or the default options (if an option was not specified). As described in the previous section (\ref{commandprogressbar}), you can override these options with \lstinline+\progressbar[<options>]{<number>}+. However, if you want to change the settings for \emph{all} following progressbar, you can use the command
96 \begin{lstlisting}
97 \progressbarchange{<options>}
98 \end{lstlisting}
99
100 So basically
101 \begin{lstlisting}
102 \progressbar{0.3}\\
103 \progressbar[roundnessr=0.5,ticksheight=1,tickswidth=1.5pt]{0.4}\\
104 \progressbar[roundnessr=0.5,ticksheight=1,tickswidth=1.5pt]{0.5}\\
105 \progressbar[roundnessr=0.5,ticksheight=1,tickswidth=1.5pt]{0.6}
106 \end{lstlisting}
107 gives you the same as
108 \begin{lstlisting}
109 \progressbar{0.3}\\
110 \progressbarchange{roundnessr=0.5,ticksheight=1,tickswidth=1.5pt}
111 \progressbar{0.4}\\
112 \progressbar{0.5}\\
113 \progressbar{0.6}
114 \end{lstlisting}
115
116 However, keep in mind that in the second case the options are changed globally. Therefore, all following progressbars will keep the changed design (as long as you don't call \lstinline+\progressbarchange{<options>}+ with other options again). (You can find an explanation of all options in the section \ref{options}.)
117
118 \section{Options}\label{options}
119 \subsection{Global and local options}
120 You can set global options when you load the \texttt{progressbar} with \lstinline+\usepackage[options]{progressbar}+ and with the command \lstinline+\progressbarchange{<options>}+. These options affect all following calls of the commands \lstinline+\progressbar{<number>}+ and \lstinline+\progressbar[<options>]{<number>}+.
121
122 However, you can override global options with local options specified with \lstinline+\progressbar[<options>]{<number>}+.
123
124 \subsection{Options, their defaults and how to change them}
125 All listed options can be used globally and locally.
126
127 You will notice that some of the options are available with the prefix \texttt{r} (standing for relative) aswell as with the prefix \texttt{a} (standing for absolute). I would recommend you to always use those options with the prefix \texttt{r}, as using absolute values might not interact too well with the rest of your documents settings. But as long as you know what you are doing, it's up to you.
128
129 \DescribeMacro{heightr} default=\texttt{1}\\
130 The progressbars height as a fraction of the textheight\footnote{I used the capital letter ``I'' as a reference for the textheight}.
131 \begin{lstlisting}
132 \progressbar[heightr=1]{0.1}A progressbar that has the same height as the text\\
133 \progressbar[heightr=0.5]{0.9}A progressbar that has half the height
134 \end{lstlisting}
135 \progressbar[heightr=1]{0.1} A progressbar that has the same height as the text\\
136 \progressbar[heightr=0.5]{0.9} A progressbar that has half the height
137
138 \DescribeMacro{heighta} default=\texttt{unused}\\
139 With this option you can define the progressbars height absolutely.
140 \begin{lstlisting}
141 \progressbar[heighta=2cm]{0.3} A progressbar that has the height 2~cm\\
142 \progressbar[heighta=10pt]{0.7} A progressbar that has the height 10~pt\\
143 \progressbar[heighta=\heightof{a} + 0.8pt]{0.42} A progressbar whose upper border starts at the same height as the letter "a"
144 \end{lstlisting}
145 \progressbar[heighta=2cm]{0.3} A progressbar that has the height 2~cm\\
146 \progressbar[heighta=10pt]{0.7} A progressbar that has the height 10~pt\\
147 \progressbar[heighta=\heightof{a} + 0.8pt]{0.42} A progressbar whose upper border starts at the same height as the letter "a"\footnote{The \texttt{\textbackslash{}heightof} command and the possibility of adding is provided by the package \texttt{calc}}
148
149 \DescribeMacro{roundnessr} default=\texttt{0.15}\\
150 \texttt{progressbar} allows rounded corners. With this option you can set them as a fraction of the progressbars height. You would not want to use numbers higher than $0.5$.
151 \begin{lstlisting}
152 \progressbar[roundnessr=0.25]{0.8} More rounder corners than the default\\
153 \progressbar[roundnessr=0.5]{0.5} In fact no more corners -- complete roundness
154 \end{lstlisting}
155 \progressbar[roundnessr=0.25]{0.8} More rounder corners than the default\\
156 \progressbar[roundnessr=0.5]{0.5} In fact no more corners -- complete roundness
157
158 \DescribeMacro{roundnessa} default=\texttt{unused}\\
159 You can also define the corners radius as absolute values.
160 \begin{lstlisting}
161 \progressbar[roundnessa=2pt]{0} Rounded corners radius 2~pt\\
162 \progressbar[roundnessa=0cm]{1} No rounded corners
163 \end{lstlisting}
164 \progressbar[roundnessa=2pt]{0} Rounded corners radius 2~pt\\
165 \progressbar[roundnessa=0cm]{1} No rounded corners
166
167 \DescribeMacro{width} default=\texttt{6em}\\
168 The width of the progressbar.
169 \begin{lstlisting}
170 \progressbar[width=5cm]{0.123} Width: 5~cm\\
171 \progressbar[width=20em]{0.785} Width: 20~em
172 \end{lstlisting}
173 \progressbar[width=5cm]{0.123} Width: 5~cm\\
174 \progressbar[width=20em]{0.785} Width: 20~em
175
176 \DescribeMacro{borderwidth} default=\texttt{0.8pt}\\
177 The linewidth of the progressbars border.
178 \begin{lstlisting}
179 \progressbar[borderwidth=2pt]{0.6} Borderwidth: 2~pt\\
180 \progressbar[borderwidth=0.025em]{0.3} Borderwidth: 0.025~em
181 \end{lstlisting}
182 \progressbar[borderwidth=2pt]{0.6} Borderwidth: 2~pt\\
183 \progressbar[borderwidth=0.025em]{0.3} Borderwidth: 0.025~em
184
185 \DescribeMacro{subdivisions} default=\texttt{10}\\
186 As you may have noticed, (by default) the progressbar also has ticks. Those ticks splits the progressbar in multiple subdivisions. You can define the number of subdivisions with \texttt{subdivisions=<number>}. Therefore the number of ticks is $\texttt{<number>}-1$.
187 \begin{lstlisting}
188 \progressbar[subdivisions=3]{0.666667} 3 subdivisions and 2 ticks\\
189 \progressbar[subdivisions=15]{0.466667} 15 subdivisions and 14 ticks
190 \end{lstlisting}
191 \progressbar[subdivisions=3]{0.666667} 3 subdivisions and 2 ticks\\
192 \progressbar[subdivisions=15]{0.466667} 15 subdivisions and 14 ticks
193
194 \DescribeMacro{tickswidth} default=\texttt{0.4pt}\\
195 The linewidth of the ticks.
196 \begin{lstlisting}
197 \progressbar[tickswidth=1mm]{0.55} Tickswidth: 1~mm\\
198 \progressbar[tickswidth=0.1pt]{0.4} Tickswidth: 0.1~pt
199 \end{lstlisting}
200 \progressbar[tickswidth=1mm]{0.55} Tickswidth: 1~mm\\
201 \progressbar[tickswidth=0.1pt]{0.4} Tickswidth: 0.1~pt
202
203 \DescribeMacro{ticksheight} default=\texttt{0.33}\\
204 The height of the ticks as a fraction of the total progressbars height.
205 \begin{lstlisting}
206 \progressbar[ticksheight=0.1]{0.22} Ticksheight: 10 ~\% of the total height\\
207 \progressbar[ticksheight=1]{0.88} Ticks are end-to-end
208 \end{lstlisting}
209 \progressbar[ticksheight=0.1]{0.22} Ticksheight: 10 ~\% of the total height\\
210 \progressbar[ticksheight=1]{0.88} Ticks are end-to-end
211
212 \DescribeMacro{linecolor} default=\texttt{black}
213
214 \DescribeMacro{tickscolor} default=\texttt{black}
215
216 \DescribeMacro{emptycolor} default=\texttt{black!10}
217
218 \DescribeMacro{filledcolor} default=\texttt{black!60}\\
219 These options should be self-explaining. Just use \texttt{xcolor}-color-definitions (use color names or the syntax \lstinline+<color-name>!<number between 0 and 100>+) for brighter colors).
220 \begin{lstlisting}
221 \progressbar[linecolor=blue,tickscolor=orange,emptycolor=yellow,filledcolor=red]{0.6}
222 \end{lstlisting}
223 \progressbar[linecolor=blue,tickscolor=orange,emptycolor=yellow,filledcolor=red]{0.6}
224
225 \section{Changelog}
226 \begin{tabbing}
227 \texttt{2014/05/04 v.1.0b\~{}4} \= version control for kvoptions updated (for unknown\\ \>
228 reason required version didn't exist)\\
229 \texttt{2013/01/06 v.1.0b\~{}3} \= replaced \lstinline+\progressbar@LoadFile@IfExist+ with\\ \> \lstinline+\RequirePackage+\\
230 \texttt{2012/02/18 v.1.0b\~{}2} \> added version control for kvoptions\\
231 \texttt{2010/10/02 v1.0b} \> first release - all basic functionality
232 \end{tabbing}
233
234 \section{Acknoledgment}
235 A big shoutout to the pros from \url{http://www.mrunix.de/} (it's german). They helped me a lot and made \texttt{progressbar} possible.
236
237 I also want to thank Robin Schneider (\url{https://ypid.wordpress.com/}) and Heiko Oberdiek who called my attention to the problems with\\ \lstinline+\progressbar@LoadFile@IfExist+.
238
239 \section{Contact}
240 If you have any question concerning \texttt{progressbar} or if you miss a feature, please write me a mail: \href{mailto:[email protected]}{\texttt{[email protected]}}.
241
242 \end{document}