4

How do you continue a numbered list onto a new slide in slidify?

My code looks as follows:

---
title       : Another Introductory R Session
subtitle    : 
author      : Christopher Meaney
job         : Biostatistician, University of Toronto
framework   : io2012        # {io2012, html5slides, shower, dzslides, ...}
highlighter : highlight.js  # {highlight.js, prettify, highlight}
hitheme     : tomorrow      # 
widgets     : [mathjax]            # {mathjax, quiz, bootstrap}
mode        : selfcontained # {standalone, draft}

--- .nobackground 

1. Item 1
2. Item 2
3. Item 3
4. Item 4

--- .nobackground

5. Create the following matrix `mat <- matrix(1:9,ncol=3)`.
  * How many ways can you think of to get the column means of `mat`? 
  * Same idea with row means.

6. In matrix notation the OLS/MLE solution for the regression coeffiicients of a linear regression model can be expressed as:

$$ \hat{\boldsymbol\beta} = (\mathbf{X}^{\rm T}\mathbf{X})^{-1} \mathbf{X}^{\rm T}\mathbf{y} $$

* Using the cars dataset investigate the relationship between distance (response variable) as a function of speed (independent variable).
* Create the vector `y` and the design matrix `X`. Dont forget the leading column vector of 1's. Using all of R's fancy matrix algebra functions estimate the $\hat{\boldsymbol\beta}$ vector. 
  * Compare your matrix algebra approach with the following code: `lm(dist~speed,data=cars)`

I want the list on the second slide to begin with 5. Item 5. 6. Item 6...and so on. But the list numbering is reset to 1. Item 5. 2. Item 6 and so on.

Chris
  • 3,401
  • 5
  • 33
  • 42

1 Answers1

2

Probably the simplest method is to add some javascript after the slide content:

--- .nobackground #foo

5. Create the following matrix `mat <- matrix(1:9,ncol=3)`.
  * How many ways can you think of to get the column means of `mat`? 
  * Same idea with row means.

6. In matrix notation the OLS/MLE solution for the regression coeffiicients of a linear regression model can be expressed as:

$$ \hat{\boldsymbol\beta} = (\mathbf{X}^{\rm T}\mathbf{X})^{-1} \mathbf{X}^{\rm T}\mathbf{y} $$

* Using the cars dataset investigate the relationship between distance (response variable) as a function of speed (independent variable).
* Create the vector `y` and the design matrix `X`. Dont forget the leading column vector of 1's. Using all of R's fancy matrix algebra functions estimate the $\hat{\boldsymbol\beta}$ vector. 
* Compare your matrix algebra approach with the following code: `lm(dist~speed,data=cars)`


<script>
$("#foo ol").attr('start', 5)
</script>

---

Other methods:

You can just use html

---
<ol start="5">
    <li>Item 5</li>
    <li>Item 6</li>
</ol>
---

slidify example

or you can resort to CSS:

--- .nobackground #foo

5. Create the following matrix `mat <- matrix(1:9,ncol=3)`.
  * How many ways can you think of to get the column means of `mat`? 
  * Same idea with row means.

6. In matrix notation the OLS/MLE solution for the regression coeffiicients of a linear regression model can be expressed as:

$$ \hat{\boldsymbol\beta} = (\mathbf{X}^{\rm T}\mathbf{X})^{-1} \mathbf{X}^{\rm T}\mathbf{y} $$

* Using the cars dataset investigate the relationship between distance (response variable) as a function of speed (independent variable).
* Create the vector `y` and the design matrix `X`. Dont forget the leading column vector of 1's. Using all of R's fancy matrix algebra functions estimate the $\hat{\boldsymbol\beta}$ vector. 
* Compare your matrix algebra approach with the following code: `lm(dist~speed,data=cars)`

---

Now in your assets/css add a styles.css with

#foo OL {
  counter-reset: item 4;
}
#foo OL>LI { display: block }
#foo OL>LI:before {
        content: counter(item) ". ";
        counter-increment: item;
        display:block;
        }

Alternatively you can insert the style as HTML in your slide

<style>
#foo OL {
  counter-reset: item 4;
}
#foo OL>LI { display: block }
#foo OL>LI:before {
      content: counter(item) ". ";
        counter-increment: item;
        display:block;
        }
</style>

enter image description here

jdharrison
  • 30,085
  • 4
  • 77
  • 89
  • That totally works. Thx. However, it throws off all of the formatting of all the other elements of the slide (syntax highlight, format/placement of other bullet types, etc.). I will update what my question to reflect the actual second slide. Hopefully the solution could maintain formatting with as much as possible. – Chris May 25 '14 at 20:10
  • A quick fix would be to just ignore the numbering until you have produced your final slides then manual add `
      ` to the HTML that slidify produces.
    – jdharrison May 25 '14 at 20:13
  • That's a good idea. Interestingly enough, the ordered lists seem to break when you place a chunk of R code in between them as well (on the same slide). Your solution would work there too. – Chris May 25 '14 at 20:22
  • The javascript approach worked nicely for me. Thanks. – Chris May 26 '14 at 00:20
  • The HTML approach is nice when you want to start the numbered list over in the same slide. Like when you have `
      ` Code `
    `. Then and R code block ```{r} R code ``` then another ordered list
    . Thanks for so many good solutions.
    – Chris May 26 '14 at 00:36