Theorem and Proof Environment in Beamer - latex

I am currently trying to use quarto beamer to making lecture slides. I would like to use the theorem environment in beamer, the qmd file however cannot render properly. Rendering stopped with latex error showing that Command \theorem already defined. I am wondering what have I done wrong?
The sample codes are as follows
---
title: "Untitled"
format: beamer
editor: visual
---
## Quarto
Quarto enables you to weave together content and executable code into a finished presentation. To learn more about Quarto presentations see <https://quarto.org/docs/presentations/>.
::: {#thm-test}
## Just a quick test
:::
If possible, I hope that I can include theorem, definition, example environment in quarto beamer presentation.
Thanks for the help in advance.

Quarto very unhelpfully loads tons of unnecessary packages like amsthm, which beamer automatically loads, and then blindly tries to define a new theorem environment, even though beamer already has defined it. At the very minimum it should check if an environment is already defined before doing this.
You can work around the problem with the notheorems class options.
---
title: "Untitled"
format: beamer
editor: source
classoption: "notheorems"
---
## Quarto
Quarto enables you to weave together content and executable code into a finished presentation. To learn more about Quarto presentations see <https://quarto.org/docs/presentations/>.
::: {#thm-test}
## Just a quick test
:::

Related

How can I use LaTeX package 'coffee4' to export an .Rmd to a Tufte Handout style .pdf?

In this video at around 7:30 into the video, Yihui Xie make a demo of the package coffee4 which adds random coffee stains to a document. However, he is showing them in a regular LateX style pdf. I am wondering if I could also use this package or an adopted version of it when creating a pdf in the style of tufte-handout. Grateful for help on how I should go about in order to achieve such a result. In particular I am wondering how to download and install the coffee4 package in RStudio and what to write in the YAML or in R code in the document itself.
If you place coffee4.sty somewhere latex can find it, e.g. the same folder as your .rmd file, then you can use it like this:
---
title: "An Example Using the Tufte Style"
author: "John Smith"
output:
tufte::tufte_handout: default
header-includes:
- \usepackage{coffee4}
---
\cofeAm{1}{1.0}{0}{5.5cm}{3cm}
test

Modify latex template in Rmarkdown

Can I modify the default Latex template used by Rmarkdown to compile Rmd files to pdf with the beamer class?
I am asking because of the difficulties I encounter using \includepdf (from the pdfpages package). Inspecting the generated tex source suggests that the root problem is the ignorenonframetext option in \documentclass[ignorenonframetext,]{beamer}.
(It is not a viable option for me to manually change the tex source each time)
In short: I want to modify the "Rmd beamer Latex template" (if that exists) to change the default ignorenonframetext
You don't need to modify the template, you can use \includepdf like this:
---
output:
beamer_presentation:
keep_tex: true
header-includes:
- \usepackage{pdfpages}
- \setbeamercolor{background canvas}{bg=}
- \makeatletter\beamer#ignorenonframefalse\makeatother
---
test
``` {=latex}
\end{frame}
\includepdf[pages=1-10]{example-image-duck}
\begin{frame}
```
test
(the line \setbeamercolor{background canvas}{bg=} is necessary for beamer versions < 3.64, a patch has been added in 9e3bb9)

RStudio ioslides, mathjax, what the heck?

So typically I use beamer for presentations, but I thought what the heck just for fun I would do a ioslides presentation so I could embed a shiny app into the presentation. For the most part making the slides has been pretty smooth, but I cannot seem to get any of the math latex setting to work. Here is a toy example where I simply want the KM estimator to display
---
title: "test"
author: "tes"
date: "1/1/16"
output:
ioslides_presentation:
widescreen: true
mathjax: "http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"
runtime: shiny
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
## Test
$$
\hat{S}(t)=\prod_{y_{(i)}\leq t}\hat{p}_{t}=\prod_{y_{(i)}\leq t}\dfrac{n_{i}-d_{i}}{n_{i}}=\prod_{i=1}^{k}\dfrac{n_{i}-d_{i}}{n_{i}} & \quad\textrm{where }y_{k}\leq t<y_{k+1}
$$
All I get is a slide with a simple wireframe box around the latex call (e.g the \hat{S}(t)=\prod_{y_{(I)}... I should note that I have also tried just simply wrapping with single $ to no avail.
What am I missing? - I looked all over the R markdown documentation but I cannot see to figure it out.
Simple latex calls work jut fine, for example
$x^{2}$
renders exactly as I would expect.
I assume this is something silly, but it is besting me.
Thanks!
Your equation is actually not valid. It contains an ampersand (&) that is not within an alignment, so MathJax rejects it. If you remove the ampersand, I suspect it will work for you.
If there is a way to configure MathJax from within your slides, you could disabled the noErrors extension so that the actual error messages will be displayed rather than the boxed source.

Set double spacing and line numbers when converting from Markdown to PDF with pandoc

I am using markdown & pandoc for scientific writing, I know I can change margins of the final pdf using
Set margin size when converting from Markdown to PDF with pandoc
but very often the journals require double lines and line numbers in submitted manuscripts, the question is how to change these, I don't know much about LaTex so I am lost in that jungle.
Thanks!
In more recent version of Pandoc, you can use a YAML header and include a bunch of metadata in that, instead of using options on the command line. So, for instance, you can put this at the top of your .md file:
---
title: The Document Title
author:
- Your Name
- Co Author
date: \today{}
geometry: margin=2cm
header-includes:
- \usepackage{setspace}
- \doublespacing
- \usepackage{lineno}
- \linenumbers
---
Document Text
and pandoc will read those options and apply them automatically.
There is maybe an easy way: generate a file with the packages we need
\usepackage{setspace}
\doublespacing
\usepackage[vmargin=1in,hmargin=1in]{geometry}
\usepackage{lineno}
\linenumbers
I named it options.sty. And use the -H FILE option that includes the content of the FILE at the end of the preamble. (as used in https://github.com/karthikram/smb_git)
pandoc -H options.sty --bibliography mypaper.bib mypaper.md -o mypaper.pdf
The advantage is that we don't need to edit the template. To add linenumbers, change margins, and set spacing it works.
You'll need to use a custom LaTeX template. First, use pandoc to create a copy of the default template:
pandoc -D latex > mytemplate.latex
Now edit this template. Somewhere in the preamble (between \documentclass{...} and \begin{document}), insert the lines
\usepackage{setspace}
\doublespacing
Then, to use your custom template:
pandoc --template mytemplate.latex mypaper.txt -o mypaper.tex

sphinx customization of latexpdf output?

Just curious if anyone knows how to customize the sphinx output when using the latexpdf target? I've seen lots of custom stuff for html output, but cant seem to find any example of custom pdf output.
Specifically, I'd be interested in customizing the title page, headers, footers, and possibly adding a few pages of front matter before the contents.
Has anyone seen any examples of this kind of customization, or do people pretty much just use the "stock" sphinx output when generating pdfs? Thanks!
Yes i think better or clearer documentation for latex styling would be nice and
some examples.
Here is a question on the sphinx mailing list, which is about about using packages.
sphinx has its own latex documentclass in a file called sphinxmanual.cls or
sphinxhowto.cls, if i remember correctly its a report documentclass that is used as base.
then there is 2 style files, which are the packages, it is those files contents
that are called on when you write \usepackage{mylatexstilefile}
Question about using latex packages
http://groups.google.com/group/sphinx-dev/browse_thread/thread/890dab5e53fff004
Here is my conf.py.
preamb_old = ur'''
%\documentclass{memoir}
\makeatletter
\fancypagestyle{normal}{
\fancyhf{}
\fancyfoot[LE,RO]{{\py#HeaderFamily\thepage}}
\fancyfoot[LO]{{\py#HeaderFamily\nouppercase{\rightmark}}}
\fancyfoot[RE]{{\py#HeaderFamily\nouppercase{\leftmark}}}
\fancyhead[LE,RO]{{\py#HeaderFamily \#title}} % here's the change
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
}
\makeatother
%\color {blue}
%\normalcolor {dark blue}
\pagecolor [RGB]{255, 247, 226}
\definecolor{VerbatimColor}{rgb}{0.95,0.85,0.65}
\definecolor{VerbatimBorderColor}{rgb}{0.5,0.95,0.1}
'''
f = open('graph/static/latexstyling.tex', 'r+')
PREAMBLE = f.read();
latex_elements = {
'papersize':'a4paper',
'pointsize':'11pt',
'classoptions': ',openany',
'babel': '\\usepackage[english]{babel}',
'preamble': PREAMBLE
}
i don't use preamble_old anymore, but it is an example of changes directly in
conf.py, to your latex preamble.
Check out latex_elements and latex_additional_files in the sphinx docs as
a starting point.

Resources