Musixtex: annotate an score with arrow and text

musixtex

It´s needed to annotate an score using arrow and text, the code is as follow:

\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage{polyglossia}
\setmainlanguage{spanish}
\usepackage{etoolbox}
\usepackage{float} %Paquete para posicionar Tablas
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\usepackage{musixtex} 
\input{musixlyr}
\input {musixcho}
\input {musixdat}%fecha
\input {musixfll}
\input {musixgre}%gregoriano
\input {musixper}%percusión
\input {musixppff}
\input {musixstr}
\input {musixvbm}  % experimental vectorized beams
\input {musixdbr} % lineas de barras punteadas, discontinuas y arbitrariamente discontinuas
%Rutinas para Musixtex
\newcommand{\BBBl}[5][0]%
{\ibbbl{#1}{#2}{#3}\qb{#1}{#4}\tqb{#1}{#5}}
\newcommand{\BBBBl}[5][0]%
{\ibbbbl{#1}{#2}{#3}\qb{#1}{#4}\tqb{#1}{#5}}

\begin{document}
%\begin{tikzpicture}
%\draw [red,-{Stealth}] (0,0)--(0.5,-1);
%\draw (0,0) circle (1cm);
%\draw (0,0) node {
%\node (image) at (0,0) {
%\begin{figure}[H]
\begin{center}
%\tikz{\node[scale=1]{
\begin{music}
        \normalmusicsize
        \setclefsymbol1\empty
        \nobarnumbers
        \nostartrule % Inicia sin barra vertical
        \startextract
        %\startpiece
        \notes \wh j \sk \en
        %\Endpiece
        \zendextract %Cierra de partitura sin barra vertical
        \startextract
        %\startpiece %\alaligne\alapage
        \notes \hl{j} \sk \hl{j} \sk \en%\alaligne
        %\Endpiece
        \zendextract %Cierra de partitura sin barra vertical
        \startextract
        %\startpiece
        \notes \ql{j} \ql{j} \ql{j} \ql{j} \sk \en %\alaligne
        %\Endpiece
        \zendextract %Cierra de partitura sin barra vertical
        \startextract
        %\startpiece
        \notes \Dqbl jj \Dqbl jj \Dqbl jj \Dqbl jj \en
        %\Endpiece
        \zendextract %Cierra de partitura sin barra vertical
        \startextract
        %\startpiece
        \notes \Qqbbl jjjj \Qqbbl jjjj \Qqbbl jjjj \Qqbbl jjjj \en
        %\Endpiece
        \zendextract %Cierra de partitura sin barra vertical
        \startextract
        %\startpiece
        \notes \BBBl{l}{0}{jjjjjjj}{j} \BBBl{l}{0}{jjjjjjj}{j} \BBBl{l}{0}{jjjjjjj}{j} \BBBl{l}{0}{jjjjjjj}{j} \en
        %\Endpiece
        \zendextract %Cierra de partitura sin barra vertical
\end{music}
%};}
\end{center}
%\end{figure}
 %\end{tikzpicture}
        
\begin{center}
\tikz{\node[scale=0.7]{
        \begin{music}
        \smallmusicsize
        \setclefsymbol1\empty
        \nobarnumbers
        \nostartrule % Inicia sin barra vertical
        \startextract
        %\startpiece
        \notes \BBBBl{l}{0}{jjjjjjjjjjjjjjj}{j} \BBBBl{l}{0}{jjjjjjjjjjjjjjj}{j} \BBBBl{l}{0}{jjjjjjjjjjjjjjj}{j} \BBBBl{l}{0}{jjjjjjjjjjjjjjj}{j}\en
        %\Endpiece
        \zendextract %Cierra de partitura sin barra vertical
        \end{music}    
        };}
\end{center}
\end{document}

The output should be as follow:

enter image description here

Best Answer

I would not use \startextract and \zendextract but rather \startpiece and \zendpiece to typeset the music, because this will automatically fill a line. You can then easily set the line width using the text width option of the TikZ node.

You can use the \scale{} macro to set the right relative distances between the different music parts. Somehow the distance of the two half notes needed some additional manual adjustment. To manually add some horizontal spacing between the notes, you can use the \off{} macro.

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usepackage{musixtex} 
%Rutinas para Musixtex
\newcommand{\BBBl}[5][0]{%
    \ibbbl{#1}{#2}{#3}\qb{#1}{#4}\tqb{#1}{#5}%
}
\newcommand{\BBBBl}[5][0]{%
    \ibbbbl{#1}{#2}{#3}\qb{#1}{#4}\tqb{#1}{#5}%
}

\begin{document}
\begin{tikzpicture}[
        scale=0.67, 
        transform shape,
        score/.style={
            anchor=west,
            align=left, 
            text width=21.25cm,
            inner sep=0pt
        },
        label/.style={
            anchor=east,
            align=center,
            text width=7em
        },
        every path/.style={
            draw=red, 
            very thick,
            line cap=round
        }
    ]
    %Primera partitura 
    \node[score] (A) at (0,0) {
    \begin{music}
        \normalmusicsize
        \setclefsymbol1\empty
        \nobarnumbers
        \nostartrule % Inicia sin barra vertical
        \startpiece
        \scale{48}
        \notes 
            \off{0.5em}
            \wh j 
            \en
        \zendpiece %Cierra de partitura sin barra vertical
    \end{music}};
    %Segunda partitura 
    \node[score] (B) at (0,-1.5) {
    \begin{music}
        \normalmusicsize
        \setclefsymbol1\empty
        \nobarnumbers
        \nostartrule % Inicia sin barra vertical
        \startpiece
        \scale{24}
        \notes 
            \off{0.5em}
            \hl{j} 
            \off{0.25em}
            \hl{j} 
            \en
        \zendpiece %Cierra de partitura sin barra vertical
    \end{music}};
    %Tercera partitura 
    \node[score] (C) at (0,-3) {
    \begin{music}
        \normalmusicsize
        \setclefsymbol1\empty
        \nobarnumbers
        \nostartrule % Inicia sin barra vertical
        \startpiece
        \scale{12}
        \notes 
            \off{0.5em}
            \ql{j} 
            \ql{j}  
            \ql{j}  
            \ql{j} 
            \en
        \zendpiece %Cierra de partitura sin barra vertical
    \end{music}};
    %Cuarta partitura 
    \node[score] (D) at (0,-4.5) {
    \begin{music}
        \normalmusicsize
        \setclefsymbol1\empty
        \nobarnumbers
        \nostartrule % Inicia sin barra vertical
        \startpiece
        \scale{6}
        \notes 
            \off{0.5em}
            \Dqbl jj 
            \Dqbl jj 
            \Dqbl jj 
            \Dqbl jj 
            \en
        \zendpiece %Cierra de partitura sin barra vertical
    \end{music}};
    %Quinta partitura 
    \node[score] (E) at (0,-6) {
    \begin{music}
        \normalmusicsize
        \setclefsymbol1\empty
        \nobarnumbers
        \nostartrule % Inicia sin barra vertical
        \startpiece
        \scale{3}
        \notes 
            \off{0.5em}
            \Qqbbl jjjj 
            \Qqbbl jjjj 
            \Qqbbl jjjj 
            \Qqbbl jjjj 
            \en
        \zendpiece %Cierra de partitura sin barra vertical
    \end{music}};
    %Sexta partitura 
    \node[score] (F) at (0,-7.5) {
    \begin{music}
        \normalmusicsize
        \setclefsymbol1\empty
        \nobarnumbers
        \nostartrule % Inicia sin barra vertical
        \startpiece
        \scale{1.5}
        \notes 
            \off{0.5em}
            \BBBl{l}{0}{jjjjjjj}{j} 
            \BBBl{l}{0}{jjjjjjj}{j} 
            \BBBl{l}{0}{jjjjjjj}{j} 
            \BBBl{l}{0}{jjjjjjj}{j} 
            \en
        \zendpiece %Cierra de partitura sin barra vertical
    \end{music}};
    %Septima partitura 
    \node[score] (G) at (0,-9) {
    \begin{music}
        \normalmusicsize
        \setclefsymbol1\empty
        \nobarnumbers
        \nostartrule % Inicia sin barra vertical
        \startpiece
        \scale{0.75}
        \notes 
            \off{0.5em}
            \BBBBl{l}{0}{jjjjjjjjjjjjjjj}{j} 
            \BBBBl{l}{0}{jjjjjjjjjjjjjjj}{j} 
            \BBBBl{l}{0}{jjjjjjjjjjjjjjj}{j} 
            \BBBBl{l}{0}{jjjjjjjjjjjjjjj}{j}
            \en
        \zendpiece %Cierra de partitura sin barra vertical
    \end{music}};
    %Lineas de redonda a blanca
    \draw 
        (0.6,-0.15) -- ++(0,-1)
        (0.8,-0.15) -- ++(10,-1);
    \draw 
        (0.6,-2) -- ++(0,-0.65)
        (0.8,-2) -- ++(5,-0.65)
        (10.95,-2) -- ++(0,-0.65)
        (11.15,-2) -- ++(5,-0.65);
    \draw 
        (0.6,-3.5) -- ++(0,-0.65)
        (0.8,-3.5) -- ++(2.33,-0.65)
        (5.8,-3.5) -- ++(0,-0.65)
        (6,-3.5) -- ++(2.33,-0.65);
    \draw 
        (0.6,-5.15) -- ++(0,-0.5)
        (0.8,-5.15) -- ++(1,-0.5)
        (3.2,-5.15) -- ++(0,-0.5)
        (3.4,-5.15) -- ++(1,-0.5);
    \draw 
        (0.6,-6.75) -- ++(0,-0.4)
        (0.8,-6.75) -- ++(0.5,-0.4)
        (1.85,-6.75) -- ++(0,-0.4)
        (2.05,-6.75) -- ++(0.5,-0.4)
        (3.1,-6.75) -- ++(0,-0.4)
        (3.3,-6.75) -- ++(0.5,-0.4)
        (4.35,-6.75) -- ++(0,-0.4)
        (4.55,-6.75) -- ++(0.5,-0.4);
    \draw 
        (0.6,-8.25) -- ++(0,-0.4)
        (0.8,-8.25) -- ++(0.1,-0.4)
        (1.2,-8.25) -- ++(0,-0.4)
        (1.4,-8.25) -- ++(0.1,-0.4);
    % annotations
    \node[label] at (A.west) {La redonda \\ vale};
    \node[label] at (B.west) {2 blancas \\ o};
    \node[label] at (C.west) {4 negras \\ o};
    \node[label] at (D.west) {8 corcheas \\ o};
    \node[label] at (E.west) {16 semicorcheas \\ o};
    \node[label] at (F.west) {32 fusas \\ o};
    \node[label] at (G.west) {64 semifusas};
\end{tikzpicture}
\end{document}

enter image description here

Related Question