使用 Musixtex 设置小节编号

使用 Musixtex 设置小节编号

需要实现每个小节下方的小节编号,基本代码如下:

\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}

当前输出如下: 当前的

期望的输出如下: 期望

答案1

我研究了 MusiXTeX 手册的第 13.1 和 13.2 段,然后试验了参数。在正常的小节编号中似乎没有定义高度,并且似乎\raise\lift不起作用。因此我尝试了 MusiXTeX 工具。在\begin{document}我插入

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

您可以通过将 E 更改为您想要的任何音符来调整高度。使用 XeLaTeX,我得到了所附的结果。我唯一还没有发现的是如何使第一个小节号可见。 在此处输入图片描述

我继续尝试,找到了一种显示第一小节数字的方法。我还添加了一些 %,因为你的行没有正确结束,即使在 musixflx 之后也是如此。我移动了你的一些代码。因此,我将整个代码放在这里并替换了屏幕截图。

\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}

在此处输入图片描述

答案2

已完成一部分:降低标准数字:

降低数字

平均能量损失

\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}

编辑

原始第一小节编号:

原始巴诺

平均能量损失

\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}

编辑2

将第一个小节编号向右移动:

酒吧号码

完全是黑客行为。请参阅代码中的注释。

平均能量损失

\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}

正如评论中所说,这不是对整个 MusiXTeX 程序的增强功能,而是对其一个分支的一部分的一次性修改。

相关内容