I explained this implementation in more detail in my blog: http://tobiw.de/tbdm/funktionssymbole (in German only)
Usage:
\function{<Function>}[<Bass Notes>][<Length>]{<Notes>}
<Funtion>
= T, D, S, Sp, s, …
The command allows also some special function symbols:
DD
for double dominant (maybe the wrong english terms, sorry for that, I know only the german ones …)
/D
for dominant without root
SS
for double sub-dominant
<Length>
= Length for space between and
<Notes>
= comma separated list of changes in notes (from lower two higher voices). Note that the order is reversed compared to my fist implementation.
<Bass Notes>
= changes in bass/lowest voice
- In all note definitions:
-
gets replaced by a dash
.
gets replaced by a space
- Numbers greater than 9 must be set in braces, e.g.
{11}
instead of 11
All notes/spaces/lines get the same with to make them align vertically.
The bass voice is always align at the same vertical position (kind of subscript). The first change in the list for the higher voices has a fixed vertical position too (kind of superscript) an all following changes get stacked above.
If you use another font (size) you must adjust all the ex
and em
values.
Results:
more or less complex voicings:
\function{T}{..7-8,3---4} \enskip
\function{D}{4---3, 6-5, ..7-8} \enskip
\function{D}{4----3, 6-5---, ..7-8-,{11}-----} \enskip
\function{s}{5,6}
special functions:
\function{DD}{8-7} \enskip \function{/D}{8-7} \enskip \function{SS}{5,6}
manually adjusted spacing between function symbol and note changes:
\function{D}[]{8-7} \enskip \function{D}[4-3]{} \enskip \function{D}[4-3]{8-7}
\par vs. \par
\function{D}[][-1pt]{8-7} \enskip \function{D}[4-3][-2.3pt]{} \enskip \function{D}[4-3][-1pt]{8-7}
with guides to show the base line etc.:
\showAllLines\mbox{}\enskip
% single change in upper voice
\function{D}{8-7} \enskip
% single chane in bass voice
\function{D}[8-7]{} \enskip
% change in upper and bass voice
\function{D}[8-7]{4-3} \enskip
% multiple changes
\function{D}[8--7]{4-3,6-5}
Full Code:
\documentclass{article}
\usepackage{xparse}
\ExplSyntaxOn
% width of the boxes containing the note numbers
\dim_new:N \l_palamas_boxwidth_dim
\dim_set:Nn \l_palamas_boxwidth_dim { 0.5em }
% token for the line betwwen two numbers
\tl_new:N \g_palamas_line_tl
\tl_set:Nn \g_palamas_line_tl { \rule [ 0.7ex ] { \l_palamas_boxwidth_dim } { 0.3pt } }
% token for a space between two numbers / befor a number
\tl_new:N \g_palamas_space_tl
\tl_set:Nn \g_palamas_space_tl { \hspace { \l_palamas_boxwidth_dim } }
% function to place the numbers/lines/space in an equal width box
\cs_new_protected:Npn \palamas_makebox:n #1 {
\makebox [ \l_palamas_boxwidth_dim ] [ c ] { #1 }
}
% function to porcess a change in notes (replace dash and dot)
\cs_new_protected:Npn \palamas_process_list:n #1 {
\tl_set:Nn \l_tmpa_tl { #1 }
\tl_replace_all:Nnn \l_tmpa_tl { - } { \g_palamas_line_tl }
\tl_replace_all:Nnn \l_tmpa_tl { . } { \g_palamas_space_tl }
\tl_map_function:NN \l_tmpa_tl \palamas_makebox:n
\\
}
% some tokes for special function symbols
%% double dominat
\tl_new:N \g_double_dominat_tl
\tl_set:Nn \g_double_dominat_tl { \makebox[0.2em][l]{\raisebox{0.2em}{D}}D }
%% double dominat
\tl_new:N \g_dominat_without_root_tl
\tl_set:Nn \g_dominat_without_root_tl { \makebox[0em][l]{\raisebox{0.25ex}{\small\kern0.2em/}}D }
%% double dominat
\tl_new:N \g_double_subdominat_tl
\tl_set:Nn \g_double_subdominat_tl { \makebox[0.1em][l]{\raisebox{0.2em}{S}}S }
% main function
\NewDocumentCommand { \function } { m O{} O{0pt} m } {
\tl_set:Nn \l_tmpa_tl { #1 }
\tl_replace_all:Nnn \l_tmpa_tl { DD } { \g_double_dominat_tl }
\tl_replace_all:Nnn \l_tmpa_tl { /D } { \g_dominat_without_root_tl }
\tl_replace_all:Nnn \l_tmpa_tl { SS } { \g_double_subdominat_tl }
\tl_use:N \l_tmpa_tl
\clist_set:Nn \l_tmpa_clist { #4 }
\clist_reverse:N \l_tmpa_clist
\kern#3
{
\tiny
\renewcommand { \arraystretch } { 0.75 }
\raisebox { -0.68ex } {
\begin{tabular}[b]{@{}l@{}}
% upper voices
\clist_map_function:NN \l_tmpa_clist \palamas_process_list:n
% shift/gap
\\[-1.2ex]
% bass line
\palamas_process_list:n { #2 }
\end{tabular}
}
}
}
\ExplSyntaxOff
% following is only for the demo
\usepackage{parskip}
\usepackage{xcolor}
\newcommand{\showBaseLine}{\makebox[0pt][l]{\color{magenta}\rule{\textwidth}{0.1pt}}}
\newcommand{\showXHeightLine}{\makebox[0pt][l]{\color{yellow}\rule[1ex]{\textwidth}{0.1pt}}}
\newcommand{\showMidLine}{\makebox[0pt][l]{\color{cyan}\rule[0.785ex]{\textwidth}{0.1pt}}}
\newcommand{\showCapHeightLine}{\makebox[0pt][l]{\color{magenta}\rule[1.57ex]{\textwidth}{0.1pt}}}
\newcommand{\showAllLines}{\showBaseLine\showXHeightLine\showMidLine\showCapHeightLine}
\begin{document}
\showAllLines\mbox{}\enskip
% single change in upper voice
\function{D}{8-7} \enskip
% single chane in bass voice
\function{D}[8-7]{} \enskip
% change in upper and bass voice
\function{D}[8-7]{4-3} \enskip
% multiple changes
\function{D}[8--7]{4-3,6-5}
% more complex examples
\function{T}{..7-8,3---4} \enskip
\function{D}{4---3, 6-5, ..7-8} \enskip
\function{D}{4----3, 6-5---, ..7-8-,{11}-----} \enskip
\function{s}{5,6}
% special function symbols
\function{DD}{8-7} \enskip
\function{/D}{8-7} \enskip
\function{SS}{5,6}
% adjust the space between function letter and notes
\function{D}[]{8-7} \enskip
\function{D}[4-3]{} \enskip
\function{D}[4-3]{8-7}
vs.
\function{D}[][-1pt]{8-7} \enskip
\function{D}[4-3][-2.3pt]{} \enskip
\function{D}[4-3][-1pt]{8-7}
\end{document}