Tag Info

35

You can use texcount to count the words. It automatically produces subcounts for the sections. Here's a new macro that calls texcount, extracts the subcount for the current section, and then inserts the word count into the document. It requires write18 to be enabled, and texcount must be in your path (or you have to include the full path to the executable ...

27

To illustrate the problem, here is the output from the following Sweave document: \documentclass[a4paper]{article} \usepackage{Sweave} \DefineVerbatimEnvironment{Sinput}{Verbatim} {xleftmargin=2em, frame=single} \DefineVerbatimEnvironment{Soutput}{Verbatim}{xleftmargin=2em, ...

22

With Sweave really you need only two steps for a simple document as this my_sweave_file.Rnw: \documentclass{article} \begin{document} Some text <<RTest>>= 2+2 @ \end{document} From the command line is enough: R CMD Sweave my_sweave_file.Rnw pdflatex my_sweave_file.tex Or even only one: R CMD Sweave --pdf my_sweave_file.Rnw In case that you ...

21

This isn't the answer to the original post, but I came here Googling for "Longtable misplaced noalign" so my eventual solution might be useful for someone. In my case I needed a \\ after the \caption and \label. This seems incredibly counterintuitive to me so if anyone can explain why or tell me where this is documented I'd be grateful. \documentclass{...

15

I found a better solution using the wallpaper package, replacing foo and bar produces the desired result. \documentclass{article} \usepackage{lipsum}% http://ctan.org/pkg/lipsum \usepackage{wallpaper} \begin{document} \ULCornerWallPaper{1}{foo} \LLCornerWallPaper{1}{bar} \lipsum[1-3] \end{document}

14

This error message is low-level TeX output which shows up if you are typesetting material in a font (external name "cmr12" in your example) and you are trying to typeset a glyph that is not in the font. The ? is not a real question mark it stands for a character that is unknown. When you are typesetting a word, say, "aha" then deep down this is all ...

13

knitr has a few pretty straightforward ways of handling this. Option 1: Using knit_child() with inline R code Say your setup is like the following. In the same directory, you have: graph.R ## ---- graph library(ggplot2) CarPlot <- ggplot() + stat_summary(data= mtcars, aes(x = factor(gear), y = mpg ...

13

(Upgraded from a comment.) Just use library("knitr"); knit("file.Rnw") in the console (where "file.Rnw" is the name of your Sweave file, of course). This will produce "file.tex" in the working directory.

11

If you are not stuck on using fancyhdr, you could adapt the solution from How do I add an image in the upper, left-hand corner using TikZ and graphicx which uses the background package: Notes: Need at least two runs to see the images. Code: \documentclass[12pt]{article} \usepackage[demo]{graphicx} \usepackage[all]{background} \usepackage{lipsum} \...

11

The basic idea of this is that you need to make sure that the tables generated by xtable don't float; instead you should put them in your own floating environment. In the example below, I've generated two side-by-side tables, each within a {minipage} environment and each with their own caption using the \captionof command of the caption package. I've ...

11

In both cases, the Sweave chunks should not be indented. When the Sweave driver (a part of R) parses the input file, it recognizes as chunks of R code blocks that begin with a << at the start of a line, and end with a @. Because your << is not at the start of a line, those blocks are never run as R code, and no plots are produced.

10

It is easy to generate such messages: \documentclass{article} \begin{document} äö¿ \end{document} But to be able to know what in your document is the source of the message a complete example is needed.

9

If you're willing to add a single space before the <<>> and the @, that'll do the trick. (The Sweave driver only interprets as chunks blocks of text beginning with <<>>= at the beginning of a line -- no spaces allowed!) Your input file will now look like this: \documentclass{article} \begin{document} \begin{verbatim} <<>&...

9

For a general introduction to book design using LaTeX, do check out A Few Notes on Book Design by Peter Wilson. Obviously, there is no single "correct" answer as to how a book ought to be designed. If you have considerable freedom in selecting a design, as seems to be implied by your question, you could start by simply taking a close look at the layouts of ...

9

The .log excerpt of the updated question shows that the underscore is an active character, which is expanded, when the graphics package with driver pdftex.def looks for the file. Here you can deactivate the underscore token with \string: \includegraphics{normalization\string_analysis-002} The .log file shows that the underscore is made active by package ...

8

I would use siunitx for typesetting the number with the percent sign, which will take care of the correct spacing, and do the conversion to a percentage and the rounding within the \Sexpr: The number 4 is \SI{ \Sexpr{round(4 / 7 * 100, 1)} }{\percent} of 7.

8

Here is a possible solution to your similar-width panel in tables by means of the tabularx package. It provides the environment tabularx that takes an argument specifying the width of the tabularx. That allows one to typeset the two panels as two separate tables but still maintain the same width across both tables. To stretch it across the entire width of ...

8

Since you mentioned R, I would recommend you to use the knitr package instead of Sweave. You can go to the package website to know more about it: http://yihui.name/knitr It is much more flexible and customizable than Sweave. For example, you only need to call render_listings() in order to switch to the listings package (e.g. http://yihui.name/knitr/demo/...

8

The easiest way to do this is to make yourself a Sweave-XeLaTeX engine file for TeXShop. To do this, do the following. Using the Go menu in the Finder, navigate to the TeXShop Engines folder by choosing Go and then entering ~/Library/TeXShop/Engines Make a Copy of the Sweave engine and rename it Sweave-XeLaTeX Open the engine in TeXShop and change the line ...

8

(Upgraded from a comment). Try adding fig=TRUE in the chunk options. (You might need an explicit print() around the p in the last line of the chunk too ...) If you use knitr::knit instead of Sweave, you won't need either of those explicit specifications ...

8

I'm still new to LaTeX (about 2 years of use) but have found knitr very helpful for: inline code code chunks - incredibly helpful for execution and then interspersing your document with it dead simple graph integration into document caching (I'm sure you could do this with make by watching file changes) an amazingly responsive support community (at least on ...

7

The problem is that you have cut and pasted the \hypersetup commands from a PDF, and there are invalid characters in the code, specifically the right single quotation mark ’ If you replace those characters with regular single quote marks ', the file should compile. This is caused by the way Sweave handles its input, not by the TeX file itself. So the ...

7

Actually the new version of Hmisc has the parameter col.just, so you do not need to edit the tex file \documentclass{report} \usepackage[utf8]{inputenc} \usepackage{siunitx,booktabs} \sisetup{group-separator={.},group-minimum-digits={3}, output-decimal-marker={,}} \usepackage[noae]{Sweave} \begin{document} <<>>= library("Hmisc") dat <- ...

7

In LaTeX captions can be used within float environments like figures or tables. So if your R output is e.g. a figure you can enclose it in a figure environment: \begin{figure} <<fig=TRUE, echo=FALSE, eps=TRUE>>= data(iris) boxplot(iris[,2]~iris[,5]) @ \caption{A boxplot of the famous Fisher data set.} \end{figure} If you want your R-Code ...

7

You can put the preambule from the knitr file in your file. Or in another file named preamb.tex for example call by \input{preamb}. ----preamb.tex----%% maxwidth is the original width if it is less than linewidth %% otherwise use linewidth (to make sure the graphics do not exceed the margin) \makeatletter \def\maxwidth{ % \ifdim\Gin@nat@width>\...

7

The answer (I found) is pretty simple. knitr/R will pass to TeX special characters if correctly escaped (backslashed). It is also probably necessary to use double-quotes " " instead of single quotes ' ' \documentclass{article} \usepackage{subfig} \begin{document} <<fig-sub, fig.cap="Three \\textit{plots}", fig.subcap=c("Erd\\H{o}s-R\\'enyi", "Barab\\'...

6

I have had the same problem when working with Russian input in Sweave. After some experimentation I understood that you need to pass the encoding to Sweave and Stangle before they start processing the file. When they read \usepackage, it is too late. The following entries in my Makefile work for me %.tex: %.rnw echo "Sweave ('$<', encoding='koi8-... 6 Your minimal example could have been more minimal:-) Looking at the log from \documentclass{article} \usepackage{amssymb} \begin{document} \showoutput$ a \leftarrow b  x \mathrel{\leftarrow\mkern-14mu\leftarrow} y c \twoheadleftarrow d \$ \end{document} You see that the single arrow comes from the original CM font but the double arrow comes ...

6

One problem of your MWE is that the both the start and end of the R chunk (<<>>= and @) are not at the beginning of the line. Another problem is that you have to add the option [fragile] to the frame environment. If you correct your both problems your example will work, also with figures if you provide the fig=T option, as in this example: \...

Only top voted, non community-wiki answers of a minimum length are eligible