自動協調 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可能比使用\parboxminipage進行封裝更自然、更有效。不用說:全域不變的寬度定義可以滿足多個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)。

相關內容