I have problem with the alignment of the codes in two column slide.
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.
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.
来源:https://stackoverflow.com/questions/18932773/slidify-alignment-of-codes