PreTeXtBook / pretext

PreTeXt: an authoring and publishing system for scholarly documents
https://pretextbook.org
Other
254 stars 203 forks source link

Add publication/latex/@openodd #2034

Closed jjrsylvestre closed 9 months ago

jjrsylvestre commented 9 months ago
  1. Borrowed from https://tex.stackexchange.com/questions/185821/openright-in-oneside-book
  2. Hopefully not too hacky.
  3. Wasn't sure where in the preamble you would want to put it.
  4. Wasn't sure if different document classes might need to be handled differently, so I just put in the common preamble.
kcrisman commented 9 months ago

This is a great idea as an option. Two comments:

sed -i '' 's/documentclass\[oneside/documentclass\[twoside/' foo.tex

mitchkeller commented 9 months ago

Any time I see sed, my hackles get raised. GNU sed (Linux and I presume WSL) and BSD sed (macOS) have some fundamentally different behaviors that makes using sed in an open-source project where folks might be building on different platforms just an absolute nightmare. (We navigated this early on with EPUB.)

sed works when itโ€™s basically just the author doing things, but as soon as others get involved, itโ€™s best to find a better method.

On Aug 3, 2023, at 8:29 AM, kcrisman @.***> wrote:

This is a great idea as an option. Two comments:

Obviously this will have to be in the guide somewhere, preferably multiple places. I expect people will use it, so that pdf and print match page numbers. Would just changing the document class option be easier/more correct, or worse? It's what I use, in a custom build script I certainly don't mean to imply is "correct PTX" ๐Ÿ˜„ but which I did for precisely this reason. sed -i '' 's/documentclass[oneside/documentclass[twoside/' foo.tex

โ€” Reply to this email directly, view it on GitHub https://github.com/PreTeXtBook/pretext/pull/2034#issuecomment-1663986979, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACBOYNZMPKY2BF5QICHCYXTXTORSBANCNFSM6AAAAAA3CFXAKA. You are receiving this because you are subscribed to this thread.

-- Mitch Keller @.***

http://www.rellek.net/

kcrisman commented 9 months ago

Haha, I didn't mean that PTX should use sed! I can't tell you how many times I've run into exactly the issues you are mentioning ... what I meant for PTX was the possibility of just changing the document class rather than the suggestion implemented in this pull request. The script line was just to show that this works for at least one person in achieving the desired result.

kcrisman commented 9 months ago

But something like <pi:pub-attribute name="openodd" default="no" options="yes"/> is just the kind of option that might be helpful for people who want this feature.

jjrsylvestre commented 9 months ago

Wouldn't twoside have other effects? For example, page numbers flopping between top right and top left.

rbeezer commented 9 months ago

Hopefully not too hacky.

Well, my very first reaction to your orginal post was going to be "So long as it doesn't include \makeatletter`" ;-)

I'll run this through some testing soon. It'll eventually need a very terse entry in the publication file reference chapter, whicvh can point to the "Page Fidelity" section, which I will re-write as part of this.

kcrisman commented 9 months ago

Yes! I was confused on which of my changes I was thinking about. My apologies! I was just excited that someone was thinking to implement this.

What I use is this solution. But if your option is more robust, it would be great to have it as an official option.

rbeezer commented 9 months ago

OK, looking good. Extensive testing with the sample book - no parts, decorative parts, structural parts. Side-by-side comparisons of PDFs indicates complete syncing on page numbers.

Force-push or add a pile-on commit, I can handle either, but please do documentation as a separate commit. Don't merge in master.

Thanks very much for doing this - the whole oneside/twoside, left/right, even/odd, recto/verso drill gives me a headache. ;-)

rbeezer commented 9 months ago

An idea that came to me while writing documentation (see, there is some value to that act!).

What about another option that basically makes \cleardoublepage do the same as \clearpage and an extra increment of the page number, but not the blank page? Basically, blank verso pages just go missing and page numbers skip a beat?

The electronic PDF is faithful, but if printed no trees are wasted. A sustainable PDF.

jjrsylvestre commented 9 months ago
  • Let's call the attribute open-odd. (Yes, I'm a bit conflicted about hyphens.)
  • Document as mentioned earlier.
  • Please cite the SE post as an XSL comment (not a LaTeX file comment), see examples all over the place.

Will do all of the above.

  • Why select="not($latex-openodd = 'no')" versus select="$latex-openodd = 'yes'"? There is a lot of this about (historically), but I think Alex's new scheme guarantees a yes or no for $latex-openodd in accordance with the default being no?

I actually tried that first, and during my testing xslt gave me an "Unknown error" in the case that the publication file omits the attribute. Didn't want to delve too deep into the pi:pub-attribute scheme to figure out why, but I assumed for some reason the test needs to be on the default value rather than an optional value.

rbeezer commented 9 months ago

Note to self: close #1423 when this is done.

jjrsylvestre commented 9 months ago

An idea that came to me while writing documentation (see, there is some value to that act!).

What about another option that basically makes \cleardoublepage do the same as \clearpage and an extra increment of the page number, but not the blank page? Basically, blank verso pages just go missing and page numbers skip a beat?

The electronic PDF is faithful, but if printed no trees are wasted. A sustainable PDF.

That could possibly be done without \makeatletter ;)

When you say "another option" do you mean literally as two different implementations of page-matching (so maybe @open-odd could have three potential settings), or as a replacement implementation for the already committed code?

rbeezer commented 9 months ago

my testing xslt gave me an "Unknown error" in the case that the publication file omits the attribute

OK, thanks for the explanation. Pinging @Alex-Jordan in case there should be some work to do - it'd be nice to have a more direct formation of that variable.

rbeezer commented 9 months ago

When you say "another option"

Definitely do not want to derail this PR in any way. I was thinking another attribute, but that would be silly. So yes, perhaps a three-way option. no, yes, drop-pages, or something with a better name. If you think it is a good idea, let's finish this with that in mind, and we won't advertise until we have it all. (We could make yes into keep-pages or something?)

jjrsylvestre commented 9 months ago

Do we need value no ? Could be just add-blanks, skip-pages, and empty/anything-else is ignored?

Alex-Jordan commented 9 months ago

I can't completely tell what in the thread is stale. Is "Unknown error" still a thing? Can you make that change and see if it still happens? I notice some places in this thread use openodd and others use open-odd, and would first want to rule out if the explanation was a typo.

To the most recent question, you want a non-empty default value whenever there is a finite list of option values. No publisher file would need to declare no as the value, so it adds no work for publishers. But it makes the XSLT more uniform and easier to maintain.

Alex-Jordan commented 9 months ago

you want a non-empty default value whenever there is a finite list of option values.

And then I look and see several such things with no default declared. I think those are about being faithful to the previous scheme, not an intentional choice. I would recommend just always declaring something non-empty for a default, even if it is never explicitly referenced in the XSLT.

jjrsylvestre commented 9 months ago

I can't completely tell what in the thread is stale. Is "Unknown error" still a thing? Can you make that change and see if it still happens?

I can't seem to recreate the situation that caused the error message. Must have been some error on my part. But the code that was at issue is not necessary in the new three-option version anyway.

I notice some places in this thread use openodd and others use open-odd, and would first want to rule out if the explanation was a typo.

No, changed wholesale from openodd to open-odd. Double-checked with a grep, there are no more instances of openodd anywhere.

To the most recent question, you want a non-empty default value whenever there is a finite list of option values. No publisher file would need to declare no as the value, so it adds no work for publishers. But it makes the XSLT more uniform and easier to maintain.

Sounds good, thanks.

rbeezer commented 9 months ago

Thanks very much - I like this a lot. Despite an increase in the use of \makeatletter.

Some mild repackaging of commits, but no changes in the code. Thanks for a very careful job.

I'll button this up and then add some more documentation, as promised. Then rebuild website, etc.