From e0c6872cf40896c7be36b11dcc744620f10adf1d Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 2 Sep 2019 13:46:59 +0900 Subject: Initial commit --- macros/latex/contrib/octave/README.md | 14 +++ macros/latex/contrib/octave/octave.pdf | Bin 0 -> 254825 bytes macros/latex/contrib/octave/octave.sty | 158 +++++++++++++++++++++++++++++++++ macros/latex/contrib/octave/octave.tex | 128 ++++++++++++++++++++++++++ 4 files changed, 300 insertions(+) create mode 100644 macros/latex/contrib/octave/README.md create mode 100644 macros/latex/contrib/octave/octave.pdf create mode 100644 macros/latex/contrib/octave/octave.sty create mode 100644 macros/latex/contrib/octave/octave.tex (limited to 'macros/latex/contrib/octave') diff --git a/macros/latex/contrib/octave/README.md b/macros/latex/contrib/octave/README.md new file mode 100644 index 0000000000..533e9707fc --- /dev/null +++ b/macros/latex/contrib/octave/README.md @@ -0,0 +1,14 @@ +# The `octave` Package for Typesetting Musical Pitches with Octave Designations + +The `octave` package typesets musical pitch names with designations for the +octave in either the Helmholtz system (letter name with subscript numeral for +the octave, where middle C is `C4`), or the traditional system with upper- and +lowercase letters and prime symbols, where middle C is `c'`. + +Using this package, authors can just write `\pitch{C}{4}` and then by calling a +package option (`number` or `prime`), can render all the pitch names in either +system. +The system can also be changed mid-document. + +This material is subject to the current version of the LaTeX Project Public License. +The author and maintainer is Andrew A. Cashner, `andrewacashner@gmail.com`. diff --git a/macros/latex/contrib/octave/octave.pdf b/macros/latex/contrib/octave/octave.pdf new file mode 100644 index 0000000000..a8e5957faf Binary files /dev/null and b/macros/latex/contrib/octave/octave.pdf differ diff --git a/macros/latex/contrib/octave/octave.sty b/macros/latex/contrib/octave/octave.sty new file mode 100644 index 0000000000..da268104f4 --- /dev/null +++ b/macros/latex/contrib/octave/octave.sty @@ -0,0 +1,158 @@ +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{octave} +[2017/10/31 Octave designations in Helmholtz or traditional style] + +% Copyright 2017 Andrew A. Cashner, andrewacashner@gmail.com + +% This work may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either +% version 1.3 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.3 or later is part of all distributions +% of LaTeX version 2005/12/01 or later. +% +% This work has the LPPL maintenance status `maintained'. +% The Current Maintainer of this work is Andrew A. Cashner. +% This work consists of the package file octave.sty +% and the documentation file octave.tex. + +% CHANGE LOG +% 2017-10-31 Spelling corrections +% 2017-08-21 First version on CTAN + +\newif\if@OctaveNumber +\@OctaveNumbertrue % Use Helmholtz numbers by default + +\DeclareOption{prime} {\@OctaveNumberfalse} +\DeclareOption{number} {\@OctaveNumbertrue} + +\ProcessOptions\relax + +\RequirePackage{xparse} + +% Allow user to switch styles mid-document +\NewDocumentCommand{\octaveprimes} {}{\@OctaveNumberfalse} +\NewDocumentCommand{\octavenumbers} {}{\@OctaveNumbertrue} + +%**************************************************************************** +% Main user command to enter pitch +% example: middle C is \pitch{c}{4}, semitone up is \pitch{C}[\sh]{4} +% #1 Pitch letter (can be lower or uppercase) +% #2 Optional accidental (e.g., $\flat$, or \fl{} from semantic-markup package) +% #3 Octave number (Helmholtz numbers, middle C = 4) +\NewDocumentCommand{\pitch}{ m o m }{% + \if@OctaveNumber + {\pitchfont{\MakeUppercase{#1}% + \IfValueTF{#2}{#2}{}\textsubscript{#3}}}% + \else + {\pitchfont{% + \@GetOctaveTick{#1}[#2]{#3}% + }}% + \fi +} + +% Font for pitch and octave designation, default italics for prime style +% User can change with \renewcommand +\NewDocumentCommand{\pitchfont}{}{% + \if@OctaveNumber\mdseries% + \else\itshape% + \fi +} + +%*************************************************************************** +% If using ticks, determine the right letter and octave symbols to print +% +% Octave Designation +% 0 C'' +% 1 C' +% 2 C +% 3 c +% 4 c' +% 5 c'' +% +% The input octave number can be less than zero or more than 5; this will just +% produce a lot of tick marks (e.g., \pitch{c}{8} => c''''' + +% Mnemonic for selecting upper or lowercase letters, +% used as argument to \@PrintLetter +\NewDocumentCommand{\@OctaveUpper}{}{1} +\NewDocumentCommand{\@OctaveLower}{}{0} + +% Get the letter of the proper case and the right number of ticks. +% #1 Pitch letter +% #2 Optional accidental +% #3 Pitch number in Helmholtz notation +\newcount\@OctaveNum +\NewDocumentCommand{\@GetOctaveTick}{ m o m }{% + \@OctaveNum = #3 + \ifnum\@OctaveNum < 3 + % Octave < 3: Letter lowercase + (-OctaveNum + 2)ticks + \@PrintLetter{\@OctaveUpper}{#1}% + \multiply\@OctaveNum by -1 + \advance\@OctaveNum by 2 + \else + % Octave >= 3: Letter uppercase + (OctaveNum - 3)ticks + \ifnum\@OctaveNum > 2 + \@PrintLetter{\@OctaveLower}{#1}% + \advance\@OctaveNum by -3 + \fi + \fi + % Print accidental if there is one + \IfValueTF{#2}{\@SpacedAccidental{#2}}{}% + % Print ticks; No need to do so if octave 2 or 3 + \ifnum\@OctaveNum > 0 + \kern1pt\@PrintTicks{\@OctaveNum}% + \fi +} + +% Accidental with spacing around it +% #1 accidental symbol code +\NewDocumentCommand{\@SpacedAccidental}{ m }{% + \kern0.4pt#1\kern-0.4pt% +} +% Print letter in proper case +% #1 \@OctaveUpper (=1) or \@OctaveLower (=0) +% #2 Character to print +\NewDocumentCommand{\@PrintLetter}{ m m }{% + \ifnum #1 = \@OctaveLower + \MakeLowercase{#2}% + \else + \MakeUppercase{#2}% + \fi +} + +% Print sequence of tick marks +\newcount\@TickNum +\NewDocumentCommand{\@PrintTicks}{ m }{% + \@TickNum = #1% + \loop + \@Tick{}% + \advance\@TickNum by -1 + \ifnum\@TickNum > 0 + \repeat +} +\NewDocumentCommand{\@Tick}{}{\ensuremath{'}} + +%******************************************* +% Octave comparison table for demonstration +\newcounter{@TableOctave} +\NewDocumentCommand{\octavetable}{}{% + \def\@TablePitchNames{}% + \loop + \edef\@TablePitchNames{% + \@TablePitchNames + {\octaveprimes \pitch{C}{\the@TableOctave}} & + {\octavenumbers \pitch{C}{\the@TableOctave}}\tabularnewline + }% + \stepcounter{@TableOctave}% + \ifnum\value{@TableOctave} < 8 + \repeat + % + \begin{tabular}{ll} + \@TablePitchNames + \end{tabular}% +} + +\endinput diff --git a/macros/latex/contrib/octave/octave.tex b/macros/latex/contrib/octave/octave.tex new file mode 100644 index 0000000000..9f7c933a25 --- /dev/null +++ b/macros/latex/contrib/octave/octave.tex @@ -0,0 +1,128 @@ +\documentclass{article} + +\usepackage{lmodern} +\usepackage[T1]{fontenc} +\usepackage[utf8]{inputenc} +\usepackage{semantic-markup} +\usepackage{octave} +\usepackage{fancyvrb} +\frenchspacing +\usepackage[ + pdftitle={The octave Package for Typesetting Musical Pitches with Octave + Designations}, + pdfauthor={Andrew A. Cashner}, + pdfsubject={LaTeX package}, + pdfkeywords={LaTeX, music, musicology, humanities} +]{hyperref} + +\title{The \code{octave} Package for Typesetting Musical Pitches with Octave +Designations} +\author{Andrew A. Cashner\thanks{% + \href{mailto:andrewacashner@gmail.com} + {\nolinkurl{andrewacashner@gmail.com}}% + }% +} + +\begin{document} +\maketitle + +There are two standard ways of indicating the octave of a musical pitch: +\begin{enumerate} + \item The Helmholtz system, which uses subscript numerals after the pitch + letter name, where \soCalled{middle C} is \pitch{C}{4} + \item {\octaveprimes + The traditional system, which uses upper- and lowercase letters followed + by prime (tick) marks, where \soCalled{middle C} is \pitch{C}{4} and + an octave higher is \pitch{C}{5}.} +\end{enumerate} + +This package allows you to typeset pitch names conveniently using either method +(or even switching between) without worrying about typography, with a simple, +semantically meaningful interface. +Authors can write their documents without worrying about which system of +nomenclature their editor or press will prefer. +Simply changing the option with which the package is called will change the +display of all the pitches in the document that have been written with this +package's commands. + +\tableofcontents + +\section{Package Options} + +\begin{center} + \begin{tabular}{ll} + \code{number} & (Default) Use Helmholtz numbers \\ + \code{prime} & Use the traditional system with prime/tick marks \\ + \end{tabular} +\end{center} + +To use octave numbers, just add \verb|\usepackage{octave}| to your preamble. +To use the traditional system, write \verb|\usepackage[prime]{octave}| instead. + + + +\section{Switching Systems within One Document} + +At any time, you can change from one system to the other. + +\begin{center} +\begin{tabular}{ll} + \verb|\octaveprimes| + & Switch to the traditional system (prime/tick marks) \\ + \verb|\octavenumbers| + & Switch to the Helmholtz system (numbers) \\ +\end{tabular} +\end{center} + +\section{Style} + +The default setup (stored in the command \verb|\pitchfont|) is for pitch letters +and numbers in the Helmholtz system to be in the normal font, while pitch +letters and prime marks are in italic. You can change this, for example: + +\verb|\renewcommand{\pitchfont}{\mdseries}|. + +\section{Entering Pitch Names} + +To enter a pitch name, use the \verb|\pitch| command. +It takes three arguments: +\begin{enumerate} + \item (Mandatory) Letter name of the pitch: Can be upper- or lowercase; the + package will adjust the case as necessary + \item (Optional, in square brackets) Accidental command, e.g., \verb|$\sharp$| or \verb|\sh| + from the \code{semantic-markup} package + \item (Mandatory) Number of the pitch in the Helmholtz system +\end{enumerate} + +Yes, the package requires you to use the numbered system, even if you want the +output to be in the traditional system. +Thus middle C is \verb|\pitch{C}{4}|, and an octave and a semitone above that is +\verb|\pitch{C}[\sh]{5}| (using the \code{semantic-markup} package for the +accidental). + + +\section{Table of Octave Designations in the Two Systems} + +The package also provides the \verb|\octavetable| which displays a comparison +of the two systems, shown in table~\ref{octavetable}. + +\begin{table} + \caption{Pitch designations in traditional (\code{prime}) and Helmholtz + (\code{number}) systems} + \label{octavetable} + \begin{center} + \octavetable + \end{center} +\end{table} + +\section{Code} + +\VerbatimInput{octave.sty} + +\section{Changes} + +\begin{tabular}{r p{0.75\textwidth}} + 2017/10/31 & Spelling corrections\\ + 2017/08/21 & First version on CTAN\\ +\end{tabular} +\end{document} -- cgit v1.2.3