2

It is needed to implement bar numbering below each measure. The basic code is as follow:

\documentclass[tikz,border=3mm]{standalone}
\usepackage[top=3cm, bottom=2.8cm, left=2.5cm, right=0.5cm, marginparwidth=0cm, marginparsep=0cm, headheight=13.6pt, a4paper]{geometry}
\usepackage[T1]{fontenc}
\usepackage{polyglossia}
\setmainlanguage{spanish}

\usepackage{musixtex}

\begin{document} \vspace{5cm} \begin{music} \font\A=phvb8t at 8pt% added for letter type. \font\B=phvb8t at 8pt% added for letter type. \setclef1\treble % Clave de Sol para el Instrumento 1 \nostartrule % Inicia sin barra vertical \generalmeter{\meterfrac{4}4} \hbox to\hsize\bgroup\vbox\bgroup\hsize=4.2in % specify length of left segment \startpiece \def\fontbarno{\B\bf\scriptsize} \Notes\hu{gg}\en\bar \znotes\zcn{s}{\hspace{0.12cm}\bf\A To Coda}\en \Notes\qu{gg}\hu{g}\en\bar \znotes\hspace{-0.25cm}\coda q\en \notes\qu{g}\Dqbu gg\qu{gg}\en\bar \znotes\ccn{s}{\hspace{+3.7cm}\bf\A D.C. al Coda}\en \NOtes\qu{g}\qp\hp\en \setdoublebar \endpiece% Se finaliza el fragmento musical \egroup\hfill\vbox\bgroup\hsize=2.2in \startbarno=5 \startpiece \def\fontbarno{\B\bf\scriptsize} \znotes\coda o\en \notes\qu{gg}\hu{g}\en\bar \notes\hu{gg}\en\bar \Notes\wh{g}\en\setdoubleBAR\endpiece \egroup\egroup% close open \bgroups \end{music}

\end{document}

The current output is as follow: current

The desired output is as follow: desired

ABV
  • 611

2 Answers2

5

I studied paragraphs 13.1 and 13.2 of the MusiXTeX manual and then experimented with the parameters. In normal bar numbering there does not seem to be defined a hight, and neither \raise nor \lift seems to work. Therefore I tried a MusiXTeX tool. After \begin{document} I inserted

\def\writethebarno{\zcharnote E{\fontbarno\the\barno}}%added to lower the bar number

You can adapt the hight by changing the E to any note you want. With XeLaTeX I get the attached result. The only thing I did not yet find out is how to make the first bar number visible. enter image description here

I continued to try and found a way to show the number of the first bar. I also added some %, because your lines do not end properly, even after musixflx. I moved some of your code. Therefore I put the entire code here and replace the screenshot.

\documentclass[tikz,border=3mm]{standalone}
\usepackage[top=3cm, bottom=2.8cm, left=2.5cm, right=0.5cm, marginparwidth=0cm, marginparsep=0cm, headheight=13.6pt, a4paper]{geometry}
\usepackage[T1]{fontenc}
\usepackage{polyglossia}
\setmainlanguage{spanish}

\usepackage{musixtex}

\begin{document} \def\writethebarno{\zcharnote E{\fontbarno\the\barno}}%added to lower the bar numbers \vspace{5cm}% \begin{music}% \font\A=phvb8t at 8pt% added for letter type. \font\B=phvb8t at 8pt% added for letter type. \setclef1\treble % Clave de Sol para el Instrumento 1 \nostartrule % Inicia sin barra vertical \generalmeter{\meterfrac{4}4}% \hbox to\hsize\bgroup\vbox\bgroup\hsize=4.2in % specify length of left segment \startpiece \def\fontbarno{\B\bf\scriptsize}% %\writethebarno% \Notes\zcharnote o{\kern-4pt{\writethebarno}}\hu{gg}\en\bar%activate number of first bar \znotes\zcn{s}{\hspace{0.12cm}\bf\A To Coda}\en \Notes\qu{gg}\hu{g}\en\bar \znotes\hspace{-0.25cm}\coda q\en \notes\qu{g}\Dqbu gg\qu{gg}\en\bar % \znotes\ccn{s}{\hspace{+3.7cm}\bf\A D.C. al Coda}\en \NOtes\qu{g}\qp\ccn{s}{\bf\A D.C. al Coda}\hp\en% put the coda where it belongs as ccn \setdoublebar \endpiece% Se finaliza el fragmento musical \egroup\hfill\vbox\bgroup\hsize=2.2in% \startbarno=5% \startpiece \def\fontbarno{\B\bf\scriptsize} \znotes\coda o\zcharnote o{\kern-4pt{\writethebarno}}\en% activate number of first bar \notes\qu{gg}\hu{g}\en\bar \notes\hu{gg}\en\bar \Notes\wh{g}\en\setdoubleBAR\endpiece \egroup\egroup% close open \bgroups \end{music}

\end{document}

enter image description here

C. Peters
  • 1,297
3

One part done: lowering the bar numbers:

lowered numbers

MWE

\documentclass[tikz,border=3mm]{standalone}
\usepackage[top=3cm, bottom=2.8cm, left=2.5cm, right=0.5cm, marginparwidth=0cm, marginparsep=0cm, headheight=13.6pt, a4paper]{geometry}
\usepackage[T1]{fontenc}
\usepackage{polyglossia}
\setmainlanguage{spanish}

\usepackage{xcolor}

\usepackage{musixtex}

\begin{document} \vspace{5cm} \begin{music} \makeatletter \def\writethebarno{\raisebox{-16\internote}{{\color{red}\fontbarno\large\the\barno\kernm\qn@width}}} \makeatother \font\A=phvb8t at 8pt% added for letter type. \font\B=phvb8t at 8pt% added for letter type. \setclef1\treble % Clave de Sol para el Instrumento 1 \nostartrule % Inicia sin barra vertical \generalmeter{\meterfrac{4}4} \hbox to\hsize\bgroup\vbox\bgroup\hsize=4.2in % specify length of left segment \startpiece \def\fontbarno{\B\bf\scriptsize} \Notes\hu{gg}\en\bar \znotes\zcn{s}{\hspace{0.12cm}\bf\A To Coda}\en \Notes\qu{gg}\hu{g}\en\bar \znotes\hspace{-0.25cm}\coda q\en \notes\qu{g}\Dqbu gg\qu{gg}\en\bar \znotes\ccn{s}{\hspace{+3.7cm}\bf\A D.C. al Coda}\en \NOtes\qu{g}\qp\hp\en \setdoublebar \endpiece% Se finaliza el fragmento musical \egroup\hfill\vbox\bgroup\hsize=2.2in \startbarno=5 \startpiece \def\fontbarno{\B\bf\scriptsize} \znotes\coda o\en \notes\qu{gg}\hu{g}\en\bar \notes\hu{gg}\en\bar \Notes\wh{g}\en\setdoubleBAR\endpiece \egroup\egroup% close open \bgroups \end{music}

\end{document}


Edit

Raw first bar number:

raw barno

MWE

\documentclass[tikz,border=3mm]{standalone}
\usepackage[top=3cm, bottom=2.8cm, left=2.5cm, right=0.5cm, marginparwidth=0cm, marginparsep=0cm, headheight=13.6pt, a4paper]{geometry}
\usepackage[T1]{fontenc}
\usepackage{polyglossia}
\setmainlanguage{spanish}

\usepackage{xcolor}

\usepackage{musixtex}

    \makeatletter
    \def\piece@beginb{\advance\line@width-\parindent \s@indent\parindent

\writ@staffs \writ@names \wbarno@x\advance\line@width\parindent} \def\writethebarno{\raisebox{-16\internote}{{\color{red}\fontbarno\large\the\barno\kernm\qn@width}}} \makeatother

\begin{document} \vspace{5cm} \begin{music} \font\A=phvb8t at 8pt% added for letter type. \font\B=phvb8t at 8pt% added for letter type. \setclef1\treble % Clave de Sol para el Instrumento 1 \nostartrule % Inicia sin barra vertical \generalmeter{\meterfrac{4}4} \hbox to\hsize\bgroup\vbox\bgroup\hsize=4.2in % specify length of left segment \startpiece \def\fontbarno{\B\bf\scriptsize} \Notes\hu{gg}\en\bar \znotes\zcn{s}{\hspace{0.12cm}\bf\A To Coda}\en \Notes\qu{gg}\hu{g}\en\bar \znotes\hspace{-0.25cm}\coda q\en \notes\qu{g}\Dqbu gg\qu{gg}\en\bar \znotes\ccn{s}{\hspace{+3.7cm}\bf\A D.C. al Coda}\en \Notes\qu{g}\qp\hp\en \setdoublebar \endpiece% Se finaliza el fragmento musical \egroup\hfill\vbox\bgroup\hsize=2.2in \startbarno=5 \startpiece \def\fontbarno{\B\bf\scriptsize} \znotes\coda o\en \notes\qu{gg}\hu{g}\en\bar \notes\hu{gg}\en\bar \Notes\wh{g}\en\setdoubleBAR\endpiece \egroup\egroup% close open \bgroups \end{music}

\end{document}


Edit 2

Moving the first bar number right:

bar numbers

A total hack. See comments in the code.

MWE

\documentclass[tikz,border=3mm]{standalone}
\usepackage[top=3cm, bottom=2.8cm, left=2.5cm, right=0.5cm, marginparwidth=0cm, marginparsep=0cm, headheight=13.6pt, a4paper]{geometry}
\usepackage[T1]{fontenc}
\usepackage{polyglossia}
\setmainlanguage{spanish}

\usepackage{xcolor}

\usepackage{musixtex}

%*** Code copied from musixtex.tex

%*** redefine \fontbarno \def\fontbarno{\color{red}\large\bfseries}

    \makeatletter

%*** for the first bar number %*** clone of \wbarno@x %*** points to \writethebarnob \def\wbarno@xb{% \ifx\volta@set\empty \n@iii\barno \divide\n@iii\freqbarno\relax \ifnum\n@iii=\lastbarno \else \y@\altplancher \advance\y@\systemheight \advance\y@\tw@\internote \raise\y@\llap{\writethebarnob}\fi \else \ifx\volta@cut\empty \else % volta was cut, there is nothing colliding with bar number. \n@iii\barno \divide\n@iii\freqbarno\relax \ifnum\n@iii=\lastbarno \else \y@\altplancher \advance\y@\systemheight \advance\y@\tw@\internote \raise\y@\llap{\writethebarno}\fi \fi \write@volta \fi \ifx\pdl@cut\empty % 1.21 RDT \else% pedal rule was cut at the end of the previous line \global\pdl@pos\lin@pos\let\pdl@cut\empty % reset \ped@pos \fi \b@rrul@ %+simick \n@iii\barno \divide\n@iii\freqbarno\relax \lastbarno\n@iii }

%*** redefine \piece@beginb %*** points to \wbarno@xb \def\piece@beginb{\advance\line@width-\parindent \s@indent\parindent \writ@staffs \writ@names \wbarno@xb\advance\line@width\parindent}

%*** redefine \writethebarno %*** lower the number with \raisebox %*** make the number \large and red \def\writethebarno{\raisebox{-16\internote}{{\color{red}\fontbarno\large\the\barno\kernm\qn@width}}}

%*** clone of \writethebarno %*** for moving (first) bar number right, -3em \def\writethebarnob{\raisebox{-16\internote}{{\color{red}\fontbarno\large\the\barno\kern-3em}}} \makeatother

\begin{document} \vspace{5cm} \begin{music} \font\A=phvb8t at 8pt% added for letter type. \font\B=phvb8t at 8pt% added for letter type. \setclef1\treble % Clave de Sol para el Instrumento 1 \nostartrule % Inicia sin barra vertical \generalmeter{\meterfrac{4}4} \hbox to\hsize\bgroup\vbox\bgroup\hsize=4.2in % specify length of left segment \startpiece \def\fontbarno{\B\bf\scriptsize} \Notes\hu{gg}\en\bar \znotes\zcn{s}{\hspace{0.12cm}\bf\A To Coda}\en \Notes\qu{gg}\hu{g}\en\bar \znotes\hspace{-0.25cm}\coda q\en \notes\qu{g}\Dqbu gg\qu{gg}\en\bar \znotes\ccn{s}{\hspace{+3.7cm}\bf\A D.C. al Coda}\en \Notes\qu{g}\qp\hp\en \setdoublebar \endpiece% Se finaliza el fragmento musical \egroup\hfill\vbox\bgroup\hsize=2.2in \startbarno=5 \startpiece \def\fontbarno{\B\bf\scriptsize} \znotes\coda o\en \notes\qu{gg}\hu{g}\en\bar \notes\hu{gg}\en\bar \Notes\wh{g}\en\setdoubleBAR\endpiece \egroup\egroup% close open \bgroups \end{music}

\end{document}

As remarked in the comments, this is not an enhancement feature-add to the whole MusiXTeX program, but a one-off mod to one part of one strand of it.

Cicada
  • 10,129
  • This certainly is more advanced TeX than my solution, but this seems to write the first bar number every time, while an incomplete bar at the beginning is not numbered 1. MusiXTeX does not count the amount of note values, so you have to tell it whether the first bar is complete or not. – C. Peters Jun 02 '23 at 12:55
  • @C.Peters Yes, musixtex.tex has a huge amount of code dealing with bar navigation (e.g., \def\startextract{\lastbarno\z@ \barno\startbarno) and special-handling code for ragged bars etc - beyond my current skills. I would re-implement it in expl3 from the ground up, but that won't be of help here. – Cicada Jun 03 '23 at 03:21