sillsdev / ptx2pdf

XeTeX based macro package for typesetting USFM formatted (Paratext output) scripture files
23 stars 8 forks source link

The Cover won't format as the first page anymore #753

Closed davidc86 closed 2 years ago

davidc86 commented 2 years ago

The Cover wont' format as the first page anymore. (And we need a blank second page, after the cover, but before the title page)

image

Here is the USFM:

\id FRT - Selaru \rem hahahaha KONSEP DASAR – BOB 25 Sept 2014 \rem Beta tambah info kover, judul, dll. David 7/Juli/2016 \rem updated David April 22, 2018 \rem updated again, David, May 11, 2019 \rem updated David, Mar 3, 2021 \zfiga|000* \nopagenums \ipc \periph Back of cover \periph Title page \ipc \ipc \ipc \ipc \ipc \ipc \mt1 Kitab Lanke \mt2 ti Tel Maslyarkwe \b \b \mt1 Alkitab \mt2 dalam bahasa Selaru \b \b \b \b \b \b \b \b \b \ipc Edisi Percobaan \ipc 2022 \im \pb \periph Verso Page \imt Kitab Lanke ti tel Maslyarkwe \ipc Alkitab dalam bahasa Selaru \ipc The Bible in the Selaru language \zfiga|001* \ipc © 2022 Yayasan Pemberdayaan Masyarakat Desa-KKT, dan \zfiga|002* \ipc © 2022 Wycliffe Bible Translators, Inc. \ipc ISBN belum \ipc Bagian-bagian dari Perjanjian Lama dan Baru dalam bahasa Selaru ...

Any ideas? Around v2.2.24 or so, the cover stopped being first. Is started appearing after a blank first page, with the page after the cover being the title page. But now the title page is first, then comes the cover, no blank page, and then comes the copyright page.

What we want is: COVER Blank page Title page Copyright page ...

Whatever I do in the Front Matter editor isn't working. Thanks for any help.

davidg-sil commented 2 years ago

I can confirm that, given that input usfm, that's what you get, assuming that the image is set with "Fc" or "Pc" . If you remove the \rems from the beginning, then you will get instead:

But there is a much better way to produce a cover page, I just can't find my demonstration file yet.

Blank pages can be forced with e.g.

[cover page]
\pb
\rem back of cover page
\mt
\ip
\pb
davidg-sil commented 2 years ago

Front cover example with a picture. The contents of the 'sidebar' is printed on top of the 'background image' If there is no content, then put in a non-breaking space (~)

\id FRT
\esb \cat frontcover\cat*
\mt1 ~
\esbe

Stylesheet:

\Marker cat:frontcover|esb
\Position Fc
\BgImage SlithyToves.jpg
davidg-sil commented 2 years ago

Modified example, with text. I put the text into a character style so that a background colour can be applied to it, since this isn't exactly a purpose-made front cover image.

\id FRT
\esb\cat frontcover\cat*
\mt1 \qt A Test Case \qt*
\esbe

Stylesheet:

\Marker cat:frontcover|esb
\Position Fc
\BgImage SlithyToves.jpg

\Marker cat:frontcover|mt1
\Background xffffff

image

davidc86 commented 2 years ago

Thanks for that trick. I had to look up what you were suggesting in the USFM Reference PDF file, and I see you are hacking an extended "sidebar" marker and category tags. The picture shows it works (though I'd rather hide the text that is used to anchor the illustration). But doing all of that is kind of beyond normal users.

So, while that solution works, doesn't that seem a bit convoluted to solve a simple normal-user request: "Here is the cover illustration. Please put make it the cover for the book. Thanks."

For that reason, I'm still trying to leverage PTXprint's Front Matter file to get the desired result, but it is still less than ideal, because the PTXprint processor makes some assumptions that are causing formatting issues for us.

Assumption 1: "If there are a bunch of blank/empty lines (SFMs) at the top of the page, delete them, and put the first SFM with content at the top of the page." This assumption is fine for most places, but is not good in formatted front matter, where we know the location of a page break and we want to move text down and center it on the page. (Even the official "blank line" SFM (\b) doesn't work at the top of the page.)

Assumption 2: "If the user has selected "Horizontal Rule" on the Layout page, use it everywhere, regardless of where the content occurs." Again, this might be good for the main Scripture portion of the book, but for front matter, TOC, glossary, maps, helps, etc., it is unlikely that a horizontal rule is wanted in ALL of those places. So, a switch to turn off horizontal rule in certain sections is needed. (E.g. \nohorizonalrule -- to turn off that feature until the next book or the next \periph.)

BUT: If I put a dummy "COVER" text at the beginning of the Front Matter, so the picture can hook to it (but it still is restricted to within the column or span at this point). If I put a dummy \pb and a \ipc . line in the place where I want a blank page after the cover. If I turn off horizontal rule for the entire project. If I turn off option to put page numbers at the bottom of Intro material pages If I put full stops in the \ipc lines on the title page before the \mt.

Then we start to get a PRD file that looks like we want. (Except of course there is the word "COVER" on the cover page, and the picture doesn't fill the page, and there are dots on the blank and title pages, and there is no horizontal rule for the scripture section of the PDF, and there are no page numbers on the Intro pages.)

Any thoughts or plans for expanding the handling of Peripheral Matter for "normal users"? (Like to optionally treat peripheral material layout different (or tweaked) from the main layout. I.e. we set up the main layout, then click "Peripheral Layout", and we get the same page with all the same settings, but we can then turn on/off features or make adjustments.)

davidg-sil commented 2 years ago

Regarding the side-bars, I think you've misunderstood what's going on, a bit. The text in the sidebar doesn't anchor the image, it just ensures that the sidebar doesn't get declared empty and skipped. A non-breaking space is sufficient to be 'not empty'. More on that later.

I've realised that I was a bit wrong yesterday. The XeTeX code can position an image as the front page, but it looks like it can only do that if the \img ...\img* is not stripped out of the text first.

\id FRT
\rem some junk
\ip
\fig |loc="P" src="image.jpg" size="full" scale="1.0" \fig*

I expect that PTXprint is 'overly helpful' and puts such images into the piclist, though.

The problem is that for other things to work (like correct anchoring of an image in a cut-out), \zimga acts as a zero-width piece of text. If there's any text on the page before the image (including zero-width text!), then the image will be put on the next page. Hence the blank page.

The text in the sidebar is not an image anchor point, but (for rather complex reasons I won't go into) if a sidebar is totally empty it does not get displayed, hence if there's no text to appear, a non-breaking space is recommended. I've not tested it, but I would expect a non-breaking space would also stop any 'disregard empty lines at the start of the page' issues. If it doesn't, then \strut is a TeX command that makes a zero-width as-high-as-a-letter invisible line. That works in some places where a space does not.

Sidebars get positioned very much like images, but they can have a background image, a 'logo' type foreground image (e.g. history sidebars might be distinguished by an image of a scroll), and any textual / in-line image content that you might want to put into them. In the above example, I just specified a background image. As side-bars are not (AFAIK) pulled out of the input, they can appear as the first page.

As you say, setting up a sidebar is probably a bit advanced for people getting started who just want a cover picture, and while yes, there have been some work done on a cover editor, that's a while off, I think. Or maybe it's there already and I've just not found out where it is.

I've therefore just added a new anchor-point bookstart which is triggered on reading the \id line of the (specified) SFM file.

image

mhosken commented 2 years ago

I created a simple cover with a title and image and found it inserted a blank page at the beginning. This was caused by having some initial space before the title and then for the rest of the page to overflow the page. In order to break nicely, it put the space on the first page (now blank) and the rest on the second page. Reducing the initial space suitably, brought everything back into harmonious alignment.

davidc86 commented 2 years ago

Yes! Changing anchor from "FRT 000" to "FRT bookstart" in the Pictures Details page worked! Thanks! Nice.