% mtxlatex.sty: Macro package to make music scores using Latex
%   or produce LaTeX documents containing music examples
%   Dirk Laurie  dlaurie@na-net.ornl.gov  2001-12-27
%   Update: see \mtxdate below
% Some comments on usage appear at the bottom
\ifx\mtxlatex\undefined\else\endinput\fi
\def\mtxlatexdate{20 October 2016}
\immediate\write10{%
mtxLaTeX\space<\mtxlatexdate>}

\usepackage{etex}

\def\MTx{\mbox{\textbf{\textsl{M-Tx}}}}
\def\PMX{\textbf{PMX}}
\def\musixlyr{\texttt{\textbf{musixlyr}}}

\input musixtex
\input musixltx

%  Preamble TeX commands for documents that contain .ex files
%   generated by M-Tx/PMX

\def\mtxlatex{
\input mtx
\renewcommand{\BIGfont}{\Huge\bfseries}
\renewcommand{\Bigfont}{\Large\bfseries} 
% Kill the PMX definition of \parskip.
\parskip=0pt plus 1pt
}
% Extra vertical space evenly spread between systems
\renewcommand\alaligne{\stoppiece\vfill\contpiece}
\def\scoreheight{\textheight 270mm}
\def\scorewidth{\textwidth 193mm}

\newcommand{\startscore}{\let\SmuF\startmuflex\let\EmuF\endmuflex
\scorewidth\scoreheight
\oddsidemargin -15mm\evensidemargin -15mm\topmargin -20mm
\ifx\mysizes\undefined\else\mysizes\fi
\let\startmuflex\relax\let\endmuflex\relax\let\bye\relax%
\let\nopagenumbers\relax\musicparskip}
\newcommand\headingandcontents[1]{\markboth{#1}{#1}\addcontentsline{toc}
  {section}{\protect\numberline{}{#1}}}

% The environment 'Score' is suitable for scores submitted to the
% Werner Icking music archive
\newenvironment{Score}[2]{\headingandcontents{#1}
\startscore\input #2
}{\markboth{}{}}

% The environment 'score' requires you to do your own input
\newenvironment{score}{\startscore}{}

\newenvironment{excerpts}{
\newlength\keepOSM\setlength\keepOSM\oddsidemargin
\newlength\keepTM\setlength\keepTM\topmargin
\global\setlength\oddsidemargin{-13mm} \global\setlength\topmargin{-20mm}
\let\startmuflex\relax\let\endmuflex\relax
\let\nopagenumbers\relax \let\bye\relax \let\vfill\relax \let\eject\relax
\musicparskip
\renewcommand{\BIGfont}{\Large\bfseries}
\renewcommand{\Bigfont}{\large\bfseries}
}{\global\setlength\oddsidemargin\keepOSM\global\setlength\topmargin\keepTM}

\newenvironment{mus}%
{\begin{minipage}{260mm}\startscore\musicparskip}%
{\assignlyrics1{}\assignlyrics2{}%
\gdef\mtxTitle{}\end{minipage}}

\def\example#1#2#3#4#5#6#7#8{
\noindent\begin{minipage}[t]{#3}
\begin{mus} \vskip #6
\input{#1.tex}
\end{mus}
\end{minipage}\hskip #4
\begin{minipage}[#7]{#5} \vskip #8
\verbatiminput{#1.#2}
\end{minipage}}

\mtxlatex

\endinput

============================================================================

\example{basename}{ext}
        {musicwidth}{separation}{codewidth}
        {musicvskip}{alignment}{codevskip}

Set music example together with M-Tx (or other) code.

basename   - musicfile is basename.tex
ext        - codefile is basename.ext
separation - distance between music and code minipages
alignment  - c, t or b (for code minipage)
