GeneralMusixTeX: How to add number and label to music extract?

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
MimiKLM
Posts: 8
Joined: Wed Jun 27, 2018 6:35 pm

MusixTeX: How to add number and label to music extract?

Post by MimiKLM »

Hi,

I'm wondering how to add labels, numbering andreferences to music extracts. I'd like to have something like I have for pictures. Is sometthing similar available in MusixTeX?

Thx.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

MusixTeX: How to add number and label to music extract?

Post by Stefan Kottwitz »

First option, you can simply use a figure environment also for pieces of music. It doesn't have to be a picture. So you can have a caption and numbering.

Second option, you could use a theorem environment for music. That's a tool for any numbered environment, not only for theorems or definitions. Quick example:

Code: Select all

\documentclass[a4paper,12pt]{article}
\usepackage[T1]{polski}
\usepackage[cp1250]{inputenc}
\usepackage{pslatex}
\usepackage{graphicx}
\usepackage{framed}
\usepackage{musixtex}
\usepackage[top=1cm,left=2cm,right=2cm,bottom=1cm]{geometry}
\newtheorem{mus}{Music}
\newcommand{\musicref}[1]{(Music \ref{#1})}
\include{musixlyr}
 
\begin{document}
 
\begin{mus}
\label{music:1}
\begin{music}
\setlength\parindent{0pt}
\generalsignature{2}
% use smallest available size:
\smallmusicsize
\renewcommand*\writebarno{\textit{\the\barno}}
\systemnumbers
\setlyrics{text}{%
   Ra-dosť krás-na isk-ra bo-hov E-ly-zej-ská dcé-ra ty, o-má-me-ní
  }
\assignlyrics1{text}
\startextract
\NOtes\qu{ffgh}\enotes
\barre
\NOTes\qu{hgfe}\enotes
\barre
\NOtes\qu{ddef}\enotes
\barre
\NOTes\qup f\cu e\hu e\enotes
\barre
\NOtes\qu{ffgh}\enotes
\endextract
\end{music}
\end{mus}

\begin{mus}
\label{music:2}
\begin{music}
\setlength\parindent{0pt}
\generalsignature{2}
% use smallest available size:
\smallmusicsize
\renewcommand*\writebarno{\textit{\the\barno}}
\systemnumbers
%\setlyrics{text}{
%   Ra-dosť krás-na isk-ra bo-hov E-ly-zej-ská dcé-ra ty, o-má-me-ní
%  }
%\assignlyrics1{text}
%\setlyrics{text}{
%   Ra-dosť krás-na isk-ra bo-hov E-ly-zej-ská dcé-ra ty, o-má-me-ní
%  }
\assignlyrics1{}
\startextract
\NOtes\qu{ffgh}\enotes
\barre
\NOTes\qu{hgfe}\enotes
\barre
\NOtes\qu{ddef}\enotes
\barre
\NOTes\qup f\cu e\hu e\enotes
\barre
\NOtes\qu{ffgh}\enotes
\endextract
\end{music}
 \end{mus}

See \musicref{music:1} and \musicref{music:2}.
\end{document}
music.png
music.png (16.24 KiB) Viewed 3484 times
Stefan
LaTeX.org admin
MimiKLM
Posts: 8
Joined: Wed Jun 27, 2018 6:35 pm

MusixTeX: How to add number and label to music extract?

Post by MimiKLM »

Almost...
But when I compile the piece you presented I got ?? instead of numbers when I refer to my music pieces.

Instead having Music 1 and Music 2 I've got Music ?? and Music ??
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

MusixTeX: How to add number and label to music extract?

Post by Stefan Kottwitz »

Compile two times,

Stefan
LaTeX.org admin
MimiKLM
Posts: 8
Joined: Wed Jun 27, 2018 6:35 pm

MusixTeX: How to add number and label to music extract?

Post by MimiKLM »

And..

1. Using theorem environment how I can move Music 1 under my piece of music to the middle?
2. Using theorem environment how I can modify that Music 1 to be not bold and smaller font?
3. Using figure environment how I can change the name 'Figure' to 'Piece music'?

Thanks
MimiKLM
Posts: 8
Joined: Wed Jun 27, 2018 6:35 pm

MusixTeX: How to add number and label to music extract?

Post by MimiKLM »

Stefan Kottwitz wrote:Compile two times,

Stefan

Great
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

MusixTeX: How to add number and label to music extract?

Post by Stefan Kottwitz »

Here is a figure example. Use the caption package if you would like to customize the captions.

Code: Select all

\documentclass[a4paper,12pt]{article}
\usepackage[T1]{polski}
\usepackage[utf8]{inputenc}
\usepackage{pslatex}
\usepackage{graphicx}
\usepackage{framed}
\usepackage{musixtex}
\usepackage[top=1cm,left=2cm,right=2cm,bottom=1cm]{geometry}
\include{musixlyr}
\usepackage{float}
\renewcommand{\figurename}{Music}
\begin{document}
 
\begin{figure}[H]
\begin{music}
\setlength\parindent{0pt}
\generalsignature{2}
% use smallest available size:
\smallmusicsize
\renewcommand*\writebarno{\textit{\the\barno}}
\systemnumbers
\setlyrics{text}{%
   Ra-dosť krás-na isk-ra bo-hov E-ly-zej-ská dcé-ra ty, o-má-me-ní
  }
\assignlyrics1{text}
\startextract
\NOtes\qu{ffgh}\enotes
\barre
\NOTes\qu{hgfe}\enotes
\barre
\NOtes\qu{ddef}\enotes
\barre
\NOTes\qup f\cu e\hu e\enotes
\barre
\NOtes\qu{ffgh}\enotes
\endextract
\end{music}
\caption{First one.}
\label{music:1}
\end{figure}
 
\begin{figure}[H]
\begin{music}
\setlength\parindent{0pt}
\generalsignature{2}
% use smallest available size:
\smallmusicsize
\renewcommand*\writebarno{\textit{\the\barno}}
\systemnumbers
%\setlyrics{text}{
%   Ra-dosť krás-na isk-ra bo-hov E-ly-zej-ská dcé-ra ty, o-má-me-ní
%  }
%\assignlyrics1{text}
%\setlyrics{text}{
%   Ra-dosť krás-na isk-ra bo-hov E-ly-zej-ská dcé-ra ty, o-má-me-ní
%  }
\assignlyrics1{}
\startextract
\NOtes\qu{ffgh}\enotes
\barre
\NOTes\qu{hgfe}\enotes
\barre
\NOtes\qu{ddef}\enotes
\barre
\NOTes\qup f\cu e\hu e\enotes
\barre
\NOtes\qu{ffgh}\enotes
\endextract
\end{music}
\caption{Second one.}
\label{music:2}
\end{figure}
 
See \ref{music:1} and \ref{music:2}.
\end{document}
Stefan
LaTeX.org admin
Post Reply