我的目标是能够将独立的音符插入文本并为其着色,因为使用LilyGlyphs
(可可),我用 做到了MusixTex
,但是遇到了间距问题!
在以下 MWE 中有:
- 表格中的“我的笔记”,以及用于
LilyGlyphs
比较的 LilyGlyphs
拍号中的“我的笔记”- 文本中的“我的笔记”。对于第一个,我通过一种
hspace{-xx}
hack 减少了注释前的空间,我可能也可以对注释后的空间做同样的 hack
为了删除上部空格,我尝试使用 进行破解vspace{-xx}
,但没有成功。
另外,由于我认为该空格是由于MusixTex
为工作人员保留的,因此我尝试用 将其删除\setstaffs{1}{0}
,但这样,注释不会被打印,空格也不会被删除,只留下一个很大的 空格!
\documentclass{report}
\usepackage{fontspec}
\usepackage{lilyglyphs}
\usepackage{xcolor}
\usepackage{musixtex}
\newcommand\myNote[2][]{
\def\FirstArg{#1}
\ifx\FirstArg\empty
% If the first arg is not set, no space moving
\else
\hspace{-#1pt}
\fi
\scalebox{0.6}{
\begin{music}
\instrumentnumber{1}
\nobarnumbers
\setclefsymbol{1}\empty
\setlines{1}{0}
\nostartrule
\smallmusicsize
\startextract
\notes#2{a}\en
\setemptybar
\endextract
\end{music}
}
}
\begin{document}
\begin{tabular}{|c|c|}
\hline
LilyGlyphs & \quaver\\
\hline
\end{tabular}\\
\begin{tabular}{|c|c|}
\hline
My note (with MusiXTeX) & \myNote{\cu}\\
\hline
\end{tabular}
\vspace{2\baselineskip}
\textcolor{red}{\lilyTimeSignature{6}{\myNote[11]{\cup}}}
\vspace{2\baselineskip}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque nisi
nisi, eleifend eu dolor vel \myNote[100]{\qu}, hendrerit pretium est. Donec vitae tempor turpis.
Maecenas ligula arcu, condimentum sit amet feugiat sed, accumsan quis ligula.
In ac lorem dignissim, venenatis felis ut, maximus magna. Donec vel tortor
condimentum mi dictum interdum a et tortor\myNote{\wh}. Nam pharetra ullamcorper quam, ut
pretium elit pellentesque ut. Donec pretium, ipsum at blandit bibendum, odio
urna tempor dolor, quis tristique orci ante fringilla nisi. Praesent vulputate
maximus ante, finibus suscipit \myNote{\ccl} massa aliquam sit amet. In nibh nisl, sagittis
sit amet fermentum quis, interdum eget dolor. Morbi eget varius magna, eu
tempor nisl. Donec vel urna ultricies, sodales turpis ut, gravida sem. Duis
consequat laoreet sodales. Curabitur laoreet pretium purus, ut vulputate
ligula auctor at. Etiam at rhoncus ex. Donec metus ante, ullamcorper vitae
ultrices a, auctor vel dolor.
\end{document}
答案1
这有点不方便,但我成功去除了空白。
我使用了znotes
来notes
删除音符后的部分空间,\def\afterruleskip{0\elemskip}
删除音符前的部分空间,以及hspace
删除剩余的左右空间。对于上部和下部空间,我使用了 及其raisebox
和height
参数depth
。
这是结果。它并不完美,必须为每个音符进行调音。
\documentclass{report}
\usepackage{fontspec}
\usepackage{lilyglyphs}
\usepackage{xcolor}
\usepackage{musixtex}
\newcommand\myNote[1]{%
\hspace{-092pt}
\raisebox{-08pt}[6pt][4pt]{%
\scalebox{0.5}{%
\begin{music}%
\instrumentnumber{1}%
\nobarnumbers%
\setclefsymbol{1}\empty%
\setlines{1}{0}%
\nostartrule%
\smallmusicsize%
\def\afterruleskip{0\elemskip}
\startextract%
\znotes#1{f}\en%
\setemptybar%
\endextract%
\end{music}%
}%
}%
\hspace{-086pt}
}
\begin{document}
\begin{tabular}{|c|c|}
\hline
LilyGlyphs & \quaver\\
\hline
\end{tabular}\\
\begin{tabular}{|c|c|}
\hline
My note (with MusiXTeX) & \myNote{\cu}\\
\hline
\end{tabular}
\vspace{2\baselineskip}
\textcolor{red}{\lilyTimeSignature{6}{\myNote{\cup}}}
\vspace{2\baselineskip}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque nisi
nisi, eleifend eu dolor vel \myNote{\qu}, hendrerit pretium est. Donec vitae tempor turpis.
Maecenas ligula arcu, condimentum sit amet feugiat sed, accumsan quis ligula.
In ac lorem dignissim, venenatis felis ut, maximus magna. Donec vel tortor
condimentum mi dictum interdum a et tortor\myNote{\wh}. Nam pharetra ullamcorper quam, ut
pretium elit pellentesque ut. Donec pretium, ipsum at blandit bibendum, odio
urna tempor dolor, quis tristique orci ante fringilla nisi. Praesent vulputate
maximus ante, finibus suscipit \myNote{\ccl} massa aliquam sit amet. In nibh nisl, sagittis
sit amet fermentum quis, interdum eget dolor. Morbi eget varius magna, eu
tempor nisl. Donec vel urna ultricies, sodales turpis ut \myNote{\hu}, gravida sem. Duis
consequat laoreet sodales. Curabitur laoreet pretium purus, ut vulputate
ligula auctor at. Etiam at rhoncus ex. Donec metus ante, ullamcorper vitae
ultrices a, auctor vel dolor.
\end{document}