| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% Copyright (C) 2005-2015 by Enrico Gregorio |
| 4 |
% <Enrico dot Gregorio at univr dot it> |
| 5 |
% ------------------------------------------------------- |
| 6 |
% |
| 7 |
% This file may be distributed and/or modified under the conditions of |
| 8 |
% the LaTeX Project Public License, either version 1.2 of this license |
| 9 |
% or (at your option) any later version. The latest version of this |
| 10 |
% license is in: |
| 11 |
% |
| 12 |
% http://www.latex-project.org/lppl.txt |
| 13 |
% |
| 14 |
% and version 1.2 or later is part of all distributions of LaTeX |
| 15 |
% version 1999/12/01 or later. |
| 16 |
% |
| 17 |
% \fi |
| 18 |
% |
| 19 |
% \iffalse |
| 20 |
%<*driver> |
| 21 |
\ProvidesFile{abc.dtx} |
| 22 |
%</driver> |
| 23 |
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01] |
| 24 |
%<package>\ProvidesPackage{abc} |
| 25 |
%<*package> |
| 26 |
[2016/05/15 v2.0b Enrico Gregorio] |
| 27 |
%</package> |
| 28 |
%<*driver> |
| 29 |
\documentclass{ltxdoc} |
| 30 |
\usepackage{verbatim} |
| 31 |
\newenvironment{smallverb}{\footnotesize\verbatim}{\endverbatim} |
| 32 |
\EnableCrossrefs |
| 33 |
\CodelineIndex |
| 34 |
\RecordChanges |
| 35 |
\begin{document} |
| 36 |
\DocInput{abc.dtx} |
| 37 |
\end{document} |
| 38 |
%</driver> |
| 39 |
% \fi |
| 40 |
% |
| 41 |
% \CheckSum{416} |
| 42 |
% |
| 43 |
% \CharacterTable |
| 44 |
% {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 |
| 45 |
% 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 |
| 46 |
% Digits \0\1\2\3\4\5\6\7\8\9 |
| 47 |
% Exclamation \! Double quote \" Hash (number) \# |
| 48 |
% Dollar \$ Percent \% Ampersand \& |
| 49 |
% Acute accent \' Left paren \( Right paren \) |
| 50 |
% Asterisk \* Plus \+ Comma \, |
| 51 |
% Minus \- Point \. Solidus \/ |
| 52 |
% Colon \: Semicolon \; Less than \< |
| 53 |
% Equals \= Greater than \> Question mark \? |
| 54 |
% Commercial at \@ Left bracket \[ Backslash \\ |
| 55 |
% Right bracket \] Circumflex \^ Underscore \_ |
| 56 |
% Grave accent \` Left brace \{ Vertical bar \| |
| 57 |
% Right brace \} Tilde \~} |
| 58 |
% |
| 59 |
% \changes{v2.0b}{2016/05/15}{Use shellesc} |
| 60 |
% |
| 61 |
% \changes{v2.0a}{2015/09/09}{Fixed gobbling of leading lines that |
| 62 |
% start with \%} |
| 63 |
% |
| 64 |
% \changes{v2.0}{2008/03/03}{Many changes, in order to allow for Mup |
| 65 |
% support; added saveall and nosaveall options} |
| 66 |
% |
| 67 |
% \changes{v1.1}{2007/03/27}{Added \cs{endgroup} when the warning for |
| 68 |
% a non existent file is issued} |
| 69 |
% |
| 70 |
% \changes{v1.0}{2006/03/22}{After long delay decided to publish it} |
| 71 |
% |
| 72 |
% \changes{v0.7}{2005/11/21}{Corrected some errors from previous |
| 73 |
% version; changed `abcinput' to support keyword-value pairs like |
| 74 |
% the environment; added the production of a batch file when the |
| 75 |
% `noshellescape' option is active; improved the documentation} |
| 76 |
% |
| 77 |
% \changes{v0.7beta}{2005/11/19}{Added the `postoptions' and `width' |
| 78 |
% keywords} |
| 79 |
% |
| 80 |
% \changes{v0.6}{2005/11/18}{Changed options: erased `nix' and |
| 81 |
% `dos', added `ps2epsidos' to correct a mistake} |
| 82 |
% |
| 83 |
% \changes{v0.5}{2005/11/13}{Added the interface to keyval} |
| 84 |
% |
| 85 |
% \changes{v0.4}{2005/11/10}{Initial version; too many things changed} |
| 86 |
% |
| 87 |
% \changes{v.0.1-0.3}{2005/11/01}{Very preliminar versions} |
| 88 |
% |
| 89 |
% \GetFileInfo{abc.dtx} |
| 90 |
% |
| 91 |
% \DoNotIndex{\newcommand,\newenvironment,\def,\ifpdf,\begin} |
| 92 |
% \DoNotIndex{\DeclareOption,\ExecuteOptions,\RequirePackage} |
| 93 |
% \DoNotIndex{\renewcommand,\else,\fi,\relax,\@bsphack,\@esphack} |
| 94 |
% \DoNotIndex{\active,\AtEndOfPackage,\catcode,\centering} |
| 95 |
% \DoNotIndex{\closeout,\comment,\do,\dospecials,\end,\endcomment} |
| 96 |
% \DoNotIndex{\fbox,\gdef,\immediate,\includegraphics,\let} |
| 97 |
% \DoNotIndex{\linewidth,\message,\newif,\newwrite,\openout} |
| 98 |
% \DoNotIndex{\PackageWarning,\space,\the,\verbatim@line} |
| 99 |
% \DoNotIndex{\verbatim@processline,\verbatim@start,\write} |
| 100 |
% \DoNotIndex{\@makeother,\IfFileExists,\ProcessOptions} |
| 101 |
% \DoNotIndex{\@ifnextchar,\define@key,\MessageBreak,\setkeys} |
| 102 |
% \DoNotIndex{\stepcounter,\newcounter,\trivlist,\AtEndDocument} |
| 103 |
% \DoNotIndex{\@empty,\edef,\csname,\endcsname,\edef,\begingroup} |
| 104 |
% \DoNotIndex{\endgroup,\endtrivlist,\global,\if,\ifx,\item} |
| 105 |
% \DoNotIndex{\PackageWarningNoLine,\PassOptionsToPackage} |
| 106 |
% \DoNotIndex{\ProvidesPackage,\@arabic} |
| 107 |
% |
| 108 |
% \title{The \textsf{abc} package\thanks{This document corresponds to |
| 109 |
% \textsf{abc}~\fileversion, dated \filedate.}} |
| 110 |
% |
| 111 |
% \author{Enrico Gregorio \\ \texttt{Enrico dot Gregorio at univr dot it}} |
| 112 |
% |
| 113 |
% \date{\filedate} |
| 114 |
% |
| 115 |
% \maketitle |
| 116 |
% |
| 117 |
% \section{Introduction} |
| 118 |
% There are several ways to set music using \TeX{}, notably |
| 119 |
% Musix\TeX{} and Lilypond. Both are very powerful and, |
| 120 |
% consequently, a bit difficult to learn and to use. |
| 121 |
% |
| 122 |
% From the point of view of notation, the ABC |
| 123 |
% system\footnote{\texttt{http://staffweb.cms.gre.ac.uk/\char`\~c.walshaw/abc/}} |
| 124 |
% is much simpler. A recent extension of this language, called |
| 125 |
% ABC~Plus\footnote{\texttt{http://abcplus.sourceforge.net}}, allows |
| 126 |
% for setting multiple staves and polyphony. One of the best programs |
| 127 |
% for converting these notations into sheet music is |
| 128 |
% \texttt{abcm2ps}, which can take an ABC or ABC~Plus file and |
| 129 |
% transform it into a PostScript\texttrademark{} file. |
| 130 |
% |
| 131 |
% The purpose of this package is to allow \LaTeX{} users to include in |
| 132 |
% their documents small excerpts of music written directly in |
| 133 |
% ABC (Plus). It exploits the \verb|\write18| technique available with |
| 134 |
% the Web2C implementation of the \TeX{} system and free utilities |
| 135 |
% like \texttt{ps2eps}, \texttt{ps2epsi} and \texttt{epstopdf}. From |
| 136 |
% version 2.0b we check the existence of the \textsf{shellesc} package |
| 137 |
% in order to be compatible with Lua\TeX. |
| 138 |
% |
| 139 |
% This package can be used both with \LaTeX{} and |
| 140 |
% \textsc{pdf}\LaTeX{}, without any change in the user's source file. |
| 141 |
% It employs also the package \textsf{keyval} by David Carlisle and |
| 142 |
% ideas from the \textsf{verbatim} package in the \LaTeX{} tools. |
| 143 |
% |
| 144 |
% Martin Tarenskeen wrote me about possible support of Mup--Music |
| 145 |
% Publisher\footnote{\texttt{http://www.arkkra.com}} and actually it |
| 146 |
% was easy to add it along with some improvements partly suggested by |
| 147 |
% him. Therefore the package now comes along with a new \textsf{mup} |
| 148 |
% package; see section~\ref{mup}. I owe many thanks to Martin for |
| 149 |
% testing the new version. |
| 150 |
% |
| 151 |
% We are studying whether it is feasible to extend support also to |
| 152 |
% other music printing programs like Lilypond. |
| 153 |
% |
| 154 |
% \section{Usage} |
| 155 |
% \DescribeEnv{abc} |
| 156 |
% The only environment provided by this package is \verb|abc| with |
| 157 |
% the following syntax: |
| 158 |
% \begin{quote} |
| 159 |
% \verb|\begin{abc}[|\meta{keyword}$=$\meta{value}\verb|...]|\\ |
| 160 |
% \meta{ABC Plus material}\\ |
| 161 |
% \verb|\end{abc}| |
| 162 |
% \end{quote} |
| 163 |
% The environment should be used only in LR-mode. Its output is set |
| 164 |
% in a `center' environment. We give a list of the available |
| 165 |
% keywords. |
| 166 |
% \begin{description} |
| 167 |
% |
| 168 |
% \item[\normalfont\texttt{name=}\meta{name}:] \meta{name} is a name |
| 169 |
% for the temporary file which will be output and massaged by |
| 170 |
% \texttt{abcm2ps}. \emph{Warning}: the extension \texttt{.abc} is |
| 171 |
% automatically added to the file name; esistent files with the same |
| 172 |
% name will be silently erased. If the keyword is specified without a |
| 173 |
% value, then the output file receives a unique name. |
| 174 |
% |
| 175 |
% \item[\normalfont\texttt{options=}\meta{options}:] \meta{options} |
| 176 |
% are command line parameters to the \texttt{abcm2ps} utility; the |
| 177 |
% default are `\texttt{-O= -c}'. |
| 178 |
% |
| 179 |
% \item[\normalfont\texttt{postoptions=}\meta{postoptions}:] |
| 180 |
% \meta{postoptions} are possible command line options which, in |
| 181 |
% \texttt{abcm2ps} syntax, go after the file name. |
| 182 |
% |
| 183 |
% \item[\normalfont\texttt{program=}\meta{program}:] \meta{program} is |
| 184 |
% used to specify an alternative program to \texttt{abc2mps} (if |
| 185 |
% existent). In this case users must specify completely the command |
| 186 |
% line options, directly in \meta{program} or with \meta{options} and |
| 187 |
% \meta{postoptions}. For example |
| 188 |
% \begin{quote} |
| 189 |
% \verb|\begin[name=song,program=abctoeps,options={-a -b}]|\\ |
| 190 |
% \verb|\begin[name=song,program={abc3ps -a -b}]| |
| 191 |
% \end{quote} |
| 192 |
% (assuming there is an \texttt{abc3ps} program). |
| 193 |
% |
| 194 |
% \item[\normalfont\texttt{width=}\meta{width}:] \meta{width} should |
| 195 |
% be a dimension; it is best to express it as a fraction of |
| 196 |
% \verb|\abcwidth|. |
| 197 |
% |
| 198 |
% \item[\normalfont\texttt{center}:] This is a boolean, either true |
| 199 |
% or false; the default is true, if left flush alignment is preferred, |
| 200 |
% specify \texttt{center=false}. |
| 201 |
% |
| 202 |
% \item[\normalfont\texttt{extension}:] This keyword seems practically |
| 203 |
% useless, but is needed if one needs to input both ABC and Mup files |
| 204 |
% in one and the same document. See later on. |
| 205 |
% \end{description} |
| 206 |
% |
| 207 |
% \DescribeMacro{\abcinput} |
| 208 |
% It is also possible to input an available ABC file. The syntax is |
| 209 |
% \begin{quote} |
| 210 |
% \verb|\abcinput|\oarg{options}\marg{name} |
| 211 |
% \end{quote} |
| 212 |
% where \meta{name} is the name of the file, without the extension |
| 213 |
% which should be \texttt{.abc}. In the optional argument users can |
| 214 |
% put keyword-value pairs as for the environment. Of course the |
| 215 |
% keyword \texttt{name} is ignored here. |
| 216 |
% |
| 217 |
% \DescribeMacro{\abcwidth} |
| 218 |
% Users have a minimum control (at least in this version) on how to |
| 219 |
% include some lines of music. The only parameter they can modify is |
| 220 |
% \verb|\abcwidth| with \verb|\renewcommand|. Its normal value is |
| 221 |
% \verb|\linewidth|. The best thing to do is |
| 222 |
% \begin{quote} |
| 223 |
% \verb|\renewcommand{\abcwidth}{|\meta{fraction}\verb|\linewidth}| |
| 224 |
% \end{quote} |
| 225 |
% where \meta{fraction} is some number between $0$ and~$1$. Changing |
| 226 |
% this parameter affects every subsequent music inclusion, obeying to |
| 227 |
% the usual scoping rules. The width can be changed locally for the |
| 228 |
% environment or the command with the method explained before. |
| 229 |
% |
| 230 |
% \DescribeMacro{\normalabcoutputfile} |
| 231 |
% The name for the generic output files is ``\texttt{out-abc}''. In |
| 232 |
% the (improbable) case that some file \texttt{out-abc.}\meta{ext} is |
| 233 |
% present in the directory, users can redefine |
| 234 |
% \verb|\normalabcoutputfile| as they like. |
| 235 |
% |
| 236 |
% \section{Package options} |
| 237 |
% There are some package options, to control what is to be passed for |
| 238 |
% subsequent processing. |
| 239 |
% |
| 240 |
% \subsection{\texttt{shellescape} and \texttt{noshellescape}} |
| 241 |
% The option \texttt{shellescape} (default) means that some external |
| 242 |
% programs will be called by \LaTeX{} to get the inclusion of the |
| 243 |
% music lines. If you don't trust the automatic generation, or your |
| 244 |
% \TeX{} implementation does not allow the trick with \verb|\write18|, |
| 245 |
% then use \texttt{noshellescape}. In this case, a name should be |
| 246 |
% specified for every `abc' environment, because otherwise ABC output |
| 247 |
% files will be overwritten, since they receive the same generic name, |
| 248 |
% by default. A file named \texttt{out-abc.sh} is produced, |
| 249 |
% containing the commands to give for elaborating the music files. |
| 250 |
% |
| 251 |
% \subsection{\texttt{generate} and \texttt{nogenerate}} |
| 252 |
% With the \texttt{generate} option (default) the ABC lines will be |
| 253 |
% processed by the external programs. The \texttt{nogenerate} option |
| 254 |
% can be used when the ABC sources have not changed, in order to |
| 255 |
% increase speed. Also in this case, however, a name should be |
| 256 |
% specified for all output ABC files. |
| 257 |
% |
| 258 |
% \subsection{\texttt{ps2epsi}, \texttt{ps2epsidos} and |
| 259 |
% \texttt{ps2eps}} |
| 260 |
% The option \texttt{ps2eps} (default) means that the \texttt{ps2eps} |
| 261 |
% Perl script will be used for generating the EPS file for graphic |
| 262 |
% inclusion. Specify the \texttt{ps2epsi} option if you prefer the |
| 263 |
% \texttt{ps2epsi} program; specify \texttt{ps2epsidos} if you are on |
| 264 |
% a system where the utility \texttt{ps2epsi} generates a file with |
| 265 |
% three letter extension \texttt{.epi}. |
| 266 |
% |
| 267 |
% \subsection{\texttt{nosaveall} and \texttt{saveall}} |
| 268 |
% The first is the default, but the second is called implicitly when |
| 269 |
% the \texttt{noshellescape} is given. When the \texttt{saveall} |
| 270 |
% option is active, every `abc' environment produces a unique output |
| 271 |
% file; in other words, the \texttt{name} keyword, without value, is |
| 272 |
% given for every environment. So the \texttt{noshellescape} option |
| 273 |
% along with \texttt{generate} will not overwrite the output from |
| 274 |
% unnamed environment. It is possible that, during the document's |
| 275 |
% preparation, the numbers added to the default file name are out of |
| 276 |
% synch, the process should converge. Note that with Lua\TeX{} the |
| 277 |
% \texttt{nosaveall} option can produce errors, so \texttt{saveall} is |
| 278 |
% enabled by default, with this engine. |
| 279 |
% |
| 280 |
% |
| 281 |
% \section{Compiling documents} |
| 282 |
% Users must give the option \texttt{-shell-escape} when compiling |
| 283 |
% their documents, unless they chose the \texttt{nogenerate} package |
| 284 |
% option or the \texttt{noshellescape}. Thus one of |
| 285 |
% \begin{quote} |
| 286 |
% \texttt{latex -shell-escape} \meta{\TeX{} file name}\\ |
| 287 |
% \texttt{pdflatex -shell-escape} \meta{\TeX{} file name}\\ |
| 288 |
% \texttt{simpdftex latex --extratexopts "-shell-escape"} |
| 289 |
% \end{quote} |
| 290 |
% should be used from the command line (or equivalent way, depending |
| 291 |
% on operating system and distribution). |
| 292 |
% |
| 293 |
% \section{An example file} |
| 294 |
% \iffalse |
| 295 |
%<*example> |
| 296 |
% \fi |
| 297 |
% \begin{smallverb} |
| 298 |
\documentclass[a4paper,12pt]{article} |
| 299 |
\usepackage[generate,ps2eps]{abc} |
| 300 |
\usepackage{mathptmx} |
| 301 |
|
| 302 |
\begin{document} |
| 303 |
|
| 304 |
\title{Example of ABC Plus in \LaTeX{}} |
| 305 |
\author{Guido Gonzato} |
| 306 |
\date{} |
| 307 |
\maketitle |
| 308 |
|
| 309 |
This is a short piece. |
| 310 |
|
| 311 |
\medskip |
| 312 |
|
| 313 |
\begin{abc} |
| 314 |
X:4 |
| 315 |
T:Cronin's Hornpipe |
| 316 |
R:hornpipe |
| 317 |
S:Keenan and Glackin |
| 318 |
E:7 |
| 319 |
M:C| |
| 320 |
L:1/8 |
| 321 |
K:G |
| 322 |
BA|GABc dBde|gage dega|bage dBGB|cABG A2BA|! |
| 323 |
GABc dBde|gage dega|bage dBAB|G2G2 G2:|! |
| 324 |
fg|afd^c d2ga|bged e2ga|(3bag (3agf gedB|(3cBA AG AcBA|! |
| 325 |
GABc dBde|~g3e dega|bage dBAB|G2G2 G2:|! |
| 326 |
\end{abc} |
| 327 |
|
| 328 |
\medskip |
| 329 |
|
| 330 |
This is another short piece, but we would like to keep the |
| 331 |
ABC source in our directory. |
| 332 |
|
| 333 |
\begin{abc}[name=jacky] |
| 334 |
X:9 |
| 335 |
T:Jacky Tar |
| 336 |
R:hornpipe |
| 337 |
M:4/4 |
| 338 |
L:1/8 |
| 339 |
K:Edor |
| 340 |
(Bd) | "Em" e2 ed efge | "G" d2 B2 B2 (dB) | "D" ABde faef | d2 A2 A2 (Bd) | |
| 341 |
"Em" e2 ef g2 fe | "G" dB GB d2 (cB) | "D" AGFE DEFA | "Em" G2 E2 E2 :| |
| 342 |
(GA) | "Em" BGEG BGEG | BAGF E2 (FG) | "D" BGEG BGEG | AGFE D2 (EF) | |
| 343 |
"G" GFGB g2 (fe) | dBGB d2 (cB) | "D" AGFE DEFA | "Em" G2 E2 E2 :| |
| 344 |
\end{abc} |
| 345 |
|
| 346 |
\clearpage |
| 347 |
|
| 348 |
And, finally, we want to set also the last piece; its ABC code |
| 349 |
is already in our directory. |
| 350 |
|
| 351 |
\medskip |
| 352 |
|
| 353 |
\abcinput{poll} |
| 354 |
|
| 355 |
\end{document} |
| 356 |
% \end{smallverb} |
| 357 |
% \iffalse |
| 358 |
%</example> |
| 359 |
% \fi |
| 360 |
% |
| 361 |
% This file is accompanied by a file \texttt{poll.abc} |
| 362 |
% \iffalse |
| 363 |
%<*abc> |
| 364 |
% \fi |
| 365 |
% \begin{smallverb} |
| 366 |
X:12 |
| 367 |
T:Poll Ha'penny |
| 368 |
T:Garra\'i na bhF\'eile\'og |
| 369 |
R:hornpipe |
| 370 |
H:The Irish title means "The Garden of Honeysuckles" |
| 371 |
D:Mary Bergin: Feadoga Stain |
| 372 |
D:Noel Hill agus Tony McMahon: I gCnoc na Grai |
| 373 |
Z:id:hn-hornpipe-26 |
| 374 |
M:C| |
| 375 |
L:1/8 |
| 376 |
K:Amix |
| 377 |
(3GAB | =cAAG A2 (3AB=c | (3d=cB (3AGF G2 (3B^cd | ed^cA d^cAG | ~A3 G A2 de | |
| 378 |
~f3 d ~e3 c | d2 (3Bcd efge | aged (3=cBA GB | ~A3 G A2:| |
| 379 |
|: ef | ~g3 f gfef | g2 ga gedg | eaag a3 g | eaag a2 ag | |
| 380 |
~f3 d ~e3 c | d2 (3Bcd efge | aged (3=cBA GB | ~A3 G A2 :| |
| 381 |
% \end{smallverb} |
| 382 |
% \iffalse |
| 383 |
%</abc> |
| 384 |
% \fi |
| 385 |
% |
| 386 |
% \section{Mup support}\label{mup} |
| 387 |
% Everything we have said about ABC translates verbatim for Mup. |
| 388 |
% Simply call the package with |
| 389 |
% \iffalse |
| 390 |
%<*verb> |
| 391 |
% \fi |
| 392 |
\begin{verbatim} |
| 393 |
\usepackage{mup} |
| 394 |
\end{verbatim} |
| 395 |
% \iffalse |
| 396 |
%</verb> |
| 397 |
% \fi |
| 398 |
|
| 399 |
% with options just like before, and substitute the string `mup' to |
| 400 |
% every occurrence of `abc' in the preceding sections. The only |
| 401 |
% differences are in the default command line options when calling the |
| 402 |
% external program (they are \texttt{-F} for `mup'). |
| 403 |
% |
| 404 |
% It is even possible to use both external programs in the same |
| 405 |
% document. If this is desired, call the \textsf{abc} package and |
| 406 |
% define a new environment for Mup inclusion as follows |
| 407 |
% \iffalse |
| 408 |
%<*verb> |
| 409 |
% \fi |
| 410 |
\begin{verbatim} |
| 411 |
\newenvironment{mup}[1][] |
| 412 |
{\renewcommand{\normalabcoutputfile}{out-mup}% |
| 413 |
\abc[program=mup,options={-F},extension=mup,#1]} |
| 414 |
{\endabc} |
| 415 |
\newcommand{\mupinput}[2][]{% |
| 416 |
\abcinput[program=mup,options={-F},extension=mup,#1]{#2}} |
| 417 |
\end{verbatim} |
| 418 |
% \iffalse |
| 419 |
%</verb> |
| 420 |
% \fi |
| 421 |
% |
| 422 |
% Here is an example with Mup. |
| 423 |
% |
| 424 |
% \iffalse |
| 425 |
%<*example-mup> |
| 426 |
% \fi |
| 427 |
% \begin{smallverb} |
| 428 |
\documentclass[a4paper,12pt]{article} |
| 429 |
\usepackage[generate,ps2eps]{mup} |
| 430 |
\usepackage{mathptmx} |
| 431 |
|
| 432 |
\begin{document} |
| 433 |
|
| 434 |
\title{Example of MUP in \LaTeX{}} |
| 435 |
\author{Martin Tarenskeen} |
| 436 |
\date{} |
| 437 |
\maketitle |
| 438 |
|
| 439 |
This is a short piece. |
| 440 |
|
| 441 |
\medskip |
| 442 |
|
| 443 |
\begin{mup} |
| 444 |
1: a-;b-;c;d; |
| 445 |
bar |
| 446 |
1: e;f;g;a; |
| 447 |
endbar |
| 448 |
\end{mup} |
| 449 |
|
| 450 |
\medskip |
| 451 |
|
| 452 |
This is another short piece, but we would like to keep the |
| 453 |
MUP source in our directory. |
| 454 |
|
| 455 |
\begin{mup}[name=mymup] |
| 456 |
score |
| 457 |
staffs=2 |
| 458 |
time=6/8 |
| 459 |
beamstyle=4.,4. |
| 460 |
|
| 461 |
staff 2 |
| 462 |
clef=bass |
| 463 |
|
| 464 |
music |
| 465 |
1: 8c;d;e;f;g;a; |
| 466 |
2: 4.ceg;cfa; |
| 467 |
repeatend |
| 468 |
|
| 469 |
\end{mup} |
| 470 |
|
| 471 |
\clearpage |
| 472 |
|
| 473 |
And finally, we want to set also the last piece; its MUP code |
| 474 |
is already in our directory. |
| 475 |
|
| 476 |
\medskip |
| 477 |
|
| 478 |
\mupinput{simple} |
| 479 |
|
| 480 |
\end{document} |
| 481 |
% \end{smallverb} |
| 482 |
% \iffalse |
| 483 |
%</example-mup> |
| 484 |
% \fi |
| 485 |
% This file is accompanied by a file \texttt{simple.mup} |
| 486 |
% \iffalse |
| 487 |
%<*mup> |
| 488 |
% \fi |
| 489 |
% \begin{smallverb} |
| 490 |
score |
| 491 |
staffs=2 |
| 492 |
time=6/8 |
| 493 |
beamstyle=4.,4. |
| 494 |
|
| 495 |
staff 2 |
| 496 |
clef=bass |
| 497 |
|
| 498 |
music |
| 499 |
1: 8c;d;e;f;g;a; |
| 500 |
2: 4.ceg;cfa; |
| 501 |
repeatend |
| 502 |
% \end{smallverb} |
| 503 |
% \iffalse |
| 504 |
%</mup> |
| 505 |
% \fi |
| 506 |
% |
| 507 |
% \StopEventually{\PrintChanges\PrintIndex} |
| 508 |
% |
| 509 |
% \section{The implementation} |
| 510 |
% After the usual stuff of package presentation, here are the actual |
| 511 |
% macros. To begin with the option declarations and the defaults. |
| 512 |
% The first options are boolean. |
| 513 |
% \begin{macrocode} |
| 514 |
%<*package> |
| 515 |
\RequirePackage{ifluatex} |
| 516 |
\newif\ifabc@shellescape |
| 517 |
\newif\ifabc@generate |
| 518 |
\newif\ifabc@warning |
| 519 |
\newif\ifabc@saveall |
| 520 |
\newif\ifabc@mup |
| 521 |
\DeclareOption{mup}{\abc@muptrue} |
| 522 |
\DeclareOption{noshellescape}{\abc@shellescapefalse\abc@warningtrue |
| 523 |
\abc@savealltrue} |
| 524 |
\DeclareOption{shellescape}{\abc@shellescapetrue} |
| 525 |
\DeclareOption{nogenerate}{\abc@generatefalse} |
| 526 |
\DeclareOption{generate}{\abc@generatetrue} |
| 527 |
\DeclareOption{nosaveall}{\abc@saveallfalse} |
| 528 |
\DeclareOption{saveall}{\abc@savealltrue} |
| 529 |
% \end{macrocode} |
| 530 |
% The following options control the external programs to use. |
| 531 |
% \begin{macrocode} |
| 532 |
\def\abc@epsext{eps} |
| 533 |
\DeclareOption{ps2eps}{\def\abc@pscmd{ps2eps -f}} |
| 534 |
\DeclareOption{ps2epsi}{\def\abc@pscmd{ps2epsi}\def\abc@epsext{epsi}} |
| 535 |
\DeclareOption{ps2epsidos}{\def\abc@pscmd{ps2epsi}\def\abc@epsext{epi}} |
| 536 |
% \end{macrocode} |
| 537 |
% Now we declare the default options and call the user specified |
| 538 |
% ones. Since Lua\TeX{} doesn't accept loading different PDF files |
| 539 |
% with the same name, when this engine is used, the \texttt{saveall} |
| 540 |
% option is enabled by default. |
| 541 |
% \begin{macrocode} |
| 542 |
\ExecuteOptions{generate,shellescape,nosaveall,ps2eps} |
| 543 |
\ifluatex |
| 544 |
\ExecuteOptions{saveall} |
| 545 |
\fi |
| 546 |
\ProcessOptions\relax |
| 547 |
% \end{macrocode} |
| 548 |
% |
| 549 |
% Then we have to load some packages we need. The first one is to do |
| 550 |
% verbatim output to a file without reinventing the wheel. Then the |
| 551 |
% package for implementing keyword-value options; we have to take care |
| 552 |
% of graphics inclusion, and to control whether we are using \LaTeX{} |
| 553 |
% with DVI or PDF output. |
| 554 |
% \begin{macrocode} |
| 555 |
\RequirePackage{verbatim} |
| 556 |
\RequirePackage{keyval} |
| 557 |
\RequirePackage{graphicx} |
| 558 |
\RequirePackage{ifpdf} |
| 559 |
% \end{macrocode} |
| 560 |
% Next we define some internal commands. First of all a boolean for |
| 561 |
% issuing messages if necessary and a counter to assign unique names |
| 562 |
% to output files |
| 563 |
% \begin{macrocode} |
| 564 |
\newif\ifabc@unprocessedfiles |
| 565 |
\newcounter{abc@count} |
| 566 |
% \end{macrocode} |
| 567 |
% We choose to give explicitly the extensions to the graphics files, |
| 568 |
% since some user could prefer \texttt{ps2epsi}. Everything is |
| 569 |
% doubled for Mup support. |
| 570 |
% \begin{environment}{mup} |
| 571 |
% \begin{macro}{\mupinput} |
| 572 |
% \begin{macrocode} |
| 573 |
\ifabc@mup |
| 574 |
\newcommand{\abc@cmd}{mup} % virtually no choice |
| 575 |
\newcommand{\abc@parm}{-F} % -F MUST stay |
| 576 |
\newcommand{\abc@epstopdfcmd}{epstopdf} |
| 577 |
\newcommand{\abc@pdfext}{pdf} |
| 578 |
\def\normalabcoutputfile{out-mup} |
| 579 |
\def\normalmupoutputfile{\normalabcoutputfile} |
| 580 |
\def\mup{\abc} |
| 581 |
\def\endmup{\endabc} |
| 582 |
\def\mupinput{\abcinput} |
| 583 |
\def\abc@ext{.mup} |
| 584 |
\def\abc@packagename{mup} |
| 585 |
\else |
| 586 |
\newcommand{\abc@cmd}{abcm2ps} % virtually no choice |
| 587 |
\newcommand{\abc@parm}{-O= -c} % -O= MUST stay |
| 588 |
\newcommand{\abc@epstopdfcmd}{epstopdf} |
| 589 |
\newcommand{\abc@pdfext}{pdf} |
| 590 |
\def\normalabcoutputfile{out-abc} |
| 591 |
\def\abc@ext{.abc} |
| 592 |
\def\abc@packagename{abc} |
| 593 |
\fi |
| 594 |
\def\abc@tempfile{\normalabcoutputfile} |
| 595 |
\def\abc@opt{} |
| 596 |
\let\abc@postopt\@empty |
| 597 |
\ifpdf |
| 598 |
\let\abc@finalext\abc@pdfext |
| 599 |
\else |
| 600 |
\let\abc@finalext\abc@epsext |
| 601 |
\fi |
| 602 |
\newif\ifabc@center |
| 603 |
\abc@centertrue |
| 604 |
% \end{macrocode} |
| 605 |
% \end{macro} |
| 606 |
% \end{environment} |
| 607 |
% The following is the only parameter the user is authorized to |
| 608 |
% tamper with; it has an alias for Mup. |
| 609 |
% \begin{macrocode} |
| 610 |
\newcommand{\abcwidth}{\linewidth} % only fractions of \linewidth |
| 611 |
\let\mupwidth\abcwidth |
| 612 |
% \end{macrocode} |
| 613 |
% \begin{macro}{\abc@startgen} |
| 614 |
% \begin{macro}{\abc@finishgen} |
| 615 |
% Now something directly borrowed from the package \textsf{verbatim}. |
| 616 |
% We declare an output stream and define two macros which will be |
| 617 |
% called by the \texttt{abc} environment or by the \verb|\abcinput| |
| 618 |
% command in case we are generating the graphics files. The macro |
| 619 |
% \verb|\abc@startgen| then passes the control to \verb|\abc@process| |
| 620 |
% which is different, according to the options given to the package. |
| 621 |
% \begin{macrocode} |
| 622 |
\newwrite\abc@out |
| 623 |
\def\abc@startgen{% |
| 624 |
\@bsphack |
| 625 |
\immediate\openout\abc@out\abc@tempfile\abc@ext |
| 626 |
\let\do\@makeother\dospecials |
| 627 |
\catcode`\^^M\active \catcode`\^^I=12 |
| 628 |
\def\verbatim@processline{% |
| 629 |
\immediate\write\abc@out |
| 630 |
{\the\verbatim@line}}% |
| 631 |
\verbatim@start} |
| 632 |
\def\abc@finishgen{% |
| 633 |
\immediate\closeout\abc@out |
| 634 |
\@esphack |
| 635 |
\abc@process |
| 636 |
} |
| 637 |
% \end{macrocode} |
| 638 |
% \end{macro} |
| 639 |
% \end{macro} |
| 640 |
% \begin{macro}{\abc@doshellcommand} |
| 641 |
% \begin{macro}{\abc@nodoshellcommand} |
| 642 |
% We define a macro for the external massaging of the ABC files and |
| 643 |
% another one for the case the user doesn't trust or have available |
| 644 |
% the \verb|\write18| trick; the second one spits out a very simple |
| 645 |
% shell script which can be used to take care of the compilation; this |
| 646 |
% file is probably compatible with all systems having a command line |
| 647 |
% interface. Then we check the options again and define the commands |
| 648 |
% that really do the job. |
| 649 |
% \begin{macrocode} |
| 650 |
\ifluatex |
| 651 |
\IfFileExists{shellesc.sty} |
| 652 |
{\RequirePackage{shellesc}\let\abc@shell\ShellEscape} |
| 653 |
{\def\abc@shell{\immediate\write18}} |
| 654 |
\else |
| 655 |
\def\abc@shell{\immediate\write18} |
| 656 |
\fi |
| 657 |
\def\abc@doshellcommand{% |
| 658 |
\abc@shell{% |
| 659 |
\ifabc@mup |
| 660 |
\abc@cmd\space |
| 661 |
\abc@opt\space |
| 662 |
\abc@parm\space |
| 663 |
\abc@tempfile\abc@ext\space |
| 664 |
\else |
| 665 |
\abc@cmd\space |
| 666 |
\abc@parm\space |
| 667 |
\abc@opt\space |
| 668 |
\abc@tempfile\abc@ext\space |
| 669 |
\fi |
| 670 |
\ifx\abc@postopt\@empty |
| 671 |
\else\space\abc@postopt\fi |
| 672 |
}% |
| 673 |
\abc@shell{% |
| 674 |
\abc@pscmd\space\[email protected] |
| 675 |
}% |
| 676 |
\ifpdf |
| 677 |
\abc@shell{% |
| 678 |
\abc@epstopdfcmd\space\abc@tempfile.\abc@epsext |
| 679 |
}% |
| 680 |
\fi |
| 681 |
} |
| 682 |
\def\abc@nodoshellcommand{% |
| 683 |
\immediate\write\abc@outsh{% |
| 684 |
\abc@cmd\space |
| 685 |
\abc@parm\space |
| 686 |
\abc@opt\space |
| 687 |
\abc@tempfile\abc@ext\space |
| 688 |
\ifx\abc@postopt\@empty |
| 689 |
\else\space\abc@postopt\fi}% |
| 690 |
\immediate\write\abc@outsh{% |
| 691 |
\abc@pscmd\space\[email protected]}% |
| 692 |
\ifpdf |
| 693 |
\immediate\write\abc@outsh{% |
| 694 |
\abc@epstopdfcmd\space\abc@tempfile.\abc@epsext}% |
| 695 |
\fi |
| 696 |
} |
| 697 |
% \end{macrocode} |
| 698 |
% We use a conditional to emit a message at the end of the |
| 699 |
% compilation if some file has not been found and the |
| 700 |
% \texttt{nogenerate} option was chosen. |
| 701 |
% \begin{macrocode} |
| 702 |
\AtEndDocument{% |
| 703 |
\ifabc@warning\ifabc@unprocessedfiles |
| 704 |
\PackageWarningNoLine{\abc@packagename}{% |
| 705 |
\ifabc@shellescape |
| 706 |
You have set the `shellescape' option, but you ran% |
| 707 |
\MessageBreak |
| 708 |
(pdf)latex without the `-shell-escape' command line% |
| 709 |
\MessageBreak |
| 710 |
option. Fix it either with the `noshellescape' option% |
| 711 |
\MessageBreak |
| 712 |
in your document or the correct call of (pdf)latex% |
| 713 |
\else |
| 714 |
Remember to generate the [eps,pdf] files before compiling% |
| 715 |
\MessageBreak |
| 716 |
again. Use the file \[email protected] for a list or as a script% |
| 717 |
\fi}% |
| 718 |
\fi\fi} |
| 719 |
% \end{macrocode} |
| 720 |
% \end{macro} |
| 721 |
% \end{macro} |
| 722 |
% Now we define the macro responsible for the massaging of the ABC |
| 723 |
% files. This is a good moment for inizializing the writing of the |
| 724 |
% shell script, when needed. |
| 725 |
% \begin{macro}{\abc@process} |
| 726 |
% \begin{macrocode} |
| 727 |
\ifabc@shellescape |
| 728 |
\let\abc@process\abc@doshellcommand |
| 729 |
\else |
| 730 |
\newwrite\abc@outsh |
| 731 |
\immediate\openout\abc@outsh\[email protected] |
| 732 |
\AtEndDocument{\closeout\abc@outsh} |
| 733 |
\let\abc@process\abc@nodoshellcommand |
| 734 |
\fi |
| 735 |
% \end{macrocode} |
| 736 |
% \end{macro} |
| 737 |
% \begin{macro}{\abc@start} |
| 738 |
% \begin{macro}{\abc@finish} |
| 739 |
% We now define how to start and finish; if no generation is required, |
| 740 |
% the ABC lines are skipped like a comment (thanks again to the |
| 741 |
% \textsf{verbatim} package). |
| 742 |
% \begin{macrocode} |
| 743 |
\ifabc@generate |
| 744 |
\let\abc@start\abc@startgen |
| 745 |
\let\abc@finish\abc@finishgen |
| 746 |
\else |
| 747 |
\let\abc@start\comment |
| 748 |
\let\abc@finish\endcomment |
| 749 |
\fi |
| 750 |
% \end{macrocode} |
| 751 |
% \end{macro} |
| 752 |
% \end{macro} |
| 753 |
% \begin{environment}{abc} |
| 754 |
% \begin{macro}{\abcinput} |
| 755 |
% Finally, we define the environment and the command. Some commands |
| 756 |
% are initialized here; the name of the temporary file is, by default, |
| 757 |
% ``out-abc'' which should not clobber any existing file. |
| 758 |
% \begin{macrocode} |
| 759 |
\def\abc{\@makeother\%\@ifnextchar[\abc@grab{\abc@grab[]}} |
| 760 |
\define@key{abc}{name}[]{% |
| 761 |
\if!#1!\stepcounter{abc@count}% |
| 762 |
\edef\abc@tempfile{\normalabcoutputfile-\@arabic\c@abc@count}% |
| 763 |
\else |
| 764 |
\def\abc@tempfile{#1}% |
| 765 |
\fi |
| 766 |
} |
| 767 |
\define@key{abc}{options}{\def\abc@opt{#1}} |
| 768 |
\define@key{abc}{postoptions}{\def\abc@postopt{#1}} |
| 769 |
\define@key{abc}{program}{\def\abc@cmd{#1}\let\abc@parm\@empty} |
| 770 |
\define@key{abc}{width}{\def\abc@width{#1}} |
| 771 |
\define@key{abc}{center}[true]{\csname abc@center#1\endcsname} |
| 772 |
\define@key{abc}{extension}{\def\abc@ext{.#1}} |
| 773 |
\def\abc@grab[#1]{\let\abc@width=\abcwidth |
| 774 |
\ifabc@saveall |
| 775 |
\setkeys{abc}{name,#1}% |
| 776 |
\else |
| 777 |
\setkeys{abc}{#1}% |
| 778 |
\fi\abc@start} |
| 779 |
% \end{macrocode} |
| 780 |
% The final part of the environment; we do the processing, if |
| 781 |
% required and then include the graphics file. If none is found, the |
| 782 |
% simple name is used, to recall that some processing is to be done. |
| 783 |
% \begin{macrocode} |
| 784 |
\def\endabc{% |
| 785 |
\abc@finish |
| 786 |
\trivlist\item[]\ifabc@center\centering\fi |
| 787 |
\IfFileExists{\abc@tempfile.\abc@finalext} |
| 788 |
{\includegraphics[width=\abc@width]{\abc@tempfile.\abc@finalext}}% |
| 789 |
{\global\abc@warningtrue\fbox{\abc@tempfile}% |
| 790 |
\global\abc@unprocessedfilestrue}% |
| 791 |
\endtrivlist |
| 792 |
} |
| 793 |
% \end{macrocode} |
| 794 |
% The command version is similar. The only difference is that we |
| 795 |
% issue a warning if the named file does not exist. |
| 796 |
% \begin{macrocode} |
| 797 |
\def\abcinput{\@ifnextchar[\abc@grabinput{\abc@grabinput[]}} |
| 798 |
\def\abc@grabinput[#1]#2{\let\abc@width=\abcwidth\setkeys{abc}{#1}% |
| 799 |
\begingroup\def\abc@tempfile{#2}% |
| 800 |
\IfFileExists{\abc@tempfile\abc@ext} |
| 801 |
{% |
| 802 |
\abc@process |
| 803 |
\begin{center} |
| 804 |
\IfFileExists{\abc@tempfile.\abc@finalext} |
| 805 |
{\includegraphics[width=\abc@width]{\abc@tempfile.\abc@finalext}}% |
| 806 |
{\fbox{\abc@tempfile}}% |
| 807 |
\end{center}% |
| 808 |
\endgroup |
| 809 |
} |
| 810 |
{\PackageWarning{\abc@packagename}{No file \abc@tempfile\abc@ext\space found}}% |
| 811 |
} |
| 812 |
%</package> |
| 813 |
% \end{macrocode} |
| 814 |
% \end{macro} |
| 815 |
% \end{environment} |
| 816 |
% \begin{macrocode} |
| 817 |
%<*package-mup> |
| 818 |
\ProvidesPackage{mup} |
| 819 |
\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{abc}} |
| 820 |
\ProcessOptions\relax |
| 821 |
\RequirePackage[mup]{abc} |
| 822 |
%</package-mup> |
| 823 |
% \end{macrocode} |
| 824 |
% \Finale |