I am using the pandoc styles extension for applying the custom style to the output word document using the rmarkdown.
It worked perfectly on my local machine. However, it's giving me an error styles extension not found on the r shiny pro server.
Unfortunately, I don't have a permission to make any configuration changes at the r shiny pro server.
I would like to know if there is any way to load the extension from the application like the way we install the packages from the server.R?
No, pandoc extensions are part of the pandoc binary (which is not written in R, but is a single executable file, compiled from Haskell) and cannot be loaded like R packages.
You would need to update to a newer pandoc version that does have this extension.
Related
I made a .rmd file for a vignette containing TeX scripts for my package.
My procedure
Make a vignette as .rmdfile.
Make a .htmlfile by the R script devtools::build_vignettes() or devtools::document()
Open the resulting .html file via web browser [Chrome]
I found that the tex script is raw in web browser page, that is, it is not compiled yet.
Why does such phenomenon occur ? Now, compile goes well, but a few hours ago, it failed.
Does the following relate ?
> devtools::build_vignettes()
Building mypkgName vignettes
Warning message:
In system(paste(cmd, "-n")) : 'make' not found
Movin aaa.html, bbb.html, ccc.html, aaa.R, bbb.R, ccc.R to doc/
Copying aaa.Rmd, bbb.Rmd, ccc.Rmd to doc/
Building vignette index
Most raw LaTeX and raw HTML is just passed through Pandoc without changes. There are some exceptions: math in dollar signs (e.g. $x^2$) will be handled by MathJax, which can handle a subset of LaTeX.
Even if you're dealing with this subset, you will see what looks like raw LaTeX if MathJax can't run. This could happen if you have Javascript turned off in your web browser (maybe by NoScript), or if you can't connect to the MathJax website and haven't asked to reference a local copy of MathJax.
I'm currently developing a shiny app that I want to install in different computers that currently doesn't have R, LaTex and pandoc install. I found this blog https://www.r-bloggers.com/deploying-desktop-apps-with-r/ where it is explain how to do this. I followed all their instructions and it work great until I generate some pdf that I wrote with knitr. The error I get is:
Warning: Error in htmlwidgets::saveWidget: Saving a widget with selfcontained = TRUE requires pandoc. For details see:
https://github.com/rstudio/rmarkdown/blob/master/PANDOC.md
which I interpret as you don't have Pandoc, and I will probably get the same for LaTex if the code gets there.
I know I have to install portable MikTex and portable pandoc in the same folder I have the shiny app and the portable R and Chrome, so I downloaded from here https://miktex.org/portable and here https://github.com/pandoc-extras/pandoc-portable and install theme. But this did not work
Reading the R blogger and the other webpage cited there I know I have to change somewhere in the code, maybe the .bat or in R or in some file of MikTex and pandoc, the direction that R is going to use but I just have no idea how to do this.
The .bat file currently has:
SET ROPTS=--no-save --no-environ --no-init-file --no-restore --no-Rconsole
R-Portable\App\R-Portable\bin\Rscript.exe %ROPTS% runShinyApp.R 1> ShinyApp.log 2>&1
Thanks in advance
I have recently begun using knitr with Rstudio. I ran into the "No tex installation detected. Please install TeX before compiling." error in both my Ubuntu and windows OS's.
After some research I was able to amend the issue in Ubuntu by adding the directory of my tex installation to PATH. I did this by including the following line in Renviron.site
PATH=/usr/local/texlive/2013/bin:${PATH}
However, the issue remains for my windows installation. I was unable to find the Renviron.site file, so I created one in the same directory of Renviron, and added the location of my tex installation in windows:
PATH=C:\texlive\2013\bin\win32:${PATH}
However this does not solve my problem and Rstudio is still unable to find my tex packages, such that
file.exists(Sys.which('texi2dvi'))
Returns FALSE.
How should I proceed?
R will always source the Rprofile.site file first. On Windows, the file is in the C:\Program Files\R\R-n.n.n\etc directory.
see here: Add TeX path to R Studio - Ubuntu and here: Customizing Startup
I found package tinytex to be of interest. It allows to install a minimal tex distrib without administrator privilege, takes care of path, and useful function to add missing tex packages. Works well with knitr
It is written by Xie Yihui author of knitr.
Let me build up to #HeavenZone's answer:
You should go onto
C:\Program Files\R\R-n.n.n\etc
directory and give permissions to modify the files in on the folder. This can be done by doing
Right click->Properties->Security->Edit->Select Users->In Permissions
list tick->Write
Once you're done you should open the file Renviron.site on the directory etc. And add a line like
PATH=C:\Program Files\MiKTeX 2.9\miktex\bin\64:${PATH}
I wrote a new line, assume that the definitions are concatenated. Perhaps you need also \pdflatex.exe in the above path.
Once you have this, restart Rstudio and it should grasp now the latex distribution.
I would probably change the title of this question to include that this is the Windows version so that it is easy to look for it, however my edit was rejected so I leave it to someone else...
I have an IPython notebook and I would like to use one of my variables inside a markup cell. Is this even possible? If so, how do you do it?
If you don't mind a code cell that does the job, there is a possibility without adding any extensions.
from IPython.display import Markdown as md
fr=2 #GHz
md("$f_r = %i$ GHz"%(fr))
This will show a markdown cell in a nicely LaTeX formatted output
Currently, this is not possible, however there is a large discussion on this topic here https://github.com/ipython/ipython/pull/2592. The PR is currently closed, but a corresponding issue is opened https://github.com/ipython/ipython/issues/2958 and marked as wishlist.
Update
In the meantime an IPython extension has appeared which allows to render python variables in markdown cells. This extension is part of the IPython notebook extensions and works with IPython 2.x and 3.x. For a detailed description see the wiki page.
It is not officially supported, but installing the python markdown extension will allow you to do so. It is part of the nbextensions, for which you will find installation instructions on their github page. Make sure you'll enable the python markdown extension using a jupyter command or the extension configurator.
Calling python variables then should work with the {{var-name}} syntax, which is described in the readme of the corresponding github page (linked in the wiki):
For example: If you set variable a in Python
a = 1.23
and write the following line in a markdown cell:
a is {{a}}
It will be displayed as:
a is 1.23
Further info on this functionality being integrated into ipython/jupyter is discussed in the issue trackers for ipython and jupyter.
The link: installing notebook extention
gives a clear description of what is necessary to enable the use of variables in markdown cells. Following it, performed the following actions to realize it:
conda install -c conda-forge jupyter_contrib_nbextensions
jupyter contrib nbextension install --user
after a successful completion of the above command I enabled the python markup extension, from jupyter dashboard, as per the following illustration:
Last but not least!!! The NOTEBOOK HAS TO BE TRUSTED to make the markup extension works with python variables
and it worked for me!
I'm working on getting knitr setup. I installed the latest version of R (2.15.1), Lyx 2.0 including the MiKTex 2.9 distribution, and RStudio 0.96.304 on a Windows 7 Enterprise box. I can get pdflatex output if I open up Lyx and simply view the tutorial, so the basic system is working. I then downloaded the minimal Rnw example saved it in my working directory as testknitr.Snw, opened that file in RStudio, and pressed the compile PDF button. The knitr output completes with a single warning about the parser package, and produces a file testknitr.tex. pdflatex.exe then runs, but fails, and the particular error in the log file seems to be
! LaTeX Error: Environment alltt undefined.
I received the same error when attempting to compile testknitr.tex using TexWorks. I created that file from inside R using knit("testknitr.Rnw") - different extension because of the default in RStudio. I did tell MikTek to update packages automatically when compiling. A bit of research on CTAN suggests that the alltt environment is part of the ltxbase package, which is installed when I look at the package manager. In fact it seems like a pretty core part of the whole thing!
OK - I was reading the comments on the minimal example page, and discovered a workaround to that problem, and that it is a known bug as of 19 hours ago. And yes, I doublechecked that RStudio is set to use knitr, not sweave. I now get a new error:
! LaTeX Error: Command \textquotesingle unavailable in encoding T1.
EDIT: OK! it turns out that error isn't fatal - there's a lovely pdf of the minimal example sitting in the working directory if one takes the time to look. Somewhat alarming that RStudio thinks compilation failed when it didn't?
The workaround, perhaps obvious to an experience LaTex-ie, is to add
\usepackage{alltt}
to the file. According to Yihui's comment this will be fixed in future versions, or now if you want to get the development version from github. I also tested #Yihui's comment above that the line
\usepackage[T1]{fontenc}
could be commented out. This fixes the 2nd issue in the question, and RStudio now treats the compilation as successful, cleaning up (some?) intermediate files and immediately previewing the pdf.