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

Style bibliography (when link-citations: false) #47

Merged
merged 2 commits into from
Feb 7, 2021

Conversation

Selbosh
Copy link
Contributor

@Selbosh Selbosh commented Feb 5, 2021

I didn't like the look of the references section if I had link-citations: false in the YAML and output: tint::tintHtml i.e. when references appear at the end of the document rather than as sidenotes. The entries were too close together with inadequate line spacing. This PR tweaks the CSS slightly so the references look a little bit nicer - that's all.

@eddelbuettel
Copy link
Owner

eddelbuettel commented Feb 5, 2021

Woot. Sounds promising. Could you maybe (cough, cough, we usually hate screenshots) show a quick 'before' and 'after' ?

@Selbosh
Copy link
Contributor Author

Selbosh commented Feb 5, 2021

This is with a top-level unnumbered header just before the end of the document.

Before

Before screenshot

After

After screenshot

@eddelbuettel
Copy link
Owner

eddelbuettel commented Feb 5, 2021

That's tough. I kinda like them both and want to remain faithful to the old 'compact' display too.

Do you think we could make it a yaml header switch? I can see us picking up the value and than maybe switching css files in tint_html_depedency().

@Selbosh
Copy link
Contributor Author

Selbosh commented Feb 5, 2021

Personally I think the old style just looks broken and unstyled (and it sort of is). It extends wider than the rest of the content. Maybe tweak the width so it spans both the content and margin areas, and reduce the spacing between the bib items?

@eddelbuettel
Copy link
Owner

I'll have to look in more detail and can't do that right now -- but point taken on the width. We'll make this better.

(I am mostly a pdf user so feedback and help is appreciated!)

@Selbosh
Copy link
Contributor Author

Selbosh commented Feb 5, 2021

One set of rules that might achieve that:

.csl-bib-body {
  width: 85%;
  margin-top: 1.4rem;
}
.csl-entry {
  margin: .25rem 0;
  line-height: 1.5;
}

Looks like

Screenshot

Kind of a compromise between "unstyled & compact" vs. "styled and padded" above.

@eddelbuettel
Copy link
Owner

Can describe which document you rendered with which version of tint? I do not even get the bold References title from either tintHTML.Rmd or tintHtmlIntro.Rmd and the references are, for me, incomplete. pandoc says 2.11.4 with citeproc 0.3.0.5. (And that is likely a version I have via RStudio, linked manually in the path, as even Ubuntu 20.10 has only the older 2.9.2.1.)

@jonathan-g Any views on the styling matters and preferences?

@Selbosh
Copy link
Contributor Author

Selbosh commented Feb 6, 2021

I added the References header myself with a # References at the end. Sorry for the confusion

@eddelbuettel
Copy link
Owner

Well we are five messages back and forth in yet we still have not minimally complete and reproducible example. Could you please add one?

@Selbosh
Copy link
Contributor Author

Selbosh commented Feb 6, 2021

---
title: Minimal working example
output: tint::tintHtml
bibliography: mwe.bib
link-citations: no
---

```{r include=FALSE}
knitr::write_bib(c('base', 'tint', 'knitr'), file = 'mwe.bib')
```

We refer to the packages by @R-base, @R-tint and @R-knitr.

```{css, eval=FALSE, echo=FALSE}
.csl-bib-body {
  width: 85%;
  margin-top: 1.4rem;
}
.csl-entry {
  margin: .25rem 0;
  line-height: 1.5;
}
```

# References

Toggle eval=TRUE on the CSS chunk to switch to styling mentioned in the previous comment.

@eddelbuettel
Copy link
Owner

This is so much better :) I also added it to the bottom of the included tintHTML.Rmd (after adjusting the written bib segment to align the two).

I am with you that this needs a little work. But

  • unsure about body witdth, maybe just 60% or 55%, what does the main text use?
  • margin-top 1.4rem seems like too much, can you live with 1.0 ?
  • line-height 1.5 for entries also feels like too much for me, how about 1.25 ?
  • is there a field for spacing below the last entry, i.e. below the cls-body?

@Selbosh
Copy link
Contributor Author

Selbosh commented Feb 7, 2021

All sounds good to me. The main text seems to use between 55% and 60% (depending on whether it's a <p>, <pre>, a plot, etc). For spacing below csl-bib-body I'd probably use margin-bottom

@eddelbuettel
Copy link
Owner

eddelbuettel commented Feb 7, 2021

I think I tried margin-bottom on a hunch and it didn't work. Would you know if there is maybe a different field?

My bad. I only tried 1.0rem and it is too indiscernible. What should we use? 3? 5?

@Selbosh
Copy link
Contributor Author

Selbosh commented Feb 7, 2021

I have no strong preference. Only consideration would be if anything is ever likely to appear below the bibliography. But I don't think anything ever does, as footnotes always appear in the margin, right?

@eddelbuettel
Copy link
Owner

Right. Unless overridden. I put three there then.

@eddelbuettel
Copy link
Owner

I just updated your PR -- can you double check that is what we want? I

  • updated some of the values as discussed
  • added a 'bottom'
  • removed the csl-body to 90% addition

@Selbosh
Copy link
Contributor Author

Selbosh commented Feb 7, 2021

Just tried it out and it looks good to me!

@eddelbuettel
Copy link
Owner

Thanks for suggesting this. Clearly makes it better. Will merge this.

@eddelbuettel eddelbuettel merged commit 0b6b153 into eddelbuettel:master Feb 7, 2021
eddelbuettel added a commit that referenced this pull request Feb 7, 2021
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

Successfully merging this pull request may close these issues.

2 participants