fancyhdr, multicols and gregoriotex problem

174 views
Skip to first unread message

Rob Leduc

unread,
Jan 28, 2021, 10:58:36 AM1/28/21
to Gregorio Users

I'm having problems with headers in a file (mwe attached, although it is only as m as I could make it, since the problem is over a page break, and includes one short score).

The TL;dr - you'll see the problem from the MWE attached.  Probably insurmountable problems with multicols.  But if there is anything that can be done, or alternate packages to use, I'd love to know.

Details:

I expect based on what I've found is the problem is with the package multicols that does not handle floats, and that a general solution appears to be insurmountable for that package.  So there may be no fix to my problem with these packages, in which case recommendations of other packages or other paths to a formatting solution may be the only hope.  I'm going to also post at Stack Exchange since this may not really be a Gregorio Tex problem.  I suspect Gregorio just creates the float which multicols can't handle.  However, expertise here in possibly typesetting in similar formats may help me avoid the problem.

I'm trying to reproduce material in the style of the Nocturnale Romanum (e.g. https://gregobase.selapa.net/source.php?id=23&images=1&index=4  and ff.).  As we all know, such books often have many sections of partial pages of two column text, chants (probably floats? from gregorio tex).  I also want a header that I can change, preferably supplying my own text at each change, but if necessary built from section headings and the like.  The latter would require flexibility in order to match the original.

My problem is that at certain (but not all) page breaks, the multicols environment seems to screw up the fancy header, but only if there is a chant involved somewhere.  I understand LaTeX can start preparing material for the next page before assigning the location of a page break, and this is likely at the heart of it.

Compiling the attached example (currently linked to the gtex file for Stack Exchange purposes) will show the problem; changing the header by commenting out one line and uncommenting the other as indicated in mwe.tex will show without the problem.  It appears not enough horizontal line space is being allowed for the header, causing bad line breaks in the header and warnings about needing more space for the fancy header.

And yes, the formatting is hell because I've tried to distill it down to an MWE.  This obviously bears no relation to how I've actually formatted this.

Any help, be it suggestions of other packages or methods, or work arounds with these packages, or redefinitions of other items would be most appreciated.

Thank you!

Rob Leduc

For whatever reason, I can't seem to attach files - google just gives me an error on posting - so will have to post the text in the message body.

File - ExtraTempusPaschale.Secunda.Antiphon.1.gabc:

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> (::)


MWE.tex:

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

\documentclass[12pt,latin,twoside]{book}
\usepackage{babel}



\usepackage{geometry}
\geometry{letterpaper}

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

\usepackage[autocompile]{gregoriotex} % for gregorio score inclusion
\newcommand{\flexsymbol}{ }
\newcommand{\psalmstar}{*}

\usepackage{fancyhdr}
\fancyhf{}
\fancyfoot[C]{\rnum{\thepage}}
%Changing between these two headers will show with and without problems.
\fancyhead[C]{Feria II \\* in I Nocturno}
%\fancyhead[C]{Test}
\renewcommand{\headrulewidth}{2pt}
\fancyfoot[C]{\thepage}
\pagestyle{fancy}


\begin{document}
\subsection{Feria Secunda}

\subsubsection{In 1 Nocturno}
\vspace*{0.5cm}
\gregorioscore{ExtraTempusPaschale.Secunda.Antiphon.1}
\vspace*{0.5cm}

\begin{multicols}{2}
{\itshape Sub una tantum Antiphona\/ {\upshape Allelúja,} in hac et aliis Feriis, dicuntur tres Psalmi in unoquoque Nocturno a Feria 2
post Dominicam in Albis usque ad Feriam 6 post Octavam Ascensionis, si Festum de Sanctis novem Lectionum celebretur; et novem
continuatim recitantur Psalmi in unico Nocturno usque ad Vigiliam Ascensions, si Officium trium Lectionum de Tempore vel de Sanctis agatur.

{\upshape \textpilcrow} Antiphonæ, tam intra quam extra Tempus Paschale, in hac et aliis Feriis appositæ, dicuntur semper in Officio feriali et in Festis
sive trium sive novem Lectionum, quando juxta Rubricas sumendi sing Psalmi de Feria, ut in Psalterio; Versus autem, per Annum in singulis Nocturnis assignati, adhibentur etiam in Festis, quæ Tempore Adventus, Quadragesimæ ac Passionis celebrantur.

In Officio autem trium Lectionum, tam de tempore quam de Sanctis, omittuntur Versus et reliqua omnia, quæ in Officio novem Lectionum solent
recitari in fine 1 et 2 Nocturni, et continuantur Psalmi (cum suis Antiphonis extra Tempus Paschale) usque ad versum 3 Nocturni.
}

Dixit insípiens in corde suo:\psalmstar non est Deus.

Corrúpti sunt, et abominábiles facti sunt in stúdiis suis:\psalmstar non est qui fáciat bonum, non est usque ad unum.

Dóminus de cælo prospéxit super fílios hóminum,\psalmstar ut vídeat si est intéllegens, aut requírens Deum.

Omnes declinavérunt, \flexsymbol simul inútiles facti sunt:\psalmstar non est qui fáciat bonum, non est usque ad unum.

Sepúlcrum patens est guttur eórum: \flexsymbol linguis suis dolóse agébant\psalmstar venénum áspidum sub lábiis eórum.

Quorum os maledictióne et amaritúdine plenum est:\psalmstar velóces pedes eórum ad effundéndum sánguinem.

Contrítio et infelícitas in viis eórum, \flexsymbol et viam pacis non cognovérunt:\psalmstar non est timor Dei ante óculos eórum.

Nonne cognóscent omnes qui operántur iniquitátem,\psalmstar qui dévorant plebem meam sicut escam panis?

Dóminum non invocavérunt,\psalmstar illic trepidavérunt timóre, ubi non erat timor.

Quóniam Dóminus in generatióne justa est, consílium ínopis confudístis:\psalmstar quóniam Dóminus spes ejus est.

Quis dabit ex Sion salutáre Israël? \flexsymbol  cum avérterit Dóminus captivitátem plebis suæ,\psalmstar exsultábit Jacob, et lætábitur Israël.
\end{multicols}

\end{document}

Rob Leduc

unread,
Jan 28, 2021, 11:28:53 AM1/28/21
to Gregorio Users
Actually, I may have to change my description a bit.

I've tried replacing the chant with a jpg picture of it created from Mac OSX grab tool, and I'm having a hard time replicating the problem.  So maybe it is related to Gregorio Tex's interaction with the LaTeX output routine, in terms of describing the size of the output image of the chant?

Rob

Fr. Samuel Springuel

unread,
Jan 28, 2021, 2:41:20 PM1/28/21
to gregori...@googlegroups.com
> On 28 Jan, 2021, at 11:28 AM, Rob Leduc <rled...@gmail.com> wrote:
>
> Actually, I may have to change my description a bit.
>
> I've tried replacing the chant with a jpg picture of it created from Mac OSX grab tool, and I'm having a hard time replicating the problem. So maybe it is related to Gregorio Tex's interaction with the LaTeX output routine, in terms of describing the size of the output image of the chant?
>
> Rob
>

Chant is not output as an image or float in GregorioTeX they are paragraphs of (complicated) text. The words and neumes are fonts (which are put into boxes in order to get better control over the relative positioning). This allows us to make use of the automatic line breaking algorithms and let the chant adapt to the various page sizes.

> Compiling the attached example (currently linked to the gtex file for Stack Exchange purposes) will show the problem; changing the header by commenting out one line and uncommenting the other as indicated in mwe.tex will show without the problem. It appears not enough horizontal line space is being allowed for the header, causing bad line breaks in the header and warnings about needing more space for the fancy header.

I don’t think changing the header is solving the problem, so much as hiding it because the replacement header isn’t wide enough to force the header onto multiple lines. In fact, if I use either of the following headers (both of which force themselves to three lines):

\fancyhead[C]{Test \\ test \\ test}
\fancyhead[C]{Testing testing testing testing more testing more testing more testing more testing more testing\\ test}

The problem rears its head even with the score replaced by \rule{\textwidth}{0.56in}, so while GregorioTex certainly has an interaction here, I’m not sure it’s the root cause.

You might want to look deeper into how fancyhdr sets the relative widths of the three header components (left, right, and center) and how multicols might effect this.


✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝
Fr. Samuel, OSB
(R. Padraic Springuel)
St. Anselm’s Abbey
4501 South Dakota Ave, NE
Washington, DC, 20017
202-269-2300
(c) 202-853-7036

PAX ☧ ΧΡΙΣΤΟΣ

Olivier Berten

unread,
Jan 28, 2021, 4:18:38 PM1/28/21
to gregori...@googlegroups.com
On my system, as soon as \gregorioscore is commented out, the problem disappears. No problem with \rule. On the other hand, on my system I could add to the header as many words up to 4 characters each without problem. Every word longer than that gets hyphenated with a line break. So it seems like an hyphenation interference.

Olivier

--
Gregorio homepage: http://gregorio-project.github.io
Archives for the old mailing list: http://www.mail-archive.com/gregori...@gna.org/
To report a bug, please post to: https://github.com/gregorio-project/gregorio/issues
---
You received this message because you are subscribed to the Google Groups "Gregorio Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gregorio-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gregorio-users/AA5C7E8F-E236-406B-8865-4CF2C5730C38%40gmail.com.

Rob Leduc

unread,
Jan 28, 2021, 4:37:20 PM1/28/21
to Gregorio Users
Thanks so much, Fr. Samuel and Olivier!

The culprit seems to be the latin option in the class statement.  Removing that fixes everything (if it doesn't break something else! :) )

Like a lot of rookies, I've grabbed too many bits of code from elsewhere and didn't pay much attention until something started not to work.  Perhaps this option is duplicative of the babel package and I can just do without.  But it's time to read some more package documentation, I think.

In any case, the main problem is likely hyphenation as Olivier said, and the latin option seems to be a linchpin, if not directly the culprit.

Thanks for the help!

Rob

Rob Leduc

unread,
Jan 29, 2021, 8:17:38 AM1/29/21
to Gregorio Users

It looks like I've "solved" this problem, in a way.  I've switched my multilanguage support from babel to the polyglossia package.  Polyglossia provides switches \disablehyphenation and \enablehyphenation.  Including these in my fancy header \fancyhead command, bracketing the header text, suppresses hyphenation in the header (only) and fully prevents the issue, while (hopefully) still retaining latin language and hyphenation support.

Obviously less than ideal from a programming standpoint, and there has to be a bug for someone's package somewhere.  But at least this works.

There appear to have been (in the past) difficulties with loading hyphenation patterns for Latin.  These threads are old and certainly can't represent the current state of affairs, but I am still trying to determine if my hyphenation rules are being loaded correctly.  See, for example,

Rob Leduc

unread,
Jan 29, 2021, 4:40:08 PM1/29/21
to Gregorio Users

The good folks at Stack Exchange LaTeX forum seem to have identified the guts of my problem, and it's possibly something involving a possible change to Gregoriotex for a future revision:

https://tex.stackexchange.com/questions/581013/lualatex-hyphenation-issue-in-fancyhdr-with-gregoriotex-and-multicols-latin-te/581022

Apparently, multicols sets \pretolerance to -1, while Gregoriotex sets a hyphen penalty of -200.  The combination results in fancyhdr wanting to hyphenate every single word in a centered header.  One suggestion to the developers of gregoriotex is to restore the hyphen penalty following completion of a score, although this alone might not be sufficient with scores that are multiple pages long, like a hymn or invitatory psalm setting.  It is also possible that the other packages should consider modifications. 

This is all beyond my simple understanding, and so I just pass it along here.

Rob

Fr. Samuel Springuel

unread,
Jan 30, 2021, 3:24:13 PM1/30/21
to gregori...@googlegroups.com
> On 29 Jan, 2021, at 4:40 PM, Rob Leduc <rled...@gmail.com> wrote:
>
> One suggestion to the developers of gregoriotex is to restore the hyphen penalty following completion of a score,

We already do this.
Reply all
Reply to author
Forward
0 new messages