# text positioning in musixtex without adding horizontal space

I am writing a musical exercise book with musixtex. I'm trying to typeset a single stave with some text positioned beneath it. There are no notes, only the key signatures change and I would like to annotate each bar with the key signature name.

These two examples demonstrate what I am trying to achieve:

\documentclass[11pt,a4paper,BCOR=12mm,DIV=24,headsepline=true,parskip=half]{scrbook}

\usepackage{musixtex}

\begin{document}

% First example, right layout but text missing
\begin{music}
\generalsignature{0}
\nostartrule
\nobarnumbers
\generalsignature{+1}\ignorenats\Changecontext
\generalsignature{+2}\ignorenats\Changecontext
\generalsignature{+3}\ignorenats\Changecontext
\generalsignature{+4}\ignorenats\Changecontext
\generalsignature{+5}\ignorenats\Changecontext
\generalsignature{-1}\ignorenats\Changecontext
\generalsignature{-2}\ignorenats\Changecontext
\generalsignature{-3}\ignorenats\Changecontext
\generalsignature{-4}\ignorenats\Changecontext
\generalsignature{-5}\ignorenats\Changecontext
\setdoublebar
\endpiece
\end{music}

% Second example, adding text messes up layout
\begin{music}
\generalsignature{0}
\nostartrule
\nobarnumbers
\lcharnote{P}{\smalltype{C-Dur}}
\generalsignature{+1}\ignorenats\Changecontext
\lcharnote{P}{\smalltype{G-Dur}}
\generalsignature{+2}\ignorenats\Changecontext
\lcharnote{P}{\smalltype{D-Dur}}
\generalsignature{+3}\ignorenats\Changecontext
\lcharnote{P}{\smalltype{A-Dur}}
\generalsignature{+4}\ignorenats\Changecontext
\lcharnote{P}{\smalltype{E-Dur}}
\generalsignature{+5}\ignorenats\Changecontext
\lcharnote{P}{\smalltype{H-Dur}}
\generalsignature{-1}\ignorenats\Changecontext
\lcharnote{P}{\smalltype{F-Dur}}
\generalsignature{-2}\ignorenats\Changecontext
\lcharnote{P}{\smalltype{B-Dur}}
\generalsignature{-3}\ignorenats\Changecontext
\lcharnote{P}{\smalltype{Es-Dur}}
\generalsignature{-4}\ignorenats\Changecontext
\lcharnote{P}{\smalltype{As-Dur}}
\generalsignature{-5}\ignorenats\Changecontext
\lcharnote{P}{\smalltype{Des-Dur}}
\setdoublebar
\endpiece
\end{music}
\end{document}


Please note that this example has to be compiled in a three step process:

$pdflatex example.tex$ musixflx example.tex
\$ pdflatex example.tex


In the first example, the layout is correct, but the text is not included yet. In the second example, I tried to include the text, but this adds unwanted horizontal space and the layout is messed up, although the documentation promises in section 2.6.13 that no horizontal space will be added.

Also, it would be nice if the text would be centered within each bar.

Does anyone have an idea how to fix the example, or a different solution to achieve the same thing?

Thank you!

• It seems the space is due to the end-of-lines after \lcharnote{P}{\smalltype{C-Dur}}. If you replace those lines by \lcharnote{P}{\smalltype{C-Dur}}% the spacing of both examples is the same Dec 29, 2013 at 16:34
• Wow, great find! This already helps a lot. Now I'm trying to fiddle with hspaces to get the annotations to be centered... If you write your comment as an answer I will accept it. Dec 29, 2013 at 16:43

It seems the space is due to the end-of-lines after

\lcharnote{P}{\smalltype{C-Dur}}


If you replace those lines by

\lcharnote{P}{\smalltype{C-Dur}}%


the spacing of both examples is the same. The output IMHO even looks better when you put the texts in a box overlapping to the right:

\zcharnote{P}{\makebox[0pt][r]{\smalltype{C-Dur}}}%


• I am the expert in adding % at end of lines. ;-) Dec 29, 2013 at 17:37
• @egreg Sorry for fishing in your fishing grounds ;) Dec 29, 2013 at 17:41