Multiple figures in one chunk with knitr and Rstudio 0.97 or 0.98 - knitr

I try to shift from Sweave to knitr but I am stucked with a problem to use multiple plots in one chunk. Here an example:
Let this .Rnw simple file (named Essai.Rnw). Of course only one plot is shown in the pdf:
\documentclass{article}
\begin{document}
\SweaveOpts{concordance=TRUE}
<<fig=TRUE>>=
plot(1:10, exp(1:10))
plot(1:10, log(1:10))
#
\end{document}
I transform it to knitr format using:
library("knitr", lib.loc="/Library/Frameworks/R.framework/Versions/3.0/Resources/library")
Sweave2knitr("Essai.Rnw")
I edit the file to get this:
\documentclass{article}
\begin{document}
\SweaveOpts{concordance=TRUE}
<<include=FALSE>>=
require(knitr)
opts_chunk$set(concordance=TRUE)
#
<<>>=
plot(1:10, exp(1:10))
plot(1:10, log(1:10))
#
\end{document}
In Rstudio global preference, I set Weave Rnw files using Knitr and when I produce pdf file using Compile pdf button in Rstudio, i get only one plot, not the 2 as I expected.
Here is my sessionInfo()
> sessionInfo()
R version 3.0.1 Patched (2013-06-10 r62935)
Platform: x86_64-apple-darwin10.8.0 (64-bit)
locale:
[1] fr_FR.UTF-8/fr_FR.UTF-8/fr_FR.UTF-8/C/fr_FR.UTF-8/fr_FR.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] knitr_1.2
loaded via a namespace (and not attached):
[1] digest_0.6.3 evaluate_0.4.3 formatR_0.7 stringr_0.6.2 tools_3.0.1

Not sure this is the cause of your problem but if you weave it with knitr, I think you have to remove the \SweaveOpts{concordance=TRUE} line.

If I compile the following, I get two plots. Note the deletions I made. Your original code did not compile on my system.
\documentclass{article}
\begin{document}
<<include=FALSE>>=
opts_chunk$set(concordance=TRUE)
#
<<>>=
plot(1:10, exp(1:10))
plot(1:10, log(1:10))
#
\end{document}
Maybe read about the knitr option fig.keep= about how your plots get integrated into the output.

Related

VSCode LaTeX nicematrix

I want to use the package "nicematrix" in VSCode, but it's not working the way I tried.
\documentclass{article}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{mathtools,halloweenmath}
\usepackage{stackengine}
\usepackage{nicematrix}
\begin{document}
\begin{vNiceMatrix}[first-row,last-row,first-col,last-col]
(I)&&x-&y+2z=1 \\
(II)-2x-5y+7z=0 & +2 \cdot (I)\\
(III)&5x+&y-3z=-11 & (-5) \cdot (I)
\end{vNiceMatrix}
\end{document}
The output should look like in this image, but it can't generate an pdf-file.
enter image description here
I get the following error:
Fatal Package nicematrix: Outside math mode. LaTeX [line 1, column 1]
(nicematrix) The environment {vNiceMatrix} can be used
(nicematrix) only in math mode (and not in \vcenter).
(nicematrix) This error is fatal.
The next big problem is, that a pdf can't be created:
Emergency stop LaTeX [line 256, column 1]
:256: ==> Fatal error occurred, no output PDF file produced!Latexmk: Getting log file 'ombplus.log' Latexmk: Examining 'ombplus.fls
Latexmk: Examining 'ombplus.log
Latexmk: Errors, so I did not complete making targets
Collected error summary (may duplicate other messages):
If I click on the problem with line 256, I get this message:
The Editor couldn't be open due to an unexpected error: The file "..." can't be read (Unknown (FileSystemError): TypeError [ERR_INVALID_ARG_VALUE]: The argument 'path' must be a string or Uint8Array without null bytes. Received 'file(...)/\x00'). Button: Try Again
How I can use the package "nicematrix" in VSCode?
I want to use the package "nicematrix", but VSCode doesn't recognise the package "nicematrix".
I downloaded it with the MikTeX-program: "miktex-pdftex" and this opens automically a "package-installer", if I include a new package in VSCode. Then I tried it with a download of this package in CTAN. It's not working this way.
The error is caused by the missing math environment around your nicematrix, add for example \[...\] for an unnumbered equation.
I also think with NiceArray you'll get better alignment:
\documentclass{article}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{mathtools,halloweenmath}
\usepackage{stackengine}
\usepackage{nicematrix}
\begin{document}
\[
\begin{NiceArray}{l|rlll|l}
\text{(I)} &x &-y &+2z &=1 & \\
\text{(II)} &-2x &-5y &+7z &=0 & +2 \cdot \text{(I)}\\
\text{(III)} &5x &+y &-3z &=-11 & (-5) \cdot \text{(I)}
\end{NiceArray}
\]
\end{document}

How to use tikz in manim?

I am trying to use tikz in manim. The version of manim I used is 3feb2019. I have added necessary packages into tex_template file. But it throws an error:
IndexError: list index out of range
I have no idea to solve this bug. Could anyone help me?
EDIT: Here are the codes I tried to render.
# These are in the example_scenes.py file
class TikzMobject(TextMobject):
CONFIG = {
"stroke_width":3,
"fill_opacity":0,
"stroke_opacity":1
}
class TikzExample3(Scene):
def construct(self):
example_tex = TikzMobject(
r"""
\begin{tikzpicture}
\draw (-1,0)--(1,0);
\end{tikzpicture}
"""
)
self.play(Write(example_tex))
self.wait()
I have tried both latest version of manim and the 3feb version but it just threw the same error:list index out of range. And I can compile the tikz codes in the output tex file. The platform I used is Windows.
I have already tried it on 2 Windows and it works perfectly, it is likely that you have not configured your tex_template.tex correctly, or that you are using an old version of Python (at least Python 3.7.3 is required), here are the proof that it works for me.
tex_template.tex configuration:
\documentclass[preview]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{dsfont}
\usepackage{setspace}
\usepackage{tipa}
\usepackage{relsize}
\usepackage{textcomp}
\usepackage{mathrsfs}
\usepackage{calligra}
\usepackage{wasysym}
\usepackage{ragged2e}
\usepackage{physics}
\usepackage{xcolor}
\usepackage{microtype}
\usepackage{tikz} %<------------------------- TIKZ PACKAGE
\DisableLigatures{encoding = *, family = * }
%\usepackage[UTF8]{ctex}
\linespread{1}
\begin{document}
YourTextHere
\end{document}
OUTPUT

how to truly turn off LaTex output in Doxygen

My group is using Doxygen 1.8.5 on RHEL7 to generate HTML-only documentation for a large C++ project. We only want HTML documentation and do not desire any other output format. The project's Doxygen configuration file (Doxyfile) carries the following settings which differ from the default (among others, of course):
OUTPUT_DIRECTORY="../Docs"
GENERATE_HTML=YES
GENERATE_LATEX=NO
When we run Doxygen with this config file, towards the end of processing, errors start coming to screen from LaTeX components, and processing is held up until the user hits enter a bunch of times to get past these errors, e.g.
...
sh: epstopdf: command not found
error: Problems running epstopdf. Check your TeX installation!
Generating graph info page...
Generating directory documentation...
</home/abilich/Src/GNSS_Software/Lib/LibgpsC++/>:3: warning: Found unknown command `\reference'
</home/abilich/Src/GNSS_Software/Lib/LibgpsC++/>:2: warning: Found unknown command `\reference'
</home/abilich/Src/GNSS_Software/Lib/LibgpsC++/>:2: warning: Found unknown command `\reference'
Generating bitmaps for formulas in HTML...
This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013)
restricted \write18 enabled.
entering extended mode
(./_formulas.tex
LaTeX2e <2011/06/27>
Babel <v3.8m> and hyphenation patterns for english, dumylang, nohyphenation, lo
aded.
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo))
(/usr/share/texlive/texmf-dist/tex/latex/graphics/epsfig.sty
(/usr/share/texlive/texmf-dist/tex/latex/graphics/graphicx.sty
(/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/share/texlive/texmf-dist/tex/latex/graphics/graphics.sty
(/usr/share/texlive/texmf-dist/tex/latex/graphics/trig.sty)
(/usr/share/texlive/texmf-dist/tex/latex/latexconfig/graphics.cfg)
(/usr/share/texlive/texmf-dist/tex/latex/graphics/dvips.def))))
No file _formulas.aux.
[1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16]
! Undefined control sequence.
l.53 \[ \Vert v - w \Vert \leqslant
p\,\min(\Vert v\Vert, \Vert w\Vert). \]
?
...
! Undefined control sequence.
l.533 $ \vert singular value \vert \leqslant
threshold \times \vert max sing...
?
[177] [178] (./_formulas.aux) )
Output written on _formulas.dvi (178 pages, 20576 bytes).
Transcript written on _formulas.log.
error: Problems running latex. Check your installation or look for typos in _formulas.tex and check _formulas.log!
Generating image form_0.png for formula
sh: gs: command not found
error: Problem running ghostscript gs -q -g60x50 -r384x384x -sDEVICE=ppmraw -sOutputFile=_form0.pnm -dNOPAUSE -dBATCH -- _form0.ps. Check your installation!
Generating index page...
/home/abilich/Src/GNSS_Software/Doxy/mainpage.h:15: warning: image file GNSSSoftwareTimeline.png is not found in IMAGE_PATH: assuming external image.
Generating page index...
Generating module index...
Generating namespace index...
Generating namespace member index...
I want to create a Doxyfile that runs without user intervention and does not throw LaTeX errors. Where have I gone astray?
Thanks for #albert's comment, actually the newest version of doxygen did support to turn latex generation off by setting GENERATE_LATEX=NO:
#---------------------------------------------------------------------------
# Configuration options related to the LaTeX output
#---------------------------------------------------------------------------
# If the GENERATE_LATEX tag is set to YES, doxygen will generate LaTeX output.
# The default value is: YES.
GENERATE_LATEX = NO
The parameter USE_PDFLATEX in your config file should set to NO (the default value is YES)
# If the USE_PDFLATEX tag is set to YES, doxygen will use the engine as
# specified with LATEX_CMD_NAME to generate the PDF file directly from the LaTeX
# files. Set this option to YES, to get a higher quality PDF documentation.
#
# See also section LATEX_CMD_NAME for selecting the engine.
# The default value is: YES.
# This tag requires that the tag GENERATE_LATEX is set to YES.
USE_PDFLATEX = NO

Compile the C-file in MATLAB

Description
I got a Mathematica Symbolic Toolbox for MATLAB--Version 2.0 here
Then I using the documentation it cotained to compile in MATLAB enviroment
Installation steps:
1)Go to your Mathematica directory and locate the file mathlink.h in
E:\math\Mathematica\5.\AddOns\MathLink\DeveloperKit\Windows\CompilerAdditions\mldev32\include'
and also the file ml32i1m.lib in
E:\math\Mathematica\5.\AddOns\MathLink\DeveloperKit\Windows\CompilerAdditions\mldev32\lib. Copy both files to a predetermined directory (we will refer to this directory as C:\xxx).
2) Copy the content of compressed file math.tar into C:\xxx.
3) Open Matlab command window and execute mex –setup. Choose “Microsoft Visual C/C++ version 6.0 in C:\Program Files\Microsoft Visual Studio”. This tells Matlab that it needs to use a C compiler (as opposed to Fortran compiler). You’ll need Microsoft Visual C/C++ installed. Do not choose the “Lcc C version 2.4 in C:\MATLAB6P1\sys\lcc” option.
4) Open Matlab command window and run mathrun.m. This program will compile the C-file math.c.
The file I got shown as belew:
Then I do step by step
(1) Find the mathlink.h and ml32i1m.lib in the following path
D:\WolframResearch\Mathematica\8.0\SystemFiles\Links\MathLink\DeveloperKit\Windows\CompilerAdditions\mldev32\include
D:\Wolfram Research\Mathematica\8.0\SystemFiles\Links\MathLink\DeveloperKit\Windows\CompilerAdditions\mldev32\lib
(2)Copy the content of compressed file math.zip into C:\XXX
(3) Compile in MATLAB
mex -setup
(4)last setp
addpath C:\XXX
run mathrun.m
I don't know why?
Update
The matlab code in mathrun.m
addpath C:\XXX;
% adds the directory C:\XXX to the list of directories which Matlab "sees" (referred to as paths)
mlpath='C:\XXX' % The directory where mathlink.h is
mllib='C:\XXX\ml32i1m.lib' % The library ml32i1m.lib
% make command
command=sprintf('mex -D__STDC __ -I % s % s % s', mlpath, 'math.c', mllib);
% compile
eval(command)
Seems like the path is not correctly passed to mex, so it cannot find math.c. Comment the original line:
%command=sprintf('mex -D__STDC __ -I % s % s % s', mlpath, 'math.c', mllib);
and add this one instead:
command=sprintf('mex -D__STDC __ -I%s %s %s', mlpath, 'math.c', mllib);
because the mex documentation specifies that there should be no space between the -I switch and the input path. To be really on the safe side, you can even write:
command=sprintf('mex -D__STDC __ -I%s %s %s', mlpath, fullfile(mlpath,'math.c'), mllib);

Where is the .tex file kept when compiling Rmd in Rstudio server

This may sound like a dumb question, but I'd like to know where is the .tex file saved, when I compile a pdf document from a Rmd file, using RStudio server.
I added the keep_tex option, so the header of Rmd looks like this :
---
output:
pdf_document:
keep_tex: yes
---
Then when I compiled, the output looks like this
|...................... | 33%
ordinary text without R code
|........................................... | 67%
label: plot
processing file: test.Rmd
cropping /tmp/Rtmpb1x3Q0/preview-3bfe24922427.dir/test_files/figure-latex/plot-1.pdf
PDFCROP 1.33, 2012/02/01 - Copyright (c) 2002-2012 by Heiko Oberdiek.
==> 1 page written on `/tmp/Rtmpb1x3Q0/preview-3bfe24922427.dir/test_files/figure-latex/plot-1.pdf'.
|.................................................................| 100%
ordinary text without R code
/usr/lib/rstudio-server/bin/pandoc/pandoc test.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output /tmp/Rtmpb1x3Q0/preview-3bfe24922427.dir/test.tex --template /home/myusername/R/x86_64-pc-linux-gnu-library/3.1/rmarkdown/rmd/latex/default.tex --highlight-style tango --latex-engine pdflatex --variable 'geometry:margin=1in'
output file: test.knit.md
/usr/lib/rstudio-server/bin/pandoc/pandoc test.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output /tmp/Rtmpb1x3Q0/preview-3bfe24922427.dir/test.pdf --template /home/myusername/R/x86_64-pc-linux-gnu-library/3.1/rmarkdown/rmd/latex/default.tex --highlight-style tango --latex-engine pdflatex --variable 'geometry:margin=1in'
Output created: /tmp/Rtmpb1x3Q0/preview-3bfe24922427.dir/test.pdf
I'd like to find the intermediate .tex file (or test.knit.md), and do a bit of editing. Except it is no where to be found. Not in the working directory, or /home/myusername/, or /, or /tmp/Rtmpb1x3Q0/.
I'd really appreciate it if someone has the answer.
Actually, this first line in the console
/usr/lib/rstudio-server/bin/pandoc/pandoc test.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output /tmp/Rtmpb1x3Q0/preview-3bfe24922427.dir/test.tex --template /home/myusername/R/x86_64-pc-linux-gnu-library/3.1/rmarkdown/rmd/latex/default.tex --highlight-style tango --latex-engine pdflatex --variable 'geometry:margin=1in'
told us that the output .tex file is in /tmp/Rtmpb1x3Q0/preview-3bfe24922427.dir/test.tex
Somehow I did not find the file last time, but on a recent instance, the .tex file is actually there, so that answers the question.
The initial code from the question
---
output:
pdf_document:
keep_tex: yes
---
Throws an error for me, while the following does not:
---
output:
pdf_document: default
keep_tex: T
---
However, I was still unable to find the .tex file following the console output. It appears to still not be saved. Instead what worked easily was running the following lines in the R studio console:
#install.packages(rmarkdown)
rmarkdown::render("FileName.Rmd", output_format = latex_document())
The file "FileName.Rmd" needs to be in the current working directory - which is where the .tex file will be saved.