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

feature request: option to restart endnote numbering after each GitBook-style web chapter #589

Open
JackDougherty opened this Issue Jun 11, 2018 · 5 comments

Comments

Projects
None yet
3 participants
@JackDougherty
Copy link

JackDougherty commented Jun 11, 2018

Thanks for bookdown! I previously posted this question on StackOverflow and offered a bounty, but did not receive any answers, so am adding as a feature request here.

I am preparing an historical book manuscript, written in R-Markdown with Bookdown, which will have 8 chapters, each with 100+ Chicago-style endnotes, using the GitBook-style web format.

My goal is to restart endnote numbering after each chapter, to avoid running into high digits and to resemble the appearance of traditional history books.

I have experimented with most of the settings described here (https://bookdown.org/yihui/bookdown/html.html#gitbook-style), but cannot produce the desired web output. Here's the relevant portion of my index.Rmd:

output:
  bookdown::gitbook:
    dev: svglite
    css: css/style.css
    split_by: rmd
    split_bib: true

See my simplified mockup demo: https://jackdougherty.github.io/bookdown-test/book/ and source code: https://github.com/JackDougherty/bookdown-test

@yihui

This comment has been minimized.

Copy link
Member

yihui commented Jun 14, 2018

This can be a good and interesting JavaScript challenge, but I have no time to take it.

@JackDougherty

This comment has been minimized.

Copy link
Author

JackDougherty commented Nov 24, 2018

Thanks @romles for creating this solution in style.css, described here:
https://stackoverflow.com/questions/50616517/restart-endnote-numbering-after-each-gitbook-style-web-chapter-in-r-bookdown

Demo here:
https://jackdougherty.github.io/bookdown-test/book

If @yihui approves, please consider adding to bookdown code for others.

/* footnote counter to restart numbering for each chapter */

/* don't show the wrong footnote calls */
.footnote-ref sup {
display: none;
}

/* use a counter for footnote calls */
.level1 {
counter-reset: fn-call;
}

.footnote-ref {
counter-increment: fn-call;
}

/* generate new footnote calls */
.footnote-ref::after {
content: counter(fn-call);
position: relative;
top: -.5em;
font-size: 85%;
line-height: 0;
vertical-align: baseline;
}

/* use a counter for footnotes numbering */
.footnotes ol {
list-style: none;
counter-reset: fn-number;
}

.footnotes li {
counter-increment: fn-number;
}

.footnotes p::before {
content: counter(fn-number) '. ';
}

@JackDougherty

This comment has been minimized.

Copy link
Author

JackDougherty commented Feb 7, 2019

My suggested code to restart note numbering after each Gitbook-style web chapter is no longer working as intended. (Perhaps something changed from bookdown v 0.8 to 0.9?) So I'm withdrawing this suggestion until I can look at it more closely. Stay tuned.

@ilyankou

This comment has been minimized.

Copy link

ilyankou commented Feb 10, 2019

@JackDougherty Version 0.9 came with some changes to CSS, that's why the CSS tweak described two comments above #589 (comment) doesn't work as desired.

The <a> tag's class inside the citation changed from .footnote-ref to .footnoteRef. So you need to extend some of your CSS to account for that:

/* don't show the wrong footnote calls */
.footnote-ref sup,
.footnoteRef sup {
  display: none;
}

...

.footnote-ref,
.footnoteRef {
  counter-increment: fn-call;
}

.footnote-ref::after,
.footnoteRef::after {
  content: counter(fn-call);
  position: relative;
  top: -.5em;
  font-size: 85%;
  line-height: 0;
  vertical-align: baseline;
}

...
@JackDougherty

This comment has been minimized.

Copy link
Author

JackDougherty commented Feb 10, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment