grimbough / msmbstyle

Tufte inspired bookdown template
https://www-huber.embl.de/users/msmith/msmbstyle/
59 stars 18 forks source link

font size and a few other small things in grid-layout #5

Open ericpgreen opened 5 years ago

ericpgreen commented 5 years ago

Loving how the html is rendered in the grid-layout branch. A few questions:

  1. What would be the correct custom css style to change the font size and style for the body copy? That would be the text within sections and rows, I think. I tried changing body but that changed the section TOC.

  2. Is it possible to put figure numbers with the captions in margin notes?

  3. How did you "turn off" footnote numbers in the margin notes?

grimbough commented 5 years ago

Thanks for the feedback.

  1. Is it sufficient to modify the <p> tag? Including the following in a custom CSS file makes the main text larger for me, without modifying either the navigation panel or the things in the right margin. It also ignores and code blocks etc.
p {
    font-size: 2em;
    line-height: 1;
}

It's entirely likely that my CSS is not complete enough at the moment to achieve what you want, so happy to add new classes or tags if it makes custom themes easier.

  1. Figure numbers are supposed to be there by default, and I hadn't realised they weren't! I'll investigate.

  2. I think I should clarify that there are several ways things can end up in the margin.

The following Markdown syntax should produce a numbered footnote beside the relevant paragraph. The footnote text itself can appear anywhere in the Markdown document.

Text in the body of the chapter. [^1]

[^1]: A numbered footnote beside it.

If you want a comment in the margin, but without numbering you can use the something like this inline code:

`r msmbstyle::margin_note('The code is shown here; hide it via \x60echo = FALSE\x60')`

The \x60 parts will get translated into backticks when the document is processed so anything inside them is rendered in typewriter font and the text is currently prefaced with the 🛈 symbol since this is extra information.

There's also the marginfigure code block for more complex content e.g.

```{marginfigure, echo = TRUE}
We know from _the first fundamental theorem of calculus_ that for $x$ in $[a, b]$:
$$\frac{d}{dx}\left( \int_{a}^{x} f(u)\,du\right)=f(x).$$
ericpgreen commented 5 years ago

Wonderful. Thanks for the very helpful tips.

Showing here that I don't seem to get a Figure number by default. I'm also getting some whitespace in the main text due to the margin figure. Is there a better way to include an image like this in the margin?

screenshot 2019-01-04 11 15 15

--- 
title: "Global Health Research: Designs and Methods"
author: "Eric P. Green"
date: "`r Sys.Date()`"
cover-image: "images/cover.jpg"
knit: "bookdown::preview_chapter"
site: "bookdown::bookdown_site"
monofont: "Inconsolata"
monofontoptions: "Scale=0.7"
bibliography: [book.bib, packages.bib, ghr.bib]
biblio-style: apalike
link-citations: yes
description: "Online textbook about global health research methods"
output:
  msmbstyle::msmb_html_book:
    toc: TRUE
    toc_depth: 1
    split_by: chapter
    split_bib: no
    margin_references: FALSE
    css: style.css
---

# Preface{-}

This book will introduce you to research designs and methods in global health. I wrote this text for undergraduate and graduate students taking my [introductory course at Duke University](http://www.globalhealthresearch.co/). Therefore, it shares the two central aims of my course: to make you a better consumer of research and to help you design your first study.

```{r cover, echo=F, fig.margin=TRUE, fig.cap="A caption."}
  knitr::include_graphics("images/cover.jpg", dpi = NA)
ericpgreen commented 5 years ago

I noticed that I have the same whitespace problem when I use markdown footnotes or msmbstyle::margin_note to create a note in the margin like this.

screenshot 2019-01-11 04 13 37

Is there a way to prevent this whitespace in the main column?

grimbough commented 5 years ago

So this is kind a fundamental issue, which is part of the reason the bootstrap version is still isn't prime time. The design philosophy behind bootstrap is to divide the page up into rows and align things within the rows. Each row is independent from the others. If your margin content is longer than the main text that's in the same row it forces the row to grow & you get this ugly white space.

I've tried a few things to allow overflowing in the margin, but if you have a lot of content there you end up with them overlapping which is even uglier e.g.

image

I will keep experimenting, but it may be that I need to consider an alternative to bootstap, since this is a pretty big limitation.

Thanks for taking the time to report the issues, it's motivating to know someone else is trying to use it!

ericpgreen commented 5 years ago

Great explanation. The combination of the navbar chapter menu plus within chapter sidebar navigation is just awesome. Hard to find a perfect setup, but your package comes pretty close!

aridus commented 5 years ago

I also see the problem with the large amount of white space associated with margin figures, and I feel the default body text font size should probably be the same as that in the master branch (and perhaps the centre column could be slightly narrower?). This is a great project! I am currently using the master branch for a book, but would love to be able to add side navigation (the absence of this is one way that the tufte format, when used for an online book, loses out to the gitbook style).

juanu commented 4 years ago

Hi! Sorry for reviving this old issue. @ericpgreen I was wondering if you found a solution for adding figure numbers on the margin notes? Thanks!!

ericpgreen commented 4 years ago

Yes, I believe so. Check out this chapter: https://github.com/ericpgreen/GHRbook/blob/master/02-ghr.Rmd

Linked to this example: https://read.themethodsection.com/ghr.html

On Thu, Oct 31, 2019 at 11:19 PM Juan A. Ugalde notifications@github.com wrote:

Hi! Sorry for reviving this old issue. @ericpgreen https://github.com/ericpgreen I was wondering if you found a solution for adding figure numbers on the margin notes? Thanks!!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/grimbough/msmbstyle/issues/5?email_source=notifications&email_token=AAEFNAILK5OPJESDJXFD3TTQRON2JA5CNFSM4GNAENTKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECZ4BJQ#issuecomment-548651174, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEFNAPVH65UBZQ6HEK7KC3QRON2JANCNFSM4GNAENTA .