3

Several MusiXTeX extracts are placed in a few floats as subfigures of a document. The width variation of these extracts within a figure environment might not please the eye. The widths do not vary much. So a uniform width might be beneficiary. Is there a way to achieve this automatically? If so then the width should adjust in each figure environment individually. Perhaps, it is reasonable to extend the question to harmonize the width of several extracts in different floats on the same page.

The following MWE shows the problem and my manual approach can be found in the answers.

\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}

enter image description here

Remark. I apologise in advance for the bad pun in the title.

  • 1
    Harmonize "width"? Okay: widpth – Steven B. Segletes Apr 17 at 11:02
  • 2
    If my humor is not understood about harmonizing "width", then let me make it crystal clear: wi\raisebox{-20pt}{\NOTes\ha{h}\enotes~~\,\NOTes\ha{i}\enotes~~}th – Steven B. Segletes Apr 17 at 11:10
  • @StevenB.Segletes Honestly, I do not really get it. Perhaps, I need to study the foundations of eye music. But I am happy that my disgraceful pun inspired you to a joke. – CampanIgnis Apr 19 at 14:59
  • 1
    The joke is that the "d" in width looks like a half note. The following "p" also looks like a harmonized half note with the "d". Thus, 2 half notes in harmony..."widpth" is harmonized! – Steven B. Segletes Apr 19 at 15:16
  • 1
    @StevenB.Segletes: Thank you. That makes sense. So you only introduced the "p" or \ha{i} to force a "harmony" (two semitones, does that count as "harmonic"?)? – CampanIgnis Apr 22 at 15:52
2

Below is a manual approach, hence the question is answered except for the automatic aspect.

The use of \hsize=\musicwidth might be more natural and more efficient than a \parbox or minipage for encapsulation. Needless to say: A global non-changing definition of the width satisfies the requirement of constant width on the same page within several figure environments but might not be appropriate for all excerpts. However, a standard size for most figures might exist.

\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}

enter image description here

Remark. Perhaps the subtle comment in \startpiece%new needs additional explanation: In contrast to the MWE of Harmonize width of MusiXTex extracts automatically, this proposal requires the generation of the *.mx2 file as written in the manual https://ctan.org/pkg/musixtex in the section "three pass system" (read the fine manual, RTFM).

  • I will delete my prior comments and, as they say, RTFM! – Steven B. Segletes Apr 10 at 15:37
  • 1
    @StevenB.Segletes A classic "read the fine manual" issue, indeed. Glad I could help you. – CampanIgnis Apr 10 at 15:38
  • 1
    Voila! Thank you for getting through to this hard head. – Steven B. Segletes Apr 10 at 15:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.