latex

unable to change the colors of the xtable cells in rmarkdown output to pdf

99封情书 提交于 2019-12-12 12:58:56
问题 I have this r markdown code: --- header-includes: - \usepackage{xcolor, colortbl} output: pdf_document: latex_engine: xelatex --- ```{r, results="asis"} library(xtable) library(formattable) # Your data tab = data.frame(category = c("A","B","C"), groupA = c(.2,.3,.5), groupB= c(.6,.7,.9)) # Function to cut your data, and assign colour to each range f <- function(x) cut(x, c(0, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, Inf), labels=c("green", "red", "blue", "orange", "yellow", "purple", "brown",

How to knit directly to R object?

廉价感情. 提交于 2019-12-12 12:44:05
问题 I'd like to store a knit() ted document directly in R as an R object, as a character vector . I know I can do this by knit() ing to a tempfile() and then import the result, like so: library(knitr) library(readr) ex_file <- tempfile(fileext = ".tex") knitr::knit(text = "foo", output = ex_file) knitted_obj <- readr::read_file(ex_file) knitted_obj returns # [1] "foo\n" as intended. Is there a way to do this without using a tempfile() and by directly "piping" the result to a vector? Why on earth

Incorrect conversion from R Markdown to LaTeX

懵懂的女人 提交于 2019-12-12 11:41:44
问题 Why does the following R Markdown minimal (non)-working example not compile to PDF? --- header-includes: - \usepackage{fancyhdr} - \pagestyle{fancy} - \lhead{} - \chead{} - \rhead{The performance of new graduates} - \lfoot{From: K. Grant} - \cfoot{To: Dean A. Smith} output: pdf_document: keep_tex: yes latex_engine: xelatex --- # Test In particular, the problematic conversion happens to -\lfoot{From: K. Grant} and -\cfoot{To: Dean A. Smith} , as seen in the output .tex file: \usepackage

Convert Mathematica equations into R code

我怕爱的太早我们不能终老 提交于 2019-12-12 11:19:19
问题 Is there an easy way to convert Mathematica equations into R code? I have several equations that consist of dozens of terms with subscripts, superscripts, and greek letters. For example, here's a small part of one equation in Latex format: m_2_2= 48 b_1 c_2^2 d_1 \rho ^4+48 b_2 c_1^2 d_2 \rho ^4+216 b_2 c_1 c_2 d_1 \rho ^3+216 b_1 c_1 c_2 d_2 \rho ^3+96 b_1 c_2^2 d_1 \rho ^2+96 b_2 c_1^2 d_2 \rho ^2 + ... I can copy from Mathematica as plain text, input text, Latex, or MathML, but how can I

LaTeX, tildes and verbatim mode

感情迁移 提交于 2019-12-12 10:55:24
问题 Following on from this question, I'm totally stumped on getting LaTeX to give me a tilde when I'm in verbatim mode. It has to be a tilde because it's the type of a function! sig symm : (Board, [(Int, Int)]) ~> Bool Standard methods for displaying a tilde are printed verbatim, of course.. Any suggestions? An edit to clarify : Typing a ~ in verbatim mode gives an accent above a blank space. I'm after a tilde as it appears at the beginning of this sentence. 回答1: If there are some characters that

How to enable math in sphinx?

别等时光非礼了梦想. 提交于 2019-12-12 10:43:21
问题 I am using sphinx with the pngmath extension to document my code that has a lot of mathematical expressions. Doing that in a *.rst file is working just fine. a \times b becomes: However, if I try the same inside a *.py file for example in a module documentation like so: """ a \times b """ I end up with Furthermore no amsmath functionality seems to work, either. What do I need to do, to also have math formulas in my *.py documentations? 回答1: Try putting a lower case 'r' before your docstring -

Latex \tableofcontents command always shows blank Contents on first build

跟風遠走 提交于 2019-12-12 08:23:38
问题 When I generate a .pdf file from a .tex file using pdflatex , only the "Contents" title is shown with no actual TOC. If I run pdflatex my.tex once more, it generates the TOC just fine. I can reproduce this simply by removing the .toc file. What I think is happening is that my .toc file is being generated too late -- so how can I make the TOC work first time? Should I be generating the TOC beforehand without using pdflatex ? 回答1: This is normal. LaTeX document need several compilations to

Latex List of Figures

久未见 提交于 2019-12-12 07:04:49
问题 So i'm trying to hide the label in my cover image. >\begin{figure} >\center >\includegraphics[scale=0.5]{universidade} >\caption* {Mycaption} >\end {figure} This way it's not labeling the figure but its not showing on the list of figures Help please ;D 回答1: You can give the caption package the option labelformat=empty to suppress the Figure 1 etc. labelling: \usepackage[labelformat=empty]{caption} You can use square brackets to specify the description for the figure list, and curly brackets

Error compiling Rnw to tex

浪尽此生 提交于 2019-12-12 05:19:51
问题 I had a problem using function Sweave . It seemed to be an encoding problem because I did not specify any encoding like: \usepackage[latin1]{inputenc}. Now using button "Compile PDF" works -> PDF is generated and everythink is OK. But I'm getting 30 warnings and 18 badboxes. Using function Sweave to generate first the tex file fails with this message: Error: chunk 4 (label = t4) Error in file(con, "w") : cannot open the connection In addition: There were 31 warnings (use warnings() to see

Replace LaTeX with $ and multi-line

假如想象 提交于 2019-12-12 05:15:15
问题 I want to use sed to replace something like $some latex$ or $$ some latex $$ with {% math %}some latex {% endmath %} or {% math %} some latex {% endmath %} I try sed to solve this problem but a command like sed -e 's/\$\([^\$]\{1,\}\)\$/{% math %}\1{% endmath %}/g' filename doesn't work for $some latex$ and I don't know how to deal with multi-line. How can I do this? 回答1: Try this with sed : sed -e ' /\$\$/{s/\$\$/{% math %}/;:a;N;/\$\$/!ba;s/\$\$/{% endmath %}/};s/^\(\$\)\(.*\)\(\$\)$/{%