latex

Function to sanitize strings for LaTeX compilation?

时间秒杀一切 提交于 2019-12-10 16:13:00
问题 While xtable() has a sanitize.text.function argument which allows to sanitize strings with special charaters to stop LaTeX compilation from breaking in Sweave/knitr documents, the package does not export the function to the userspace. How can I sanitize strings like asdf_text outside of the xtable context, so as to have it transformed to something like asdf\_text ? (If possible I would prefer a small, self-contained solution.) 回答1: Unless I misunderstand your question, I think you've

How can I auto-number math equations in RMarkdown?

天大地大妈咪最大 提交于 2019-12-10 15:57:26
问题 $$ r = \frac{1}{n-1} \sum_{i=1}^{n} \frac{(X_i - \bar{X})(Y_i - \bar{Y})}{S_xS_y} $$ The rendered equation is not numbered. Using \begin{aligned} and \end{aligned} generates an error. I am also using knitr in RStudio, knitting to PDF using pandoc and xelatex engine. Thank you. 回答1: Try align not aligned \begin{align} r = \frac{1}{n-1} \sum_{i=1}^{n} \frac{(X_i - \bar{X})(Y_i - \bar{Y})}{S_xS_y} \end{align} 回答2: As pointed out amsmath is already in the default template, so you can invoke the

Autoconf/Automake conditionals and dist rules

為{幸葍}努か 提交于 2019-12-10 15:56:49
问题 I recently started using autoconf and automake for a project I'm working on. The project's documentation is written in LaTeX. Since I don't want to have LaTeX as a dependency I want to check the presence of the pdflatex binary with autoconf and then use that information in the Makefile.am to decide whether to simply copy the .tex file to the documentation directory, or to generate the PDF and copy both. This is the relevant section in configure.ac : # Check for presence of pdfLaTeX AC_CHECK

How to best manage multi-lingual presentations?

落爺英雄遲暮 提交于 2019-12-10 15:56:23
问题 I have a presentation done in Latex+Beamer, currently in french. I also need to make the same presentation, with the same structure, in dutch. I'd like to maintain the presentation in one file, so that if I want to change the structure of it, I only have to do it in one place. What's the best way to put the translations outside of the presentation file? I thought of defining a command for each text element to be present in the slides, and having a different command definition for each

matplotlib won't write \approx LaTeX character in legend?

和自甴很熟 提交于 2019-12-10 15:50:32
问题 For some reason I can't get matplotlib to write down the \approx LaTeX symbol in a legend. Here's a MWE: import matplotlib.pyplot as plt plt.scatter([0.5, 0.5], [0.5, 0.5], label='$U_{c} \approx %0.1f$' % 22) #plt.scatter([0.5, 0.5], [0.5, 0.5], label='$U_{c} \simeq %0.1f$' % 22) #plt.scatter([0.5, 0.5], [0.5, 0.5], label='$U_{c} \sim %0.1f$' % 22) plt.legend(fancybox=True, loc='upper right', scatterpoints=1, fontsize=16) plt.show() Notice the first line will not show the \approx character or

Problems cross referencing in LaTex with knitr and xtable

ε祈祈猫儿з 提交于 2019-12-10 15:45:33
问题 I am currently working with R Studio to produce PDF documents with R/knitr in LaTex. Within these documents I want to present part of my results in tables that I want to refer to in the text. I produce these tables using the xtable package within R and it is working perfectly and giving me the right tables. So far so good but when it come to referencing I ran into some troubles. At the moment the resulting PDF output refers to the section in which the table lies. I searched around in some

Character vector in R as itemized list with knitr

回眸只為那壹抹淺笑 提交于 2019-12-10 15:27:04
问题 I have a vector (e.g. letters ) that I want to incorporate into my .Rnw knitr document as an itemized list. How do I do this? I have tried \Sexpr{letters} but it merely places commas between each: a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z Something like this is just as unhelpful: \begin{itemize} \item[\Sexpr{letters}] \end{itemize} What is the proper way to do this? I'm looking for a result like: a b c d e f etc. 回答1: \documentclass{article} \begin{document}

Knitr escape latex special characters (e.g., ~, $) in R code

£可爱£侵袭症+ 提交于 2019-12-10 15:11:49
问题 LaTeX crashes when I run it on the output of this knitr document because the LaTeX special characters aren't properly escaped. Any hints how to fix this? \documentclass{beamer} \begin{document} \begin{frame}{Unescaped dollar signs and tildes} In this example, neither the tilde nor the dollar sign will appear in the pdf document, and the dollar sign will cause a \LaTeX error. <<xtable, results="asis">>= n <- 100 x <- rnorm(n) y <- 2*x + rnorm(n) out <- lm(y ~ x) library(xtable) xtable(summary

escape `|' in \verb

主宰稳场 提交于 2019-12-10 15:10:16
问题 In LaTex, if I use \verb , how can I escape | ? For example, I want to display ab|bc : \verb|ab [] bc|. What should replace [] ? 回答1: You can use other characters in \verb than | ; for example, you can do \verb!ab|bc! to allow you to use | in your string. 来源: https://stackoverflow.com/questions/4937440/escape-in-verb

Nonfloating figure spanning two columns in multicol environment

允我心安 提交于 2019-12-10 14:49:33
问题 I am using the multicol package, with two columns, and need a figure to span both columns. I am aware of \begin{figure*} , but I do not want the figure to float. I have been googling for about an hour, to no avail. Any help would be great. 回答1: Have a look at the package nonfloat (it is part of TeXlive so there is a good chance you already have it). The following example taken from the manual of nonfloat shows how you can have a non-floating figure with caption: \begin{minipage}{\linewidth}