\chapter{Managing the Layout of your Score}
\section{Line and page breaking}\label{linebreak}
If every bar ends with \verb|\bar| and no other line- or page-breaking commands
are used, then the external program \verb|musixflx| will decide where to insert
line and page breaks. Line breaks will only come at bar lines. The total
number of lines will depend on the initial value of \verb|\elemskip|, which by
default is \verb|6pt| in \verb|\normalmusicsize|.

You can force a line or page break by replacing \keyindex{bar} with
\keyindex{alaligne} or \keyindex{alapage} respectively. On the other hand,
to forbid line-breaking at a particular bar, replace \verb|\bar|
with \keyindex{xbar}. To force a line or page break where there is
no bar line, use \keyindex{zalaligne} or \keyindex{zalapage}. To mark any
mid-bar location as an optional line-breaking point, use \keyindex{zbar}.

The heavy final double bar of a piece is one of the consequences of
\keyindex{Endpiece} or \keyindex{Stoppiece}. If you just want to terminate
the text with a simple bar, say \keyindex{stoppiece} or \keyindex{endpiece}.
If you want to suppress right-justification of the last line of a score,
use \keyindex{raggedstoppiece}.
To terminate it with no bar line at all, code \keyindex{zstoppiece}.

Once you have stopped the score by any of these means, you may want to restart
it, and there are several ways to do so. If you don't need to change the key
signature, meter, or clef,
you can use \keyindex{contpiece} for no indentation, or \keyindex{Contpiece}
to indent by \keyindex{parindent}. If you do want to change some score
attribute that takes up space, for example
with \keyindex{generalsignature} after \verb|\stoppiece|, then to restart you
must use \keyindex{startpiece}. However, if you don't want \verb|\barno| reset
to 1, you must save its new starting value to \verb|\startbarno|. You may also
wish to modify instrument names or \verb|\parindent| before restarting.

Recall that thin-thin or thin-thick double bars or blank bar lines can be
inserted without stopping by using the commands described in Section~\ref{doublebars}. 
Those commands can also be used before \verb|\stoppiece|,
\verb|\alaligne|, or \verb|\alapage|

\section{Page layout}
Blank space above and below each staff is controlled by the dimension
registers \keyindex{stafftopmarg} and \keyindex{staffbotmarg}. For more
info see Chapter~\ref{LayoutParameters}.

The macro \keyindex{raggedbottom} will remove all vertical glue and
compact everything toward the top of page.
In contrast, the macro \keyindex{normalbottom} will restore default
behavior, in which vertical space between the systems is distributed
so that the first staff
on the page is all the way at the top and the last staff all the way at
the bottom.
The macro \keyindex{musicparskip} will allow the existing space between
systems to increase by up to \verb|5\Interligne|.

The following values of page-layout parameters will allow as much material
as possible 
on a page, provided the printer supports these dimensions which
imply approximately half-inch margins:

\begin{center}
\begin{tabular}{|l|l|}\hline
\multicolumn{1}{|c|}{A$4$}&\multicolumn{1}{|c|}{letter}\\\hline
\verb+\hsize=190mm+&\verb+\hsize=7.5in+\\\hline
\verb+\vsize=270mm+&\verb+\vsize=10in+\\\hline
\end{tabular}
\end{center}
\zkeyindex{parindent}\zkeyindex{hoffset}\zkeyindex{voffset}
\zkeyindex{hsize}\zkeyindex{vsize}
You may have to be more conservative if you have headlines or footlines
or want
even/odd-page asymmetry, such as with the \keyindex{rectoverso}
command in \verb|musixsty.tex| (Section~\ref{musixsty}).
If a score is going to be ``published'' at a public repository (such as
\mbox{\textsc{imslp}}), you may want to allow for \emph{either}
A$4$ \emph{or} letter paper, for example  by setting the \verb|\hsize| to~190~mm
and the \verb|\vsize| to~10~in.

To generate a score in ``landscape''\index{landscape mode} mode, adjust the 
text-size parameters above accordingly (e.g., \verb+\hsize=10in+ and \verb+\vsize=7.5in+)
and add a suitable \verb\papersize\ ``special'' to the \TeX\ output, as in 
\verb+\special{papersize=11in,8.5in}+.


For \emph{any} values of 
\verb|\hsize| and \verb|\vsize|,
material will normally be centered on the page by using 
command sequences such as the following, which simply split the difference between the page size and the text size, 
and then subtract one inch because of \TeX\ conventions:
\begin{enumerate}
\item[For A$4$ paper, portrait mode (210~mm $\times$ 297~mm):]\quad\\[-2ex]
\begin{verbatim}
\hoffset=210mm\advance\hoffset-\hsize\divide\hoffset2
\advance\hoffset-1.0in
\voffset=297mm\advance\voffset-\vsize\divide\voffset2
\advance\voffset-1.0in
\end{verbatim}
\item[For letter-size paper, portrait mode (8.5~in $\times$ 11~in):] \quad\\[-2ex]
\begin{verbatim}
\hoffset=8.5in\advance\hoffset-\hsize\divide\hoffset2
\advance\hoffset-1.0in
\voffset=11in\advance\voffset-\vsize\divide\voffset2
\advance\voffset-1.0in
\end{verbatim}
\end{enumerate}

To determine the maximal dimensions that \emph{your} printer is capable of, 
process the standard file \verb|testpage.tex| with \LaTeX\ and
print the result. The ``rulers'' on four sides will indicate
how much of the one-inch ``margin'' material outside the frame can actually be printed.
Your \verb|\hsize| and \verb|\vsize| parameters can be increased, or, if necessary, decreased
accordingly.  If your score is going to be printed by a publisher or a colleague, you can send
\verb|testpage.pdf| to them to determine what margins are necessary for their
printer.

However, if the margins on the \verb|testpage| output are \emph{not} 
symmetric, 
the printer is mis-aligned.
If this can't be corrected, the margin offsets will 
have to be adjusted. Ideally, this should be done in the \TeX\ configuration
so all \TeX\ output will be corrected, but offsets can be adjusted
for just \verb|musixtex| output using
\verb|\advance\hoffset ...| and/or
\verb|\advance\voffset ...|
after the ``normal'' settings given above.




\section{Page numbering, headers and footers}\index{page
number}\index{footnote}

There are no special page numbering facilities in \musixtex; you must rely on
macros from plain \TeX. There is a count register in \TeX\ called
\verb|\pageno|. It is always initialized to $1$ and incremented by one
at every page break. By saying \keyindex{pageno}\verb|=|$n$, it can be reset to any
value at any time, and will continue to be incremented from the new value.

By default, \TeX\ will place a page number on
every page, centered at the bottom. Unfortunately, this is not the preferred
location according to any standard practice. To suppress this default
behavior, say \keyindex{nopagenumbers}.

One way to initiate page numbering in a more acceptable location is to take
advantage of the facts that (a) \TeX\ prints the contents of the control sequences
\keyindex{headline} and \keyindex{footline} at the top and bottom
respectively of every page, and (b) the value of \verb|\pageno| can be printed by
saying \keyindex{folio}. Therefore, for example, the following sequence of
commands, issued anywhere before the end of the first page, will cause page
numbers and any desired text to be printed at the top of every page,
alternating between placement of the number at the left and right margins, and
alternating between the two different text strings (the capitalized text in
the example):

\begin{quote}\begin{verbatim}
\nopagenumbers
\headline={\ifodd\pageno\rightheadline\else\leftheadline\fi}%
\def\rightheadline{\tenrm\hfil RIGHT RUNNING HEAD\hfil\folio}%
\def\leftheadline{\tenrm\folio\hfil LEFT RUNNING HEAD\hfil}%
\voffset=2\baselineskip
\end{verbatim}\end{quote}

\section{Controlling the total number of systems and pages}\index{page/line layout}

Once all the notes are entered into a \musixtex\ score, it would be convenient
if there were a simple sequence of commands to
cause a specified number of systems to be uniformly distributed over a
specified number of pages. Unfortunately that's not directly
possible\footnote{It \textit{is} possible in \textbf{PMX}.}.
Rather, some trial and error will usually be required to achieve the desired final
layout. To this end, some combination of the following strategies may be used:

 \begin{enumerate}\setlength{\itemsep}{0ex}
  \item Assign a value to the count register \keyindex{linegoal} representing
the total number of systems. The count register \keyindex{mulooseness} must be $0$ if using
\verb|\linegoal|.
  \item Explicitly force line and page breaking as desired, using
the macros \verb|\alaligne|, \verb|\alapage|, \verb|\zalaligne|
or \verb|\zalapage|.
  \item Adjust both \keyindex{mulooseness} and the initial value of
\keyindex{elemskip}: increasing \verb|\mulooseness| from its default of 0 will
increase the total number of systems, while changing the initial value of
\verb|\elemskip| (use \verb|\showthe\elemskip| to find its default value) may change the
total number of systems accordingly.
 \end{enumerate}
