Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

front-matter main-matter page numbering #904

Closed
pmjdebruijn opened this issue Jul 19, 2019 · 6 comments
Closed

front-matter main-matter page numbering #904

pmjdebruijn opened this issue Jul 19, 2019 · 6 comments

Comments

@pmjdebruijn
Copy link
Contributor

I'm trying to create a document with a proper title page front-matter and back-matter, with properly restarting page numbering.

If I enable counter-reset: page on the page elements, with a proper encapsulating div for both front-matter and back-matter, the counter-reset is executed on every page:

matter_2.pdf
matter_2.txt

When I kludge it, with a separate empty div, I get a unwanted empty page, but the number resetting works fine:

matter_1.pdf
matter_1.txt

The other idea that came to mind is using the :first selector with my named pages, but...
@page front :first { counter-reset: page 1; }
seems to be ignored, and
@page:first front { counter-reset: page 1; }
results in the following error:
WARNING: Unsupported @page selector ":first front
", the whole @page rule was ignored at 11:1.

I'd love to hear your thoughts on this issue...

@pmjdebruijn
Copy link
Contributor Author

Presumably this may be related:
dffab39

@pmjdebruijn
Copy link
Contributor Author

And #562

@pmjdebruijn
Copy link
Contributor Author

@page main:left { counter-reset: page 10; }

seems to work fine.

@Tontyna
Copy link
Contributor

Tontyna commented Jul 27, 2019

@page main:left { counter-reset: page 10; }
seems to work fine.

Huh? This rule results in main pages which are numbered 10, 11, 10, 11, ...

Unless the pseudo-selector :first is supported for named pages there's almost no chance to get what you want with the builtin page counter. (Dunno why the spec restricts this useful selector: "The :first pseudo-class matches the first printed page of a document")

Can be achieved by using your own main-pagecounter:

@page main
{
  counter-increment: main-pagecounter;
  @bottom-center
  {
    font-family: Arimo, Arial, Helvetica, sans-serif;
    content: counter(main-pagecounter);
  }
}

article#contents a::after
{
  content: target-counter(attr(href), main-pagecounter);
  float: right;
}

@pmjdebruijn
Copy link
Contributor Author

pmjdebruijn commented Jul 29, 2019

@page 10, that was just an example to illustrate that :left was indeed working.

My suspicion is that the spec was worded as "first printed page of a document" because at that point in time, "document" was the only scope that applied to page styles, when named pages were introduced after there were multiple scopes, where the original precise wording actually creating problems when literally interpreted. It would seem to make @page whatever:first should apply to the first page occurrence of a named page style. The only possibly undefined situation that arises is what to do when a named page style is invoked, then switched to another named page style, and then back to the original named page style. Would :first apply to the second set named pages?

In any case, the workaround you propose seems to work well, so that's a viable approach for me for the time being. Thanks for the help.

Not sure if that should close this issue though.

@liZe
Copy link
Member

liZe commented Sep 18, 2019

Not sure if that should close this issue though.

Another solution for this problem would be to have page groups, with a group for the main content and a counter reset on its first page.

As this feature is tracked by #895, we can safely close this issue.

@liZe liZe closed this as completed Sep 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants