summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/guitartabs/guitartabs-doc.tex
blob: df8b1dc12a52a8e2463cf7e6417010eedfb2becf (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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
%NAME: guitartabs-doc.tex
%
% Andrey Babushkin, 2018/05/01
% babusand@fit.cvut.cz
%
% The documentation source for the guitartabs class.
% 
% Released under the The LaTeX Project Public License 1.3c.

\documentclass{guitartabs}

\title{\LaTeX\ Guitar Tabs}
\author{Andrey Babushkin}
\date{June, 2018}

\usepackage{geometry}
\geometry{left=2.0cm, top=1.5cm, right=2.0cm, bottom=1.5cm, footskip=0cm}

\usepackage{listings}
\lstset{
	keepspaces=false,
	numbers=left,
	language=[LaTeX]TeX,
	basicstyle=\tt\scriptsize,
	keywordstyle=\color{blue},
	identifierstyle=\color{magenta},
	morekeywords={*,
				artistname,
				albumtitle,
				songname,
				maketabheader,
				note,
				notel,
				restwhole,
				resthalf,
				restquarter,
				resteighth,
				restsixteenth
				}
}

\usepackage{titling}
\renewcommand\maketitlehooka{\null\mbox{}\vfill}
\renewcommand\maketitlehookd{\vfill\null}

\begin{document}
	
	\begin{titlingpage}
		\maketitle
	\end{titlingpage}
	
	\pagebreak
	\tableofcontents
	\pagebreak
	
	\section{Introduction}
	
	Many guitarists in the world use instead of music sheets guitar tabs, which is a more convenient 
	way of learning songs. Music sheets show how a melody goes: the notes, tonality, mode, time signatures etc.
	Unfortunately, a guitar has one same note on different strings several times and the position of the left 
	hand plays its role. So, the guitar tabs were created where a different notation is used. Every line of a
	guitar tab shows a separate string. A number on a string shows which fret should be played on which moment. 
	Of course, the a time signature is still written on the beginning of the tab and vertical lines separate 
	a tab onto bars, just like on a music sheet. There are also tuning settings written for each string.
	
	This project describes a set of \LaTeX\space macros that allow a user to write such guitar tabs.
	
	\begin{tabline}{3}{6}{8}{E,A,D,G,B,E}
		\notel{1}{6}{6}{0}{8}
		\notel{2}{6}{3}{0}{8}
		\notel{3}{6}{2}{0}{8}
		\notel{4}{6}{1}{0}{8}
		\notel{5}{6}{2}{0}{8}
		\notel{6}{6}{3}{0}{8}
		
		\nextbar
		\notel{1}{12}{6}{0}{8}
		\notel{3}{12}{3}{0}{8}
		\notel{5}{12}{2}{0}{8}
		\notel{7}{12}{1}{0}{8}
		\notel{9}{12}{2}{0}{8}
		\notel{11}{12}{6}{3}{16}
		\notel{12}{12}{6}{2}{16}
		
		\nextbar
		\notel{1}{12}{6}{0}{8}
		\notel{3}{12}{3}{0}{8}
		\notel{5}{12}{2}{0}{8}
		\notel{7}{12}{1}{3}{8}
		\notel{9}{12}{3}{0}{16}
		\notel{10}{12}{1}{0}{16}
		\notel{11}{12}{2}{0}{16}
		\notel{12}{12}{3}{0}{16}
	\end{tabline}

	\section{Quick start}
	\subsection{Generating header}
	
	A new class called \textbf{\textit{guitartabs.cls}} was created, so, for using this class a command 
	\begin{lstlisting}
\documentclass{guitartabs}
	\end{lstlisting} 
	should be used on the beginning of a document.
	
	Every guitar tab has a title of a song, an album and a composer (resp. band) name. Before starting a 
	document one can use a set of macros to define these. 
	\begin{lstlisting}[firstnumber=2]
\artistname{Metallica}
\albumtitle{Metallica}
\songname{Nothing Else Matters}
	\end{lstlisting}
	
	To start writing a document one should begin with:
	\begin{lstlisting}[firstnumber=5]
\begin{document}
	\maketabheader % print the header
	
	The code goes here...
\end{document}
	\end{lstlisting}
	As you can see, the \lstinline{\maketabheader} is used to print a header of the document.
	
	\pagebreak
	\subsection{List of available commands}
	
	So, now we are ready to make some \LaTeX\ music! First of all, let me introduce a set of all available commands:
	\vspace{0.5cm}
	
	\begin{tabular}{ | p{4cm} | p{5cm} | p{7cm} | }
		\hline
		\textbf{Command} 
			& \textbf{Description} 
			& \textbf{Arguments} 
			\\ \hline
		\textbackslash artistname\{name\} 
			& Sets an artist name who wrote or performed a composition. 
			& \textit{name} - an artist name.
			\\ \hline
		\textbackslash albumtitle\{title\}
			& Sets an album title on which the song was published.
			& \textit{title} - an album title
			\\ \hline
		\textbackslash songname\{name\} 
			& Sets a song name. 
			& \textit{name} - a song name.
			\\ \hline
		\parbox[t]{4cm}{
			\textbackslash begin\{tabline\}
			\\ \hspace*{1cm}\{bars\}
			\\ \hspace*{1cm}\{tsupper\}
			\\ \hspace*{1cm}\{tslower\}
			\\ \hspace*{1cm}\{tuning\}
		}
			& Opens the environment and make \LaTeX\ ready for drawing tabs.
			& \parbox[t]{7cm}{
				\textit{bars} - a number of bars on a tab line.
				\\ \textit{tsupper} - upper time signature number.
				\\ \textit{tslower} - lower time signature number.
				\\ \textit{tuning} - a guitar tuning, starting from the 6th string. 
				\\ E.g. E,A,D,G,B,E
			}
			\\ \hline
		\textbackslash maketabheader
			& Prints a header.
			& 
			\\ \hline
		\parbox[t]{4cm}{
			\textbackslash note\{numerator\}
			\\ \hspace*{1cm}\{denominator\}
			\\ \hspace*{1cm}\{string\}
			\\ \hspace*{1cm}\{fret\}
		}
			& Draws one note.
			& \parbox[t]{7cm}{
				\textit{string} - a string.
				\\ \textit{fret} - a fret.
				\\ \textit{numerator}
				\\ \textit{denominator} - sets the position of a note relatively to the beginning of a bar. 
					E.g. values \{1\}\{2\} or \{8\}\{16\} print a note at the center of the bar.
			}
			\\ \hline
		\parbox[t]{4cm}{
			\textbackslash notel\{numerator\}
			\\ \hspace*{1cm}\{denominator\}
			\\ \hspace*{1cm}\{string\}
			\\ \hspace*{1cm}\{fret\}
			\\ \hspace*{1cm}\{length\}
		}
			& Draws one note with a note length beneath a tab line.
			& \parbox[t]{7cm}{
				\textit{string} - a string.
				\\ \textit{fret} - a fret.
				\\ \textit{numerator}
				\\ \textit{denominator} - sets the position of a note relatively to the beginning of a bar. 
				E.g. values \{1\}\{2\} or \{8\}\{16\} print a note at the center of the bar.
				\\ \textit{length} - 1 for a whole note, 2 for a half note etc. 
				\\ Available values for length are:
				\\ 1, 2, 2.5, 4, 4.5, 8, 8.5, 16, 16.5
			}
		\\ \hline
		\parbox[t]{4cm}{
			\textbackslash restwhole
			\\ \textbackslash resthalf
			\\ \textbackslash restquarter
			\\ \textbackslash resteighth
			\\ \textbackslash restsixteenth
			\\ \hspace*{1cm}\{numerator\}
			\\ \hspace*{1cm}\{denominator\}
		}
			& A set of functions that draw rest symbols (whole, half, quarter, eighth, sixteenth, eighth respectively) on a selected position. 
			& \parbox[t]{7cm}{
				\textit{numerator}
				\\ \textit{denominator} - sets the position of a rest relatively to the beginning of a bar. 
				E.g. values \{1\}\{2\} or \{8\}\{16\} print a rest at the center of the bar.
			}
			\\ \hline
		\textbackslash end\{tabline\}
			& Closes the environment and draws a tab line.
			& 
			\\ \hline
		\textbackslash nextbar 
			& Moves a position of the cursor to the next bar.
			& 
			\\ \hline
	\end{tabular}

	\vspace{0.5cm}
	The way how the position of a note is set was chosen with a reason. Sometimes some notes are played 
	out of the rhythm of a song. For example:
	
	 \begin{tabline}{1}{4}{4}{E,A,D,G,B,E}
	 	\notel{1}{2}{3}{12}{2}
	 	\notel{2}{2}{3}{12}{2}
	 	\notel{3}{4}{4}{12}{8}
	 \end{tabline}
 
 	So, here we have 3 notes, two of them fill the bar rhythmically but we have the 3rd note, 1/8, that goes before the second 1/2. So, such approach of setting the exact position of each note offers great flexibility.
 	
 	\pagebreak
 	\subsection{Example}
 	
 	So, let's have a look on the example from the introduction section:
 	
 	\begin{tabline}{3}{6}{8}{E,A,D,G,B,E}
 		
 		\notel{1}{6}{6}{0}{8}
 		\notel{2}{6}{3}{0}{8}
 		\notel{3}{6}{2}{0}{8}
 		\notel{4}{6}{1}{0}{8}
 		\notel{5}{6}{2}{0}{8}
 		\notel{6}{6}{3}{0}{8}
 		
 		\nextbar
 		\notel{1}{12}{6}{0}{8}
 		\notel{3}{12}{3}{0}{8}
 		\notel{5}{12}{2}{0}{8}
 		\notel{7}{12}{1}{0}{8}
 		\notel{9}{12}{2}{0}{8}
 		\notel{11}{12}{6}{3}{16}
 		\notel{12}{12}{6}{2}{16}
 		
 		\nextbar
 		\notel{1}{12}{6}{0}{8}
 		\notel{3}{12}{3}{0}{8}
 		\notel{5}{12}{2}{0}{8}
 		\notel{7}{12}{1}{3}{8}
 		\notel{9}{12}{3}{0}{16}
 		\notel{10}{12}{1}{0}{16}
 		\notel{11}{12}{2}{0}{16}
 		\notel{12}{12}{3}{0}{16}
 	\end{tabline}
 
 	Of course, the best way to learn something is to look at the code. Here is comes:
 	
 	\begin{lstlisting}[firstnumber=1]
 % we create a tab with 3 bars, with the time signature 6/8 and a standart guitar tuning (E, A, D, G, B, E)
 \begin{tabline}{3}{6}{8}{E,A,D,G,B,E}
 
	\notel{1}{6}{6}{0}{8} % 1st bar, position 1/6, 6th string, 0th fret, length 1/8
	\notel{2}{6}{3}{0}{8} % 1st bar, position 2/6, 3rd string, 0th fret, length 1/8
	\notel{3}{6}{2}{0}{8}
	\notel{4}{6}{1}{0}{8}
	\notel{5}{6}{2}{0}{8}
	\notel{6}{6}{3}{0}{8}
	
	\nextbar				% move the cursor to the next bar
	\notel{1}{12}{6}{0}{8}
	\notel{3}{12}{3}{0}{8}
	\notel{5}{12}{2}{0}{8}
	\notel{7}{12}{1}{0}{8}
	\notel{9}{12}{2}{0}{8}
	\notel{11}{12}{6}{3}{16} % 2nd bar, position 11/12, 6th string, 3rd fret, length 1/16
	\notel{12}{12}{6}{2}{16}
	
	\nextbar
	\notel{1}{12}{6}{0}{8}
	\notel{3}{12}{3}{0}{8}
	\notel{5}{12}{2}{0}{8}
	\notel{7}{12}{1}{3}{8}
	\notel{9}{12}{3}{0}{16}
	\notel{10}{12}{1}{0}{16}
	\notel{11}{12}{2}{0}{16}
	\notel{12}{12}{3}{0}{16}
	
\end{tabline}
 	\end{lstlisting}
 	
 	It is that simple. Of course, the position on the bar determines the length of each note, so, if
 	one does not need the length to be drawn, one can omit the last argument and use \lstinline{\note} 
 	instead of \lstinline{\notel}. Everything else stays the same.
 	
 	\begin{lstlisting}[firstnumber=1]
\begin{tabline}{3}{6}{8}{E,A,D,G,B,E}
	\note{1}{6}{6}{0} % we use \note instead of \notel and omit the last argument
	\note{2}{6}{3}{0} 
	\note{3}{6}{2}{0}
	\note{4}{6}{1}{0}
	\note{5}{6}{2}{0}
	\note{6}{6}{3}{0}
	
	\nextbar
	\note{1}{12}{6}{0}
	\note{3}{12}{3}{0}
	\note{5}{12}{2}{0}
	\note{7}{12}{1}{0}
	\note{9}{12}{2}{0}
	\note{11}{12}{6}{3} 
	\note{12}{12}{6}{2}
	
	\nextbar
	\note{1}{12}{6}{0}
	\note{3}{12}{3}{0}
	\note{5}{12}{2}{0}
	\note{7}{12}{1}{3}
	\note{9}{12}{3}{0}
	\note{10}{12}{1}{0}
	\note{11}{12}{2}{0}
	\note{12}{12}{3}{0}

\end{tabline}
	\end{lstlisting}

	This code results in this tab line:
	
	\begin{tabline}{3}{6}{8}{E,A,D,G,B,E}
		
		\note{1}{6}{6}{0} 
		\note{2}{6}{3}{0} 
		\note{3}{6}{2}{0}
		\note{4}{6}{1}{0}
		\note{5}{6}{2}{0}
		\note{6}{6}{3}{0}
		
		\nextbar
		\note{1}{12}{6}{0}
		\note{3}{12}{3}{0}
		\note{5}{12}{2}{0}
		\note{7}{12}{1}{0}
		\note{9}{12}{2}{0}
		\note{11}{12}{6}{3}
		\note{12}{12}{6}{2}
		
		\nextbar
		\note{1}{12}{6}{0}
		\note{3}{12}{3}{0}
		\note{5}{12}{2}{0}
		\note{7}{12}{1}{3}
		\note{9}{12}{3}{0}
		\note{10}{12}{1}{0}
		\note{11}{12}{2}{0}
		\note{12}{12}{3}{0}
		
	\end{tabline}
		
	One may notice that there are no small drawn anymore  underneath every note.
	
	\pagebreak
	
	\section{Conclusion}
	
	The goal of this work was to create flexible and simple enough system to draw guitar tabs. In my opinion, this goal was reached. The \textbf{guitartabs} class offers a simple interface for drawing such tabs, so, a user
	is only responsible for writing music and the class will make everything else including drawing, calculating
	positions on the bar, setting correct size etc. 
	
\end{document}