4

I'm trying to write an extract of music with two instruments, and then resize it with a scalebox (I also tried with a resizebox and the problems are the sames).


First I tried:

\documentclass{standalone}

\usepackage{musixtex}
\usepackage{graphicx}
\begin{document}

  \scalebox{1.0}{%
  \begin{music}%
    \instrumentnumber{2}%
    \setclef10%
    \setclef20%
    \nobarnumbers%
    \startextract%
      \notes \qa c & \qa d \en%
    \endextract%
  \end{music}%
  }

\end{document}

And I get this error when I compile:

! Misplaced alignment tab character &.
<argument> ...numbers \startextract \notes \qa c &
                                                   \qa d \en \endextract \en...
l.17   }


Then I tried to put the music extract into a figure environment and then to scale it:

\documentclass{article}

\usepackage{musixtex}
\usepackage{graphicx}
\begin{document}

  \scalebox{1.0}{%
  \begin{figure}[h!]
    \begin{music}%
      \instrumentnumber{2}%
      \setclef10%
      \setclef20%
      \nobarnumbers%
      \startextract%
        \notes \qa c & \qa d \en%
      \endextract%
    \end{music}%
  \end{figure}
  }

\end{document}

And I got this error message:

! LaTeX Error: Not in outer par mode.


I, then, also tried to scale an extract with one instrument and two staffs, I did this:

\documentclass{standalone}

\usepackage{musixtex}
\usepackage{graphicx}
\begin{document}

  \scalebox{1.0}{
  \begin{music}
    \instrumentnumber{1}
    \setstaffs 1{2}
    \setclef{1}{00}
    \startextract
      \notes \qa c | \qa d \en
    \endextract
  \end{music}
  }

\end{document}

This compile, but It's doing this:

Image

As we can see, instead of having a note on each staffs, both notes are on the bottom staff, and there is a pipe between the notes.

So, i there a way to achieve what I'm trying to do ?

  • That's an interesting observation. Even if one just puts the music environment in a savebox and uses it, the same issue arises. – user121799 Aug 4 '18 at 13:52
  • This is not an answer, just a recommendation: MusiXTeX does a poor job and I really advise you to switch to LilyPond. While I love TeX, it's not a tool for music typesetting, which is very complex. If you plan to typeset more music, the sooner you switch the better. – yo' Aug 4 '18 at 17:20
4

This is not a full answer, but a workaround. With xsavebox you can rescale the notes.

\documentclass{standalone}
\usepackage{musixtex}
\usepackage{graphicx}
\usepackage{xsavebox}

\begin{document}

\begin{xlrbox}{mybox}%
\begin{music}
    \instrumentnumber{1}
    \setstaffs1{2}
    \setclef{1}{00}
    \startextract
      \notes \qa c | \qa d \en
    \endextract
  \end{music}%
\end{xlrbox}  


\fbox{\themybox}~\scalebox{0.6}{\themybox}

\end{document}

enter image description here

And one way to squeeze the very generous bounding box is to work with minipages.

\documentclass{standalone}
\usepackage{musixtex}
\usepackage{graphicx}
\usepackage{xsavebox}

\begin{document}

\begin{xlrbox}{mybox}%
\begin{minipage}{3cm}
\begin{music}
    \instrumentnumber{1}
    \setstaffs1{2}
    \setclef{1}{00}
    \startextract
      \notes \qa c | \qa d \en
    \endextract
  \end{music}%
\end{minipage}%  
\end{xlrbox}  


\fbox{\themybox}~\scalebox{0.6}{\themybox}

\end{document}

enter image description here

And amazingly TikZ also works.

\documentclass{standalone}
\usepackage{musixtex}
\usepackage{graphicx}
\usepackage{xsavebox}
\usepackage{tikz}
\begin{document}

\tikz{\node[draw]{\begin{music}
    \instrumentnumber{1}
    \setstaffs1{2}
    \setclef{1}{00}
    \startextract
      \notes \qa c | \qa d \en
    \endextract
  \end{music}};}
~
\tikz{\node[draw,scale=0.6]{\begin{music}
    \instrumentnumber{1}
    \setstaffs1{2}
    \setclef{1}{00}
    \startextract
      \notes \qa c | \qa d \en
    \endextract
  \end{music}};}

\end{document}

enter image description here

  • I prefer the TikZ way, I find it more convenient. I just added \hspace{-80pt} to reduce the space on each sides. Thanks a lot – Phantom Aug 4 '18 at 16:14
  • @Phantom If you go the TikZy way, you could also work with a negative inner xsep, e.g. \tikz{\node[draw,scale=0.6,inner xsep=-140pt]{\begin{music} .... . – user121799 Aug 4 '18 at 19:03
  • It does not really change the render, but it's simpler. Thanks – Phantom Aug 4 '18 at 19:32

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.