# lualatex hyphenation issue in fancyhdr, with gregoriotex and multicols, latin text

The problem presents as each word in the header becoming hyphenated with each syllable on its own line, making the header unreasonably tall. The problem is intermittent, not occurring on every page.

It seems to occur when there is a Gregorian chant score on a page with a multicols environment that in turn triggers or goes over a page break. However, the chant score is NOT a float - it is a paragraph of text in a very strange font. The multicols environments contain only text - no images or scores or floats of any kind. The text between scores changes between multicols or not with great frequency, sometimes spanning pages. I will put a picture of a typical page (from an original document) before the MWE at the end of this post to show the style I'm trying to copy.

Changing the header to a longish sequence of short, unhyphenable words seems to function fine, so it definitely appears to be a hyphenation issue.

While removing the latin designations in this example "fixes" the problem in some cases, this may be just because spacing changes in the body. It does not fix all cases, so I do not believe it is simply a particular language issue.

Switching from babel to polyglossia for language hyphenation issues does not seem to help, except that polyglossia provides commands \disablehyphenation and \enablehyphenation, which can be used in the header to suppress the problem. That's a "solution" for me, but maybe not everyone.

The MWE is not so M because I have to include the gregorioscore input for this example. Gregorio takes a short text description of a chant - a .gabc file - and converts it to a .gtex file with a similar name. You can either use \input to read the .gtex file or the \gregorioscore command to read the .gabc file. Both are provided in the MWE, just uncomment the one you test with. They ought to be equivalent. Using the .gtex file would eliminate the need for the gregoriotex package, perhaps, but I'm not sure the fonts to represent the chant would be available on other systems without this.

MWE.tex

% !TEX TS-program = lualatex
% !TEX encoding = UTF-8

%latin language setting (plus babel package below)
\documentclass[12pt,twoside,latin]{book}

%Use for English
%\documentclass[12pt,twoside]{book}

\usepackage[oldstyle]{libertine}

% Comment out for English
\usepackage[latin]{babel}

\usepackage[letterpaper]{geometry}

\usepackage{multicol}
\setlength\columnseprule{0.4pt}

%You may comment this line out if you use the .gtex file input instead of the .gabc file.
%\usepackage[autocompile]{gregoriotex} % for gregorio score inclusion

\usepackage{fancyhdr}
\fancyhf{}
\fancyfoot[C]{\rnum{\thepage}}
%
% \fancyhead[C]{Feria II in I Nocturn}
%
%optional english long header with small words - works fine in English language setting
%\fancyhead[C]{This Hdr is quite long but has just small words}
\fancyfoot[C]{\thepage}
\pagestyle{fancy}

\usepackage{gregoriotex}

\usepackage{lipsum}

\begin{document}
\subsection{Feria Secunda}

\subsubsection{In 1 Nocturno}
\vspace*{0.5cm}
%Use only one of the following two lines; the gregorioscore line requires the usepackage{gregoriotex} line above
\input{ExtraTempusPaschale.Secunda.Antiphon.1-5_2_1.gtex}
%\gregorioscore{ExtraTempusPaschale.Secunda.Antiphon.1}
\vspace*{0.5cm}

\begin{multicols}{2}
\lipsum[1-5]
\end{multicols}{2}
\end{document}


File ExtraTempusPaschale.Secunda.Antiphon.1.gabc. Use with the gregorioscore command if gregoriotex 5.2.1 is installed. In that case, you don't need the .gtex file below this.

name: Dominus ;
office-part: Antiphona;
commentary: {\itshape\mdseries Ps.13,2;\/} Off.m.h.135;
mode: 2;
mode-differential:d;
annotation: 1.Ant;
annotation: II.d;
%%
(f3) DO([alt:Extra Tempus Paschale.]h)mi(g)nus(h) <sp>*</sp>( )
de(f) cœ(g)lo(f) pro(e)spé(g)xit(f) (,)
su(f)per(e) fí(f)li(h)os(g) hó(e)mi(gh)num.(f) (::)
<eu> E(h) U(h) O(h) U(g) A(ef) E.(f)  </eu> (::)


File ExtraTempusPaschale.Secunda.Antiphon.1-5_2_1.gtex. Do not use if you can compile from the .gabc file above. Gregorio Tex will create it and include it for you.

% File generated by gregorio 5.2.1
\GregorioTeXAPIVersion{5.2.1}%
% Name: Dominus
\GreBeginScore{502c932081554682fd50cc8f4a972b3d670d7f44}{10}{7}{0}{1}{}{4}{\GreInitialClefPosition{3}{0}}%
\GreAnnotationLines{1.Ant}{II.d}%
\GreMode{\GreModeNumber{2}}{}{}%
\GreSetLargestClef{f}{3}{3}{c}{0}{3}%
\GreScoreOpening{%
}{%
\GreSetInitialClef{f}{3}{3}{c}{0}{3}{1}%
}{%
}{\GreSyllable}{\GreSetFirstSyllableText{D}{O}{}{{}{\GreFirstWord{\GreFirstSyllable{\GreFirstSyllableInitial{O}}}}{}}{{\GreFirstWord{\GreFirstSyllable{\GreFirstSyllableInitial{D}}}}{\GreFirstWord{\GreFirstSyllable{O}}}{}}{}}{}{\GreFirstWord}{0}{\GreSetNextSyllable{\GreFirstWord{m}}{\GreFirstWord{i}}{}{\GreFirstWord{m}}{\GreFirstWord{i}}}{}{0}{}{%
\GreSyllableNoteCount{1}%
\GreSetTextAboveLines{Extra Tempus Paschale.}%
\GreGlyph{\GreCPPunctum}{10}{\GreNextCustos{9}{}}{0}%
{%
\GreGlyphHeights{10}{10}%
}{}{}%
}%
\GreSyllable{\GreSetThisSyllable{\GreFirstWord{m}}{\GreFirstWord{i}}{}{\GreFirstWord{m}}{\GreFirstWord{i}}}{}{\GreFirstWord}{0}{\GreSetNextSyllable{\GreFirstWord{n}}{\GreFirstWord{u}}{\GreFirstWord{s}}{\GreFirstWord{n}}{\GreFirstWord{u}\GreFirstWord{s}}}{}{0}{}{%
\GreSyllableNoteCount{1}%
\GreGlyph{\GreCPPunctum}{9}{\GreNextCustos{10}{}}{0}%
{%
\GreGlyphHeights{9}{9}%
}{}{}%
}%
\GreSyllable{\GreSetThisSyllable{\GreFirstWord{n}}{\GreFirstWord{u}}{\GreFirstWord{s}}{\GreFirstWord{n}}{\GreFirstWord{u}\GreFirstWord{s}}}{}{\GreFirstWord}{1}{\GreSetNextSyllable{}{\GreSpecial{*}}{}{\GreSpecial{*}}{}}{}{0}{}{%
\GreSyllableNoteCount{1}%
\GreGlyph{\GreCPPunctum}{10}{\GreNextCustos{8}{}}{0}%
{%
\GreGlyphHeights{10}{10}%
}{}{}%
}%
%
\GreSyllable{\GreSetThisSyllable{}{\GreSpecial{*}}{}{\GreSpecial{*}}{}}{}{\GreUnstyled}{1}{\GreSetNextSyllable{d}{e}{}{d}{e}}{}{0}{}{%
\GreSyllableNoteCount{0}%
\GreEndOfElement{2}{0}{0}%
}%
%
\GreSyllable{\GreSetThisSyllable{d}{e}{}{d}{e}}{}{\GreUnstyled}{1}{\GreSetNextSyllable{c}{œ}{}{c}{œ}}{}{0}{}{%
\GreSyllableNoteCount{1}%
\GreGlyph{\GreCPPunctum}{8}{\GreNextCustos{9}{}}{0}%
{%
\GreGlyphHeights{8}{8}%
}{}{}%
}%
%
\GreSyllable{\GreSetThisSyllable{c}{œ}{}{c}{œ}}{}{\GreUnstyled}{0}{\GreSetNextSyllable{l}{o}{}{l}{o}}{}{0}{}{%
\GreSyllableNoteCount{1}%
\GreGlyph{\GreCPPunctum}{9}{\GreNextCustos{8}{}}{0}%
{%
\GreGlyphHeights{9}{9}%
}{}{}%
}%
\GreSyllable{\GreSetThisSyllable{l}{o}{}{l}{o}}{}{\GreUnstyled}{1}{\GreSetNextSyllable{pr}{o}{}{p}{ro}}{}{0}{}{%
\GreSyllableNoteCount{1}%
\GreGlyph{\GreCPPunctum}{8}{\GreNextCustos{7}{}}{0}%
{%
\GreGlyphHeights{8}{8}%
}{}{}%
}%
%
\GreSyllable{\GreSetThisSyllable{pr}{o}{}{p}{ro}}{}{\GreUnstyled}{0}{\GreSetNextSyllable{sp}{é}{}{s}{pé}}{}{0}{}{%
\GreSyllableNoteCount{1}%
\GreGlyph{\GreCPPunctum}{7}{\GreNextCustos{9}{}}{0}%
{%
\GreGlyphHeights{7}{7}%
}{}{}%
}%
\GreSyllable{\GreSetThisSyllable{sp}{é}{}{s}{pé}}{}{\GreUnstyled}{0}{\GreSetNextSyllable{x}{i}{t}{x}{it}}{}{0}{}{%
\GreSyllableNoteCount{1}%
\GreGlyph{\GreCPPunctum}{9}{\GreNextCustos{8}{}}{0}%
{%
\GreGlyphHeights{9}{9}%
}{}{}%
}%
\GreSyllable{\GreSetThisSyllable{x}{i}{t}{x}{it}}{}{\GreUnstyled}{1}{\GreSetNextSyllable{}{}{}{}{}}{}{11}{}{%
\GreSyllableNoteCount{1}%
\GreGlyph{\GreCPPunctum}{8}{\GreNextCustos{8}{}}{0}%
{%
\GreGlyphHeights{8}{8}%
}{}{}%
}%
%
\GreBarSyllable{\GreSetThisSyllable{}{}{}{}{}}{}{\GreUnstyled}{1}{\GreSetNextSyllable{s}{u}{}{s}{u}}{}{0}{}{%
\GreSyllableNoteCount{0}%
\GreDivisioMinima{0}{}{1}%
}%
%
\GreSyllable{\GreSetThisSyllable{s}{u}{}{s}{u}}{}{\GreUnstyled}{0}{\GreSetNextSyllable{p}{e}{r}{p}{er}}{}{0}{}{%
\GreSyllableNoteCount{1}%
\GreGlyph{\GreCPPunctum}{8}{\GreNextCustos{7}{}}{0}%
{%
\GreGlyphHeights{8}{8}%
}{}{}%
}%
\GreSyllable{\GreSetThisSyllable{p}{e}{r}{p}{er}}{}{\GreUnstyled}{1}{\GreSetNextSyllable{f}{í}{}{f}{í}}{}{0}{}{%
\GreSyllableNoteCount{1}%
\GreGlyph{\GreCPPunctum}{7}{\GreNextCustos{8}{}}{0}%
{%
\GreGlyphHeights{7}{7}%
}{}{}%
}%
%
\GreSyllable{\GreSetThisSyllable{f}{í}{}{f}{í}}{}{\GreUnstyled}{0}{\GreSetNextSyllable{l}{i}{}{l}{i}}{}{0}{}{%
\GreSyllableNoteCount{1}%
\GreGlyph{\GreCPPunctum}{8}{\GreNextCustos{10}{}}{0}%
{%
\GreGlyphHeights{8}{8}%
}{}{}%
}%
\GreSyllable{\GreSetThisSyllable{l}{i}{}{l}{i}}{}{\GreUnstyled}{0}{\GreSetNextSyllable{}{o}{s}{o}{s}}{}{0}{}{%
\GreSyllableNoteCount{1}%
\GreGlyph{\GreCPPunctum}{10}{\GreNextCustos{9}{}}{0}%
{%
\GreGlyphHeights{10}{10}%
}{}{}%
}%
\GreSyllable{\GreSetThisSyllable{}{o}{s}{o}{s}}{}{\GreUnstyled}{1}{\GreSetNextSyllable{h}{ó}{}{h}{ó}}{}{0}{}{%
\GreSyllableNoteCount{1}%
\GreGlyph{\GreCPPunctum}{9}{\GreNextCustos{7}{}}{0}%
{%
\GreGlyphHeights{9}{9}%
}{}{}%
}%
%
\GreSyllable{\GreSetThisSyllable{h}{ó}{}{h}{ó}}{}{\GreUnstyled}{0}{\GreSetNextSyllable{m}{i}{}{m}{i}}{}{0}{}{%
\GreSyllableNoteCount{1}%
\GreGlyph{\GreCPPunctum}{7}{\GreNextCustos{9}{}}{0}%
{%
\GreGlyphHeights{7}{7}%
}{}{}%
}%
\GreSyllable{\GreSetThisSyllable{m}{i}{}{m}{i}}{}{\GreUnstyled}{0}{\GreSetNextSyllable{n}{u}{m\GreProtrusion{\GreProtrusionFactor{period}}{.}}{n}{um\GreProtrusion{\GreProtrusionFactor{period}}{.}}}{}{0}{}{%
\GreSyllableNoteCount{2}%
\GreGlyph{\GreCPPesOneNothing}{9}{\GreNextCustos{8}{}}{0}%
{%
\GreGlyphHeights{10}{9}%
}{}{}%
}%
\GreSyllable{\GreSetThisSyllable{n}{u}{m\GreProtrusion{\GreProtrusionFactor{period}}{.}}{n}{um\GreProtrusion{\GreProtrusionFactor{period}}{.}}}{}{\GreUnstyled}{1}{\GreSetNextSyllable{}{}{}{}{}}{}{15}{}{%
\GreSyllableNoteCount{1}%
\GreGlyph{\GreCPPunctum}{8}{\GreNextCustos{10}{}}{0}%
{%
\GreGlyphHeights{8}{8}%
}{}{}%
}%
%
\GreBarSyllable{\GreSetThisSyllable{}{}{}{}{}}{}{\GreUnstyled}{1}{\GreSetNextSyllable{ }{E}{}{ }{E}\GreLastSyllableBeforeEUOUAE{1}{0}}{}{0}{}{%
\GreSyllableNoteCount{0}%
\GreDivisioFinalis{0}{}%
%
\GreNextSyllableBeginsEUOUAE{1}{0}%
}%
%
\GreBeginEUOUAE{1}%
\GreSyllable{\GreSetThisSyllable{ }{E}{}{ }{E}}{}{\GreUnstyled}{1}{\GreSetNextSyllable{}{U}{}{U}{}}{}{0}{}{%
\GreSyllableNoteCount{1}%
\GreGlyph{\GreCPPunctum}{10}{\GreNextCustos{10}{}}{0}%
{%
\GreGlyphHeights{10}{10}%
}{}{}%
}%
%
\GreSyllable{\GreSetThisSyllable{}{U}{}{U}{}}{}{\GreUnstyled}{1}{\GreSetNextSyllable{}{O}{}{O}{}}{}{0}{}{%
\GreSyllableNoteCount{1}%
\GreGlyph{\GreCPPunctum}{10}{\GreNextCustos{10}{}}{0}%
{%
\GreGlyphHeights{10}{10}%
}{}{}%
}%
%
\GreSyllable{\GreSetThisSyllable{}{O}{}{O}{}}{}{\GreUnstyled}{1}{\GreSetNextSyllable{}{U}{}{U}{}}{}{0}{}{%
\GreSyllableNoteCount{1}%
\GreGlyph{\GreCPPunctum}{10}{\GreNextCustos{9}{}}{0}%
{%
\GreGlyphHeights{10}{10}%
}{}{}%
}%
%
\GreSyllable{\GreSetThisSyllable{}{U}{}{U}{}}{}{\GreUnstyled}{1}{\GreSetNextSyllable{}{A}{}{A}{}}{}{0}{}{%
\GreSyllableNoteCount{1}%
\GreGlyph{\GreCPPunctum}{9}{\GreNextCustos{7}{}}{0}%
{%
\GreGlyphHeights{9}{9}%
}{}{}%
}%
%
\GreSyllable{\GreSetThisSyllable{}{A}{}{A}{}}{}{\GreUnstyled}{1}{\GreSetNextSyllable{}{E}{\GreProtrusion{\GreProtrusionFactor{period}}{.}}{E}{\GreProtrusion{\GreProtrusionFactor{period}}{.}}}{}{0}{}{%
\GreSyllableNoteCount{2}%
\GreGlyph{\GreCPPesOneNothing}{7}{\GreNextCustos{8}{}}{0}%
{%
\GreGlyphHeights{8}{7}%
}{}{}%
}%
%
\GreSyllable{\GreSetThisSyllable{}{E}{\GreProtrusion{\GreProtrusionFactor{period}}{.}}{E}{\GreProtrusion{\GreProtrusionFactor{period}}{.}}}{}{\GreUnstyled}{1}{\GreSetNextSyllable{}{ }{}{ }{}}{}{15}{}{%
\GreSyllableNoteCount{1}%
\GreGlyph{\GreCPPunctum}{8}{\GreNextCustos{9}{}}{0}%
{%
\GreGlyphHeights{8}{8}%
}{}{}%
}%
%
\GreBarSyllable{\GreSetThisSyllable{}{ }{}{ }{}}{}{\GreUnstyled}{1}{\GreSetNextSyllable{}{}{}{}{}\GreLastOfLine}{}{16}{}{%
\GreSyllableNoteCount{0}%
\GreLastOfScore\GreDivisioFinalis{1}{}%
}%
%
\GreEndEUOUAE{1}%
\GreEndScore %
\endinput %

• I ran the file as posted, inputting the gtex file and get a one page file but I don't see any tower of one syllable hyphenations? Can you show an image of the output you get from this page and mark the bad heading? Jan 29, 2021 at 16:42
• @DavidCarlisle The problem is only visible if you uncomment the \fancyhead command. Jan 29, 2021 at 16:42
• @MarcelKrüger yes I just realised uncomment \fancyhead[C]{Feria II in I Nocturno}  Jan 29, 2021 at 16:44

gregoriotex sets \hyphenpenalty for internal reasons to -200. A negative \hyphenpenalty means that LuaTeX should consider a line ending with a hyphen as better than a line non-hyphenated line. Since in a centered context like your header, there are no other reasons not to make lines longer, LuaTeX will hyphenate whenever possible. You can avoid this by locally changing \hyphenpenalty back to a more sensible value for your header.
E.g. change \fancyhead[C]{Feria II in I Nocturno} to \fancyhead[C]{\hyphenpenalty=50 Feria II in I Nocturno}.
• @UlrikeFischer That's because of the \pretolerance. multicols sets it to -1, so LuaTeX will always try to hyphenate. Otherwise the issue would only occur if it isn't possible to set the header without hyphenation. Jan 29, 2021 at 17:00
• I think that \hyphnpenalty is the real issue here. Even if gregoriotex needs this internally, they should at least reset it after the score. But otherwise I think that reseting in fancyhdr would make sense (or even in general at the beginning of \output. But this triggers the question which values it should be reset too. (Even though it probably doesn't make a big difference since hyphenation shouldn'tbe that common during the output routine) Jan 29, 2021 at 17:24