自动协调 MusiXTex 摘录的宽度

自动协调 MusiXTex 摘录的宽度

我们找到了一个足够但不是最佳的答案。欢迎任何改进。

一些MusiXTeX摘录被放置在几个浮点图中作为文档的子图。这些摘录在图形环境中的宽度变化可能不美观。宽度变化不大。因此统一的宽度可能是有益的。有没有办法自动实现这一点?如果是这样,那么宽度应该在每个图形环境中单独调整。也许,将问题扩展为协调同一页上不同浮点图中的几个摘录的宽度是合理的。

以下 MWE 显示了问题,并且可以在答案中找到我的手动方法。

\documentclass{article}
\usepackage{subfig,musixtex}

\begin{document}

\begin{figure}
\subfloat[narrow example]{%
\begin{music}%
\nobarnumbers%
\startextract%
\NOTEs\wh{cdefg}\enotes%
\endextract%
\end{music}}

\subfloat[wide example]{%
\begin{music}%
\nobarnumbers%
\startextract%
\NOTes\ha{cdef}\enotes\bar%
\NOTes\ha{ghi}\enotes%
\endextract%
\end{music}}

%\subfloat[test]{%from p. 116 of the manual, most like useless for this problem
%\begin{music}%
%\let\extractline\hbox
%\hbox to \hsize{%
%\hss\startextract\NOTes\hu{cd}\enotes\endextract\hss%
%\hss\startextract\NOTEs\wh{cd}\enotes\endextract\hss}%
%\end{music}
%}
\caption{Can these two examples automatically have the same width?}
\end{figure}

\end{document}

在此处输入图片描述

评论。我提前为标题中的不当双关语道歉。

答案1

以下是手动方法,因此问题得到回答除了自动方面。

对于封装来说,使用\hsize=\musicwidth可能比\parbox或更自然、更高效minipage。毋庸置疑:全局不变的宽度定义满足了在多个figure环境中同一页面宽度不变的要求,但可能并不适合所有摘录。然而,对于大多数图形来说,可能存在折衷的尺寸。

\documentclass{article}
\usepackage{subfig,musixtex}

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

\begin{document}

\begin{figure}
\centering%new

\subfloat[narrow example]{
%\fbox
{\begin{music}
\hsize=\musicwidth%new
\nobarnumbers%
\startpiece%new
\NOTEs\wh{cdefg}\enotes%
\endpiece%new
\end{music}}}

\subfloat[wide example]{
%\fbox
{\begin{music}
\hsize=\musicwidth%new
\nobarnumbers%
\startpiece%new
\NOTes\ha{cdef}\enotes\bar%
\NOTes\ha{ghi}\enotes%
\endpiece%new
\end{music}}}

\caption{This manual approach by try and error works. But there might be room for improvement.}
\end{figure}

\end{document}

在此处输入图片描述

评论。也许需要进一步解释一下这个微妙的评论\startpiece%new:与 MWE 相比自动协调 MusiXTex 摘录的宽度,此提案需要生成*.mx2手册中写明的文件 https://ctan.org/pkg/musixtex在“三通系统”部分(阅读精细手册,RTFM)。

相关内容