runemadsen / Magic-Book-Project

DEPRECATED: We are reviving the Magic Book project as a node package: https://github.com/magicbookproject/magicbook
http://itp.nyu.edu
620 stars 62 forks source link

front matter page numbering #142

Closed shiffman closed 11 years ago

shiffman commented 11 years ago

Traditionally, page numbers don't begin until the introduction. Before that, pages are numbered with lowercase roman numerals. The page numbers don't need to appear until the acknowledgments, i.e. the the first page of the acknowledgments would be "v".)

Looks like this is all possible with counter-reset and counter-styles!

http://www.princexml.com/doc/6.0/counters/

stevenklise commented 11 years ago

I was able to get the page numbers to reset. However I'm having trouble with lettered page numbers.

The "front matter" needs to be wrapped in a container so as to apply different page numbers to that part of the book. @runemadsen is there a better way to wrap the multiple files of the front matter in a div other than passthrough blocks? The </div> tags I've added to book.asc aren't getting rendered.

Commits in shiffman/the-nature-of-code@7893ff8

references: http://www.princexml.com/doc/8.1/counters/ http://www.princexml.com/doc/8.1/page-numbers/ http://www.princexml.com/doc/8.1/page-selectors/

runemadsen commented 11 years ago

Good question. You should probably just wrap it in a passthrough block for now. Then we can solve it later by using asciidoc.

On Sun, Oct 7, 2012 at 4:26 PM, Steven Klise notifications@github.comwrote:

I was able to get the page numbers to reset. However I'm having trouble with lettered page numbers.

The "front matter" needs to be wrapped in a container so as to apply different page numbers to that part of the book. @runemadsenhttps://github.com/runemadsenis there a better way to wrap the multiple files of the front matter in a div other than passthrough blocks? The

tags I've added to book.asc aren't getting rendered.

Commits in shiffman/the-nature-of-code@7893ff8https://github.com/shiffman/the-nature-of-code/commit/7893ff8

— Reply to this email directly or view it on GitHubhttps://github.com/runemadsen/Magic-Book-Project/issues/142#issuecomment-9212085.

stevenklise commented 11 years ago
++++++
BEFORE</div>AFTER
++++++

renders as

BEFOREAFTER
shiffman commented 11 years ago

After further investigation, guess what (I think) works.

:front: <div id="front-matter">
:content: <div id="content">
:enddiv: </div>

{front}

front matter

{enddiv}

{content}

content

{enddiv}

There are some extra paragraph tags, but they'll just be ignored I think?

<p><div id="front-matter"></p>
<p>front matter</p>
<p></div></p>
<p><div id="content"></p>
<p>content</p>
<p></div></p>

@stevenklise I think this will allow this to work, yes?

shiffman commented 11 years ago

Ok, I spent a while hacking at this today. And I've got it to work (with one problem). Here's the solution.

You don't actually need pass-through, somehow in the main book.asc, it's fine with this:

include::chapters/00_1_titlepage.asc[]

<div id ="frontmatter">

include::chapters/00_2_dedication.asc[]

</div>

include::chapters/01_vectors.asc

Note that the div can't be above the title page, but the title page is handled easily by:

@page  :first {

}

Once we've got that working, I can just name the front matter page:

div#frontmatter {
  page: frontmatter;
}

And then I can tell those pages to render with lower roman, i.e.

@page frontmatter :left {
   @bottom-left {
    content: counter(page,lower-roman);
  }
}

@page frontmatter :right {
   @bottom-right {
    content: counter(page,lower-roman);
  }
}

The problem is that for some reason whenever I "name" a div, something (Prince?) is adding an extra page break, i.e. even if I just do:

h2#dedication {
  page: dedication
}

to name the page where the dedication heading is, it sticks a page break between the <h2> and what comes after.

@stevenklise or @runemadsen does this raise any alarms in your CSS brains? I guess I can check with mikeday on the PrinceXML board next. Current tests are in https://github.com/shiffman/The-Nature-of-Code/tree/142-pagenumbering with relevant files scratch.asc and print.css.

stevenklise commented 11 years ago

did you figure out the page break issue? It's so weird how the pass throughs don't seem to work...

On Sat, Nov 24, 2012 at 10:55 PM, Daniel Shiffman notifications@github.comwrote:

Ok, I spent a while hacking at this today. And I've got it to work (with one problem). Here's the solution.

You don't actually need pass-through, somehow in the main book.asc, it's fine with this:

include::chapters/00_1_titlepage.asc[]

include::chapters/00_2_dedication.asc[]

include::chapters/01_vectors.asc

Note that the div can't be above the title page, but the title page is handled easily by:

@page :first {

}

Once we've got that working, I can just name the front matter page:

div#frontmatter { page: frontmatter; }

And then I can tell those pages to render with lower roman, i.e.

@page frontmatter :left { @bottom-left { content: counter(page,lower-roman); } }

@page frontmatter :right { @bottom-right { content: counter(page,lower-roman); } }

The problem is that for some reason whenever I "name" a div, something (Prince?) is adding an extra page break, i.e. even if I just do:

h2#dedication { page: dedication }

to name the page where the dedication heading is, it sticks a page break between the

and what comes after.

@stevenklise https://github.com/stevenklise or @runemadsenhttps://github.com/runemadsendoes this raise any alarms in your CSS brains? I guess I can check with mikeday on the PrinceXML board next. Current tests are in https://github.com/shiffman/The-Nature-of-Code/tree/142-pagenumberingwith relevant files scratch.asc and print.css.

— Reply to this email directly or view it on GitHubhttps://github.com/runemadsen/Magic-Book-Project/issues/142#issuecomment-10688600.

http://skli.se/ @stevenklise

shiffman commented 11 years ago

Well, I got further. Naming a page enforces a page break so the double page break was just that plus page-break-before: always for h2. This is solvable as I could eliminate the page-break-before: always. But without the passthrough working, I can't really control the HTML output effectively. This is the closest to anything I've gotten to work:

include::chapters/00_1_titlepage.asc[]

<div id="frontmatter"> 

Front Matter
------------
front matter

</div>

++++
<div style="counter-reset: page 1;"> </div>
++++

Content
-------
content

But without the pass-through, the divs render as:

<p><div id="frontmatter"></p>

and

<p></div></p>

which causes other problems. If I manually remove the extra <p> tags it works exactly the way it's supposed to.

runemadsen commented 11 years ago

This should be fixed now!

shiffman commented 11 years ago

Works! Works! Works! (minor issue that I now have to manually add page breaks before each h2 b/c the CSS page designation enforces a page break and I don't want any double breaks. will revisit this sometime in the future.)