7

I have problem with the alignment of the codes in two column slide.

enter image description here

Here is my code for this slide,

--- &twocol

## Sample R Codes

*** =left

```{r, echo=FALSE}
options(width=30)
```


```{r, fig.height=5.5,highlight=TRUE, fig.show='hide',tidy=TRUE}
mvreg.sim <- function(xcov,beta1=matrix(c(0.7, 0.2, 0.2, 0.7), 
             nr = 2, nc = 2),  err.mu=c(0,0), 
             err.sigma=matrix(c(100,0,0,100), nr=2)){
  library(mvtnorm)
  N <- nrow(xcov)
  e <- rmvnorm(N, mean = err.mu, sigma = err.sigma)  
  y <- matrix(NA, nrow = N, ncol = 2)
  for(i in 1:N){
    y[i,] <- (xcov[i,])%*%beta1 + e[i,]
  }
  return(y)
}
```

*** =right

This is the explanation of the plot.

```{r, fig.height=5.5,highlight=TRUE,echo=FALSE}
x <- seq(0,10, by = 0.01)
y <- x
plot(x, sin(y), xlab = 'x-axis', ylab = 'sin(x)', main = 'Sample Plot')
```

I am new to slidify with little knowledge on html. I use tidy=TRUE with options(width=60) to control the width of the codes inside the box, but the alignment somehow is affected. I want the alignment set to right justified. Any help is greatly appreciated.

Al-Ahmadgaid Asaad
  • 1,172
  • 5
  • 13
  • 25

1 Answers1

11

The trouble is because the default two column layout in Slidify center aligns the left column (I will fix it in the next version). This is the two column template used.

---
layout: slide
---
{{{ slide.content }}}
<div style='float:left;width:48%;' class='centered'>
  {{{ slide.left.html }}}
</div>
<div style='float:right;width:48%;'>
  {{{ slide.right.html }}}
</div>

Easiest fix would be to save the above layout as twocol.html in the directory assets/layouts and then remove class = "centered". Custom layouts automatically override system layouts. Just make sure that you drop the file in assets/layouts since that is the location where Slidify will look for custom layouts.

Ramnath
  • 54,439
  • 16
  • 125
  • 152
  • Is there a mechanism to inherit layout? – agstudy Sep 21 '13 at 13:06
  • Yes. A very simple mechanism though. For example, the twocol layout inherits from the slide layout, and merely replaces {{{ slide.content }}} with content from the child. It is easy to extend this mechanism to do arbitrary replacements, but I haven't found a good use case yet to support this. – Ramnath Sep 21 '13 at 14:37