How to use latex standalone package with knitr? - latex

I'm trying to generate png pictures of charts using knitr and latex standalone package. The following minimal code compiles but the output is pdf:
\documentclass[convert=true]{standalone}
\begin{document}
<<test-plot, echo=FALSE>>=
plot(rnorm(10))
#
\end{document}
Now if I want to pass some options to standalone I must use curly brackets after convert=, but simply putting something like convert={true} will produce an error:
! Argument of \#fileswith#pti#ns has an extra }.
...
Something like convert={true, ghostscript, gsexe=gswin64c, density=1200} works fine with tikz charts.
Am I overlooking something or maybe a knitr shortcoming? Any ideas on how to go around?

Related

Trying to replicate a LaTeX front cover template

I am trying to copy the following template:
Where I would like to replace the tiger with an image of my own but first I would like to replicate this one.
On the page below I have the LaTeX code but it does not work. I obtain a few errors (out of the box)
https://tug.org/PSTricks/main.cgi?file=Examples/Logos/logos
(Code is here^)
Are there any similar title pages where I can replicate the following?
When I run the code it seems to work fine (except that the image of the tiger is missing), my compiler runs LaTeX -> drips -> ps2pdf, can TeXStudio do something similar?

Converting code listings from mediawiki to latex using pandoc

Is there an easy way to say pandoc converter I wish to replace all my source codes in mediawiki article convert to an lstlisting environment on its Latex output?
At this moment, all my <source lang="c"> some code... </source> environments are converted into something like this
\begin{Shaded}\begin{Highlighting}[]
\NormalTok{ some code \textless{}\textless{} }\DecValTok{1}\NormalTok{ \CommentTok{// set... \end{Highlighting}
\end{Shaded}
Not only the code is completely unreadable but also my Latex distribution is not able to translate the code and is missing probably some packages.
I wish to have simply \begin{lstlisting} some code \end{lstlisting} at the output with no additional changes to the code itself.
And I don't speak Haskell, believing there should be an easier way...
Solution was very simple. There is a --listings command line option solving this problem as Sam Carter pointed out.

Mathjax does not render colorbox correctly

I try to render \colorbox{yellow}{\sigma} and configurate the mathjax following http://docs.mathjax.org/en/latest/tex.html), but it just does not work.
Result:
Configuration I find from http://docs.mathjax.org/en/latest/tex.html (I tried with and without autoload-all.js, both don't work):
It looks like the same issue here on https://tex.stackexchange.com/
The problem here is that \colorbox reverts its argument back to text mode
Then you should write:
\colorbox{yellow}{$\sigma$}
Convenient sites to test your syntax:
http://quicklatex.com/
(add \usepackage{color} in the Custom LaTeX Document Preamble option to test colors)
and
here for Tex supported by mathjax.
Note: as \colorbox is displayed in red perhaps the command is not recognized, which means that your configuration contains errors. You can test with the macro require and write
\require{color}\colorbox{yellow}{$\sigma$}

usepackage and making macros in ipython notebook

How can user macros and packages be included in the latex rendered in markdown cells in ipython?
e.g.:
\usepackage{amssymb}
\newcommand{kms}{\ensuremath{\mathrm{km~s}^{-1}}
It is possible to define macros in cells with markdown. Just put the \newcommand between $'s:
$\newcommand{kms}{{\mathrm{km~s}^{-1}}}$
(Note that I removed the \ensuremath command, as it is not accessible.)
In any following statement (in the whole notebook) you can call the macro (in a markdown cell only, of course):
$\kms$
I do not know a way to include extra packages :( If you ever learn how, I would also encourage you to use the siuntx package to format units.
The Html notebook use mathjax to render LaTeX, I suggest reading its doc to know wether it is possible and how.

LaTeX help with href

I am trying to create a hyperlink using LaTeX. When I use the command pdflatex to compile the file, I get an error.
The relevant lines of the document are:
\documentclass[12pt]{article}
\usepackage{hyperref}
\begin{document}
...
\href{http://www.cs.utah.edu/dept/old/texinfo/as/gprof_toc.html}{gprof}
pdflatex created a file called missfont.log, which contains this:
mktextfm pzdr
What am I doing wrong?
Do you have the pzdr font installed? If you're on Debian or Ubuntu, try installing the texlive-fonts-recommended package.
Does the hyperref package purport to make hyperlinks to arbitrary web pages? I thought it was just for intra-document links (which it does automatically). I would do
\usepackage{url}
and
\url{http://foo.com}
to format a URL in your document.
ADDED: Thanks Will, I didn't know that about href. But if you're creating a document that's mainly targeting paper as the intended medium, I think the url package for formatting URLs is the way to go. But if you think the href package subsumes the url package, I'd love to be set straight on that.

Resources