在 Musixtex 中突出显示音阶

在 Musixtex 中突出显示音阶

理论分析时需要突出尺度,基本代码如下:

\documentclass[tikz,border=3mm]{standalone}
\usepackage[T1]{fontenc}
\usepackage{polyglossia}
\setmainlanguage{spanish}

\usepackage{musixtex} 

\newlength{\musicwidth}%new
\setlength{\musicwidth}{0.75\textwidth}%new, can be set for each instance of a figure environment 


\begin{document}

(a) C major scale

\begin{music}
    \setclef1{\treble}
    \parindent3pt
    \startextract
    \Notes\wh{cdefghijihgfedc}\en
    \zendextract
 \end{music}
 
C minor scales

(b) Natural

\begin{music}
    \setclef1{\treble}
    \parindent3pt
    \startextract
    \Notes\wh{cd_efg_h_ij_i_hgf_edc}\en
    \zendextract
\end{music}

(c) Harmonic

\begin{music}
    \setclef1{\treble}
    \parindent3pt
    \startextract
    \Notes\wh{cd_efg_h=ij=i_hgf_edc}\en
    \zendextract
\end{music}

(d) Melodic

\begin{music}
    \setclef1{\treble}
    \parindent3pt
    \startextract
    \Notes\wh{cd_efg=h=ij_i_hgf_edc}\en
    \zendextract
\end{music}

\end{document}

当前输出如下: 当前的

预期输出如下(注意跨尺度的突出显示): 预期的

答案1

这是一个使用的解决方案tikzmark

  • \upmark和宏\downmark将标记放在下一个音符的上方或下方。

  • 如果改变音乐的大小,请调整\lsh\rsh距离。

  • 必须tikzpicture在音乐系统之前绘制矩形才能作为背景出现。

\documentclass{article}
\usepackage[paper=a4paper,margin=1cm]{geometry}
\usepackage[T1]{fontenc}
\usepackage{polyglossia}
\setmainlanguage{spanish}

\usepackage{musixtex} 

\usepackage{tikz}
\usetikzlibrary{tikzmark}

\newcommand\upmark[1]{\cchar{14}{\pgfmark{#1}}}
\newcommand\downmark[1]{\cchar{-6}{\pgfmark{#1}}}
\def\lsh{-6pt}
\def\rsh{12pt}

\pagestyle{empty}

\begin{document}

\begin{tikzpicture}[overlay,remember picture]
  \fill[cyan!10] ([xshift=\lsh]pic cs:a1) rectangle ([xshift=\rsh]pic cs:a2);
  \fill[orange!10] ([xshift=\lsh]pic cs:b1) rectangle ([xshift=\lsh]pic cs:c2);
  \fill[violet!10] ([xshift=\lsh]pic cs:d1) rectangle ([xshift=\lsh]pic cs:e2);
\end{tikzpicture}

(a) C major scale

\begin{music}
    \setclef1{\treble}
    \parindent3pt
    \startextract
    \Notes\wh{cd}\upmark{a1}\wh{efg}\upmark{b1}\wh{hi}\upmark{c1}\wh{j}\upmark{d1}\wh{ih}\upmark{e1}\wh{gfedc}\en
    \zendextract
 \end{music}
 
C minor scales

(b) Natural

\begin{music}
    \setclef1{\treble}
    \parindent3pt
    \startextract
    \Notes\wh{cd_efg_h_ij_i_hgf_edc}\en
    \zendextract
\end{music}

(c) Harmonic

\begin{music}
    \setclef1{\treble}
    \parindent3pt
    \startextract
    \Notes\wh{cd_efg_h=ij=i_hgf_edc}\en
    \zendextract
\end{music}

(d) Melodic

\begin{music}
    \setclef1{\treble}
    \parindent3pt
    \startextract
    \Notes\wh{cd}\downmark{a2}\wh{_efg}\downmark{b2}\wh{=h=i}\downmark{c2}\wh{j}\downmark{d2}\wh{_i_h}\downmark{e2}\wh{gf_edc}\en
    \zendextract
\end{music}

\end{document}

在此处输入图片描述

相关内容