0

I am using musixtex for writing music. I want to use environment music with enumerate. See this code -

\documentclass{article}
\usepackage{musixtex}

\begin{document}
    \begin{enumerate}
        \item   \begin{music}
            \setclef{1}{\alto}
            \startextract
            \notes \wh{c} \en
            \endextract
        \end{music}
        \hrule
        \item   \begin{music}
            \setclef{1}{\alto}
            \startextract
            \notes \wh{g} \en
            \endextract
        \end{music}
        \hrule
        \item   \begin{music}
            \setclef{1}{\alto}
            \startextract
            \notes \wh{g} \en
            \endextract
        \end{music}
        \hrule
    \end{enumerate}
\end{document}

This renders the following output. It is evident that the enumeration has happened wrongly. What can be the cause of this and how to solve this?

enter image description here


Solution provided by @Piroooh and some further doubts.

\documentclass{article}
\usepackage{musixtex}

\begin{document}
\begin{enumerate}
\item\mbox{\null}

\begin{music}
\setclef{1}{\alto}
\startextract
\notes \wh{c} \en
\endextract
\end{music}
\hrule
\item\mbox{\null}

\begin{music}
\setclef{1}{\alto}
\startextract
\notes \wh{g} \en
\endextract
\end{music}
\hrule
\item\mbox{\null}

\begin{music}
\setclef{1}{\alto}
\startextract
\notes \wh{g} \en
\endextract
\end{music}
\hrule
\item\mbox{\null}

\begin{music}
\setclef{1}{\alto}
\startextract
\notes \wh{c} \en
\endextract
\end{music}
\hrule
\item\mbox{\null}

\begin{music}
\setclef{1}{\alto}
\startextract
\notes \wh{g} \en
\endextract
\end{music}
\hrule
\item\mbox{\null}

\begin{music}
\setclef{1}{\alto}
\startextract
\notes \wh{g} \en
\endextract
\end{music}
\hrule
\item\mbox{\null}

\begin{music}
\setclef{1}{\alto}
\startextract
\notes \wh{c} \en
\endextract
\end{music}
\hrule
\item\mbox{\null}

\begin{music}
\setclef{1}{\alto}
\startextract
\notes \wh{g} \en
\endextract
\end{music}
\hrule
\item\mbox{\null}

\begin{music}
\setclef{1}{\alto}
\startextract
\notes \wh{g} \en
\endextract
\end{music}
\hrule
\item\mbox{\null}

\begin{music}
\setclef{1}{\alto}
\startextract
\notes \wh{c} \en
\endextract
\end{music}
\hrule
\item\mbox{\null}

\begin{music}
\setclef{1}{\alto}
\startextract
\notes \wh{g} \en
\endextract
\end{music}
\hrule
\item\mbox{\null}

\begin{music}
\setclef{1}{\alto}
\startextract
\notes \wh{g} \en
\endextract
\end{music}
\hrule
\item\mbox{\null}

\begin{music}
\setclef{1}{\alto}
\startextract
\notes \wh{c} \en
\endextract
\end{music}
\hrule
\item\mbox{\null}

\begin{music}
\setclef{1}{\alto}
\startextract
\notes \wh{g} \en
\endextract
\end{music}
\hrule
\item\mbox{\null}

\begin{music}
\setclef{1}{\alto}
\startextract
\notes \wh{g} \en
\endextract
\end{music}
\hrule
\item\mbox{\null}

\begin{music}
\setclef{1}{\alto}
\startextract
\notes \wh{c} \en
\endextract
\end{music}
\hrule
\item\mbox{\null}

\begin{music}
\setclef{1}{\alto}
\startextract
\notes \wh{g} \en
\endextract
\end{music}
\hrule
\item\mbox{\null}

\begin{music}
\setclef{1}{\alto}
\startextract
\notes \wh{g} \en
\endextract
\end{music}
\hrule

\end{enumerate}
\end{document}

See 9th and 17th point. The enumeration and the point are on different pages.

1

Cause : It's due to the height of the music environment which starts from the bottom of the line in LaTeX. It's the same problem for each environment next to the \item command. (Minipage, includegraphics,...)


Solution : You can avoid this behaviour by adding \mbox{\null} and a blank line after the \item command. It's the easiest way to achieve what you want.

\documentclass{article}
\usepackage{musixtex}

\begin{document}
    \begin{enumerate}
        \item   \mbox{\null}

        \begin{music}
            \setclef{1}{\alto}
            \startextract
            \notes \wh{c} \en
            \endextract
        \end{music}
        \hrule
        \item   \mbox{\null}

        \begin{music}
            \setclef{1}{\alto}
            \startextract
            \notes \wh{g} \en
            \endextract
        \end{music}
        \hrule
        \item   \mbox{\null}

        \begin{music}
            \setclef{1}{\alto}
            \startextract
            \notes \wh{g} \en
            \endextract
        \end{music}
        \hrule
    \end{enumerate}
\end{document}

OUTPUT

Output

  • Ok, really a good solution. Also thanks for the explanation, but this is still creating a problem for large lists. See the edit. – Niranjan Dec 8 '19 at 9:26
  • By this logic I can also have `\item\phantom{text}\` and then my music environment. I tried it and it works fine, I want a real solution which will enumerate the music correctly. – Niranjan Dec 8 '19 at 9:54
  • Why not simply \mbox{}? – egreg Dec 8 '19 at 9:59
  • @egreg Yes, it works. Thanks. – Niranjan Dec 8 '19 at 10:17
1

This is the solution that I found the best. Thanks @Pirooh and @egreg.

\documentclass{article}
\usepackage{musixtex}

\begin{document}
\begin{enumerate}
\item \mbox{}
\begin{minipage}{\textwidth}
\begin{music}
\setclef{1}{\alto}
\startextract
\notes \wh{c} \en
\endextract
\end{music}
\end{minipage}

\item \mbox{}
\begin{minipage}{\textwidth}
\begin{music}
\setclef{1}{\alto}
\startextract
\notes \wh{g} \en
\endextract
\end{music}
\end{minipage}

\item \mbox{}
\begin{minipage}{\textwidth}
\begin{music}
\setclef{1}{\alto}
\startextract
\notes \wh{g} \en
\endextract
\end{music}
\end{minipage}

\item \mbox{}
\begin{minipage}{\textwidth}
\begin{music}
\setclef{1}{\alto}
\startextract
\notes \wh{c} \en
\endextract
\end{music}
\end{minipage}

\item \mbox{}
\begin{minipage}{\textwidth}
\begin{music}
\setclef{1}{\alto}
\startextract
\notes \wh{g} \en
\endextract
\end{music}
\end{minipage}

\item \mbox{}
\begin{minipage}{\textwidth}
\begin{music}
\setclef{1}{\alto}
\startextract
\notes \wh{g} \en
\endextract
\end{music}
\end{minipage}

\item \mbox{}
\begin{minipage}{\textwidth}
\begin{music}
\setclef{1}{\alto}
\startextract
\notes \wh{c} \en
\endextract
\end{music}
\end{minipage}

\item \mbox{}
\begin{minipage}{\textwidth}
\begin{music}
\setclef{1}{\alto}
\startextract
\notes \wh{g} \en
\endextract
\end{music}
\end{minipage}

\item \mbox{}
\begin{minipage}{\textwidth}
\begin{music}
\setclef{1}{\alto}
\startextract
\notes \wh{g} \en
\endextract
\end{music}
\end{minipage}

\item \mbox{}
\begin{minipage}{\textwidth}
\begin{music}
\setclef{1}{\alto}
\startextract
\notes \wh{c} \en
\endextract
\end{music}
\end{minipage}

\item \mbox{}
\begin{minipage}{\textwidth}
\begin{music}
\setclef{1}{\alto}
\startextract
\notes \wh{g} \en
\endextract
\end{music}
\end{minipage}

\item \mbox{}
\begin{minipage}{\textwidth}
\begin{music}
\setclef{1}{\alto}
\startextract
\notes \wh{g} \en
\endextract
\end{music}
\end{minipage}

\item \mbox{}
\begin{minipage}{\textwidth}
\begin{music}
\setclef{1}{\alto}
\startextract
\notes \wh{c} \en
\endextract
\end{music}
\end{minipage}

\item \mbox{}
\begin{minipage}{\textwidth}
\begin{music}
\setclef{1}{\alto}
\startextract
\notes \wh{g} \en
\endextract
\end{music}
\end{minipage}

\item \mbox{}
\begin{minipage}{\textwidth}
\begin{music}
\setclef{1}{\alto}
\startextract
\notes \wh{g} \en
\endextract
\end{music}
\end{minipage}

\item \mbox{}
\begin{minipage}{\textwidth}
\begin{music}
\setclef{1}{\alto}
\startextract
\notes \wh{c} \en
\endextract
\end{music}
\end{minipage}

\item \mbox{}
\begin{minipage}{\textwidth}
\begin{music}
\setclef{1}{\alto}
\startextract
\notes \wh{g} \en
\endextract
\end{music}
\end{minipage}

\item \mbox{}
\begin{minipage}{\textwidth}
\begin{music}
\setclef{1}{\alto}
\startextract
\notes \wh{g} \en
\endextract
\end{music}
\end{minipage}
\end{enumerate}
\end{document}
  • 1
    You don't need \mbox{}, because of minipage; also \textwidth should be \linewidth. – egreg Dec 8 '19 at 11:01
  • Oh yes. Thanks. Can you explain the difference between textwidth and linewidth? – Niranjan Dec 9 '19 at 5:58

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.