Showing posts with label LaTeX. Show all posts
Showing posts with label LaTeX. Show all posts

Monday, February 15, 2021

Using tikzDevice in R Markdown document

 When I was LaTeX user in the past, I like TikZ and tikzDevice a lot. After switching to R Markdown, however, I gradually forgot about them. Today I spent some time figuring out how to make TikZ and tikzDevice work for R Markdown. Here is some simple code: 

---
title: "Using tikzDevice"
output: 
  pdf_document: 
    latex_engine: xelatex
    keep_tex: yes
    includes:
      in_header: setup.tex
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
```{r, fig.cap="Without tikzDevice"}
x<- rnorm(10)
y<-x +rnorm(5,sd=0.25)
model <- lm(y~x)
rsq<- summary(model)$r.squared
rsq<- signif(rsq,4)
plot(x, y, main='Hello \\LaTeX!')
abline(model,col='red')
mtext(paste("Linear model:$R^{2}=",
            rsq, "$"), line=0.5)
legend('bottomright',legend=paste("$y = ",round(coef(model)[2],3),'x +',round(coef(model)[1],3),'$',sep =''), bty ='n')
```
```{r, echo=FALSE}
library(tikzDevice)
```
```{r, echo=FALSE, message=FALSE, results='hide'}
tikz('latexEx.tex',width=7,height=4.5)
x<- rnorm(10)
y<-x +rnorm(5,sd=0.25)
model <- lm(y~x)
rsq<- summary(model)$r.squared
rsq<- signif(rsq,4)
plot(x, y, main='Hello \\LaTeX!')
abline(model,col='red')
mtext(paste("Linear model:$R^{2}=",
            rsq, "$"), line=0.5)
legend('bottomright',legend=paste("$y = ",round(coef(model)[2],3),'x +',round(coef(model)[1],3),'$',sep =''), bty ='n')
dev.off()
```
```{r, fig.cap="With tikzDevice", message=FALSE, engine='tikz'}
\input{latexEx.tex}

Saturday, November 26, 2016

The importance of googling ...

Trying to submit a manuscript today. The main manuscript was written in Rmarkdown whereas the supplementary materials in Word. The online submission system kept complaining abut my pdf file. After some googling and tweaking, it turns out the problem was caused by indicator function "\mathbbm{1}". Following the suggestion given here, I replaced it with "\mathds{1}". Problem solved!

Monday, May 25, 2015

Friday, March 14, 2014

TeXMath

TeXMath is a LibreOffice plugin that support LaTeX equations. Looks good.

Saturday, March 08, 2014

LaTeX templates

Here is a collection of useful LaTeX templates.

Thursday, September 26, 2013

R to LaTeX options

This post provides a thorough comparison among a number of options. If one wants full Zelig support, stargazer seems to be the only option (it handles more Zelig model types than texreg does).

Monday, May 20, 2013

Another option for R/LaTeX/Sweave editor

WinEdt is another good option for R/LaTeX/Sweave editing. I especially the feature of running "knitr + pdflatex" without opening a R terminal. Unfortunately it is a Windows-only software.

Wednesday, May 08, 2013

Sumatra pdf viewer

The Sumatry pdf viewer works very well on Windows platform. If you have to run LaTeX on Windows platform and needs function like auto-update of the compiled pdf file, Sumatry is the right choice.

Friday, May 03, 2013

Rstudio vs. StatET

Rstudio wins in easy installation, smaller size, and intuitive user interface. StatET wins in graphical debugger and an outline view. Right now, StatET is a better choice for Sweave/Knitr/LaTeX authoring platform than Rstudio.

Tuesday, March 12, 2013

Thursday, November 29, 2012

TikzEdt

TikzEdt is an editor and previewer forTikZ LaTeX graphics package.

Sunday, November 11, 2012

Excel2latex

Excel2latex is a handy tool to get Word tables into LaTeX.

Thursday, April 19, 2012

Is Markdown/Pandoc any good?

Here is a post about LaTeX vs. Markdown. Looks like it is not easy to translate between the two systems automatically.

Monday, April 09, 2012

Sunday, February 19, 2012

Equations in LaTeX

Here are some useful tips on how to do equations right in LaTeX.

Saturday, February 11, 2012

The "tables" package

The "tables" package makes Sweave a real option for exploratory data analysis and report generation.

Friday, December 30, 2011

Chapterbib package

Here is useful information on the "chapterbib" package.

The trick to get it working is to run bibtex on each chapter and then run latex on the main document.

Sunday, November 27, 2011

Bibtex vs. biblatex

Here is a comprehensive discussion on the relative strengths and weaknesses of each approach. Here are some instruction about how to switch from bibtex to biblatex.

Monday, November 14, 2011

One little problem with the new StatET

The new StatET looks great, and the visual debugger is really cool. However, after playing with it for a little while, I realized that the outline function (which works on LaTeX source file) still does not work on .Rnw file. The StatET group probably thinks that this is something that the TeXLipse group should do, while the TeXlipse group probably thinks this is not a LaTeX-related issue.

Tuesday, November 08, 2011

More than one columns in Beamer slide

Sometimes it is helpful to have more than one columns in a Beamer slide. This post shows how to do that.

Counter