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.

2 Answers 2

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

4
  • 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, 2019 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, 2019 at 9:54
  • Why not simply \mbox{}?
    – egreg
    Dec 8, 2019 at 9:59
  • @egreg Yes, it works. Thanks.
    – Niranjan
    Dec 8, 2019 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}
3
  • 1
    You don't need \mbox{}, because of minipage; also \textwidth should be \linewidth.
    – egreg
    Dec 8, 2019 at 11:01
  • Oh yes. Thanks. Can you explain the difference between textwidth and linewidth?
    – Niranjan
    Dec 9, 2019 at 5:58
  • See tex.stackexchange.com/questions/41476/…
    – egreg
    Dec 9, 2019 at 8:54

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.