Musixtex写五线谱
程序员文章站
2022-04-19 19:36:25
...
这学期修了一门方法和写作课,从中接触到了LaTeX,最后作业被分到用LaTeX写乐谱((lll¬ω¬))
LATEX 中的Music-TeX 宏包提供了一个music 环境和整套音乐符号命令,可排版多声部乐曲或交响乐总谱。通常,LaTeX源文件主要是由文本和控制命令构成,而MusicTeX 源文件主要是由音符标记命令和控制命令组成,看起来很复杂,可一旦掌握,就能排版高质量的五线谱。MusicTeX 宏包尚有些缺陷,如圆滑线不够圆滑等,现在逐渐被MusiXTeX 宏包所取代。MusiXTeX 宏包以MusicTeX 为基础并进一步改进提高,MusicTeX 中的绝大部分命令依然有效或被兼容,少部分有所改动,另外还增加许多新的记谱命令,使其乐谱排版功能更为强大。MusiXTeX 最重要的改进之处就是采用三步编译法,使圆滑线和连接线更为滑流畅。
步骤一
我使用的LaTeX环境是TeXLive 2017 + TeXstudio(顺便安利一下)。当然,里面已经包含了MusixTeX宏包,所以就直接上手了。
一个例子
参考Musixtex官方给的例子:
\documentclass{article}
\usepackage{Musixtex}
\usepackage{amsfonts}
\usepackage{CJK}
\begin{document}
\begin{music}
\parindent10mm
\instrumentnumber{1} % a single instrument
\setname1{Piano} % whose name is Piano
\setstaffs1{2} % with two staffs
\generalmeter{\meterfrac44} % 4/4 meter chosen
\startextract % starting real score
\Notes\ibu0f0\qb0{cge}\tbu0\qb0g|\hl j\en
\Notes\ibu0f0\qb0{cge}\tbu0\qb0g|\ql l\sk\ql n\en
\bar
\Notes\ibu0f0\qb0{dgf}|\qlp i\en
\notes\tbu0\qb0g|\ibbl1j3\qb1j\tbl1\qb1k\en
\Notes\ibu0f0\qb0{cge}\tbu0\qb0g|\hl j\en
\zendextract % terminate excerpt
\end{music}
\end{document}
编译一下得到这样的谱子:
所以一个乐谱的主体就是begin{music}和end{music}之间的部分,这里面先是有格式的描述,接着是各个音符的表示(不懂音乐,音符什么的只能依葫芦画瓢,一个音一个音地试,心累)。
自己写的一个版本
网上送了《送别》的谱子,对着谱子用LaTeX写了一遍:
\documentclass[a4paper]{article}
\usepackage{Musixdoc}
\usepackage[UTF8]{ctex}
\usepackage{amsfonts}
\usepackage{CJK}
\begin{document}
\title{送别}
\date{ }
\maketitle
\begin{music}
%\hsize=160mm
\parindent10mm
\instrumentnumber{1} % a single instrument
\setname1{Piano} % whose name is Piano
\setstaffs1{2} % with two staffs
\setclef1\bass
\generalmeter{\meterfrac44}% 4/4 meter chosen
\startextract % starting real score
\Notes\Qqbbu CGJL \Dqbl NL \Qqbbu CGJL \Dqbl NL|\zcharnote{N}{长} \qu {g***} \zcharnote{N}{亭}\Dqbu eg \zcharnote{N}{外}\hl {j***}\en
\bar
\Notes\Qqbbu FJMa \Dqbl ca \Qqbbu CGJL \Dqbl NL|\zcharnote{N}{古} \qu {h***}\zcharnote{N}{道} \ql {j*} \zcharnote{N}{边} \hu {g***} \en \endpiece
\zendextract % terminate excerpt
\end{music}
%2
\begin{music}
\parindent10mm
\instrumentnumber{1} % a single instrument
\setname1{} % whose name is Piano
\setstaffs1{2} % with two staffs
\setclef1\bass
\generalmeter{\meterfrac44}% 4/4 meter chosen
\startextract % starting real score
\Notes\Qqbbu CGJL \Dqbl NL \Qqbbu CGJL \Dqbl NL \Dqbl NL|\zcharnote{N}{芳} \qu {g***}\zcharnote{N}{草} \Dqbu cd \zcharnote{N}{碧} \qu {e***} \zcharnote{N}{连} \Dqbu dc\en
\bar
\Notes\Qqbbu GKNb \Dqbl ML \Qqbbu CGJL \Dqbl NL|\zcharnote{N}{天} \hup {d*********} \qp \en \endpiece
\zendextract % terminate excerpt
\end{music}
%3
\begin{music}
\parindent10mm
\instrumentnumber{1} % a single instrument
\setname1{} % whose name is Piano
\setstaffs1{2} % with two staffs
\setclef1\bass
\generalmeter{\meterfrac44}% 4/4 meter chosen
\startextract % starting real score
\Notes\Qqbbu CGJL \Dqbl NL \Qqbbu CGJL \Tqbl N*L|\zcharnote{N}{晚} \qu {g***}\zcharnote{N}{风} \Dqbu eg \zcharnote{N}{拂} \qlp {j***} \zcharnote{N}{袖} \cl {**i} \en
\bar
\Notes\Qqbbu FJMa \Dqbl ML \Qqbbu CGJL \Dqbl NL|\zcharnote{N}{笛} \qu {h***}\zcharnote{N}{声} \ql {j*} \zcharnote{N}{残} \hu {g***}\en \endpiece
\zendextract % terminate excerpt
\end{music}
%4
\begin{music}
\parindent10mm
\instrumentnumber{1} % a single instrument
\setname1{} % whose name is Piano
\setstaffs1{2} % with two staffs
\setclef1\bass
\generalmeter{\meterfrac44}% 4/4 meter chosen
\startextract % starting real score
\Notes\Qqbbu GKLN \Dqbl db \Qqbbu GKLN \Tqbl d*b|\zcharnote{N}{夕} \qu {g***}\zcharnote{N}{阳} \Dqbu de \zcharnote{N}{山} \qup {f***} \zcharnote{N}{外} \cu {**b}\en
\bar
\Notes\Qqbbu CGJL \Dqbl NL \Qqbbu CGJL \Dqbl NL|\zcharnote{N}{山} \hup {c*********} \qp \en \endpiece
\zendextract % terminate excerpt
\end{music}
%5
\begin{music}
\parindent10mm
\instrumentnumber{1} % a single instrument
\setname1{} % whose name is Piano
\setstaffs1{2} % with two staffs
\setclef1\bass
\generalmeter{\meterfrac44}% 4/4 meter chosen
\startextract % starting real score
\Notes\Qqbbu FJMa \Dqbl ca \Qqbbu FJMa \Dqbl ca|\zcharnote{N}{天} \qu {h***}\zcharnote{N}{之} \ql {j*} \zcharnote{N}{涯} \hl {j***}\en
\bar
\Notes\Qqbbu GKNb \Dqbl db \Qqbbu CGJL \Dqbl NL|\zcharnote{N}{海} \ql {i***} \zcharnote{N}{之} \Dqbu hi \zcharnote{N}{角} \hl {j***}\en\endpiece
\zendextract % terminate excerpt
\end{music}
%6
\begin{music}
\parindent10mm
\instrumentnumber{1} % a single instrument
\setname1{} % whose name is Piano
\setstaffs1{2} % with two staffs
\setclef1\bass
\generalmeter{\meterfrac44}% 4/4 meter chosen
\startextract % starting real score
\Notes\Qqbbu FJMa \Dqbl ca \Qqbbu CGJL \Dqbl NL|\zcharnote{N}{知} \ibu0f0\qb0{h*i*j}\tbu0\qb 0h \ibu0f0\qb0{h*g*e}\tbu0\qb 0c\en
\bar
\Notes\Qqbbu GKNb \Dqbl db \Qqbbu GKNb \Dqbl db|\hup {d*********} \qp\en\endpiece
\zendextract % terminate excerpt
\end{music}
%7
\begin{music}
\parindent10mm
\instrumentnumber{1} % a single instrument
\setname1{} % whose name is Piano
\setstaffs1{2} % with two staffs
\setclef1\bass
\generalmeter{\meterfrac44}% 4/4 meter chosen
\startextract % starting real score
\Notes\Qqbbu CGJL \Dqbl NL \Qqbbu CGJL \Tqbl N*L|\qu {g***}\Dqbu eg \qlp {j***} \cl {**i}\en
\bar
\Notes\Qqbbu FJMa \Dqbl ca \Qqbbu CGJL \Dqbl NL|\qu {h***} \ql {j*} \hu {g***}\en\endpiece
\zendextract % terminate excerpt
\end{music}
%8
\begin{music}
\parindent10mm
\instrumentnumber{1} % a single instrument
\setname1{} % whose name is Piano
\setstaffs1{2} % with two staffs
\setclef1\bass
\generalmeter{\meterfrac44}% 4/4 meter chosen
\startextract % starting real score
\Notes\Qqbbu GKNb \Dqbl db \Qqbbu GKNb \Tqbl d*b|\qu {g***}\Dqbu de \qup {f***} \cu {**b}\en
\bar
\Notes\Qqbbu CGJL \Dqbl NL \zh J\zh L\hl N|\hup {c******} \qp \en\endpiece
\zendextract % terminate excerpt
\end{music}
\end{document}
出来效果是这样:
说实话,太丑了(没有对齐、歌词和音符有重叠),没办法再改要吐血了(lll¬ω¬)。
总结
和所见即所得的MS word 不同,LaTeX写起来就像是在写代码,门槛有点高,要达到熟练我还是算了吧,能自己谢谢论文,做个ppt就可以了ε=ε=ε=┏(゜ロ゜;)┛。