I have some Latex slides I want to put in an rmarkdown beamer presentation, e.g.
---
title: "Untitled"
author: "Me"
date: "8 November 2017"
output: beamer_presentation
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
\section{First section}
\begin{frame}{List 1}
\begin{itemize}
\item Point A
\item Point B
\item Point C
\end{itemize}
\end{frame}
This returns an error:
"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS
presentation3.utf8.md --to beamer --from
markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash
--output presentation3.pdf --highlight-style tango --latex-engine pdflatex output file: presentation3.knit.md
! Missing \endgroup inserted.
\endgroup l.85 \end{frame}
pandoc.exe: Error producing PDF Fehler: pandoc document conversion
failed with error 43 Zusätzlich: Warnmeldung: Ausführung von Kommando
'"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS
presentation3.utf8.md --to beamer --from
markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash
--output presentation3.pdf --highlight-style tango --latex-engine pdflatex' ergab Status 43 Ausführung angehalten
How to fix this?
Related
I'm trying to convert a latex file to markdown using Pandoc. The latex file contains linked images, for example like this:
\begin{figure}[htbp]
\begin{center}
\leavevmode
\scalebox{0.4}{\includegraphics{microsatsFigures/Figure_traceView.png}}
\end{center}
\caption{The Traces view}
\label{traces}
\end{figure}
However in the markdown file all I get is
::: center
:::
Is this a known limitation of Pandoc, or is there some command I'm missing that will convert the image instructions? The command I used in pandoc was just the standard format:
pandoc -f latex -t markdown Inputfile.tex -o Outputfile.md
I have compiled an Rmd file that should knit to PDF, whereof the code is derived from another model which does knit to pdf. However, with the exact same yaml header parameters, the knitting defaults to HTML instead of pdf for the first model (When clicking 'knit to pdf'. I am using R version 3.6.1.
---
title: "Title"
subtitle: "Subtitle"
author:
- Piet en Henk
date: "`r format(Sys.time(), '%B %d, %Y')`"
abstract: "This document provides the description of the used R code for ...."
geometry: "left=1in, right=1in, top=1in, bottom=1in, headsep=0.4in"
output:
pdf_document:
highlight: zenburn
number_sections: true
toc: true
toc_depth: 2
header-includes:
- \usepackage{eso-pic}
- \usepackage{graphicx}
- \usepackage{transparent}
- \usepackage{fancyhdr}
- \usepackage{datetime}
- \usepackage{hyperref}
- \usepackage{float}
- \usepackage{amsmath}
- \usepackage{courier}
- \usepackage{placeins}
- \pagestyle{fancy}
- \numberwithin{figure}{section}
- \newdateformat{mydate}{\monthname[\THEMONTH] \THEYEAR}
- \renewcommand{\headrulewidth}{1pt}
- \renewcommand{\footrulewidth}{0.5pt}
- \fancyhead[L]{\includegraphics{Company.png}}
- \fancyfoot[RO]{Company}
- \fancyfoot[L]{Version 1.0}
---
```{=latex}
% Trigger ToC creation in LaTeX
\renewcommand{\baselinestretch}{0.7}\normalsize
\renewcommand{\baselinestretch}{1.2}\normalsize
\tableofcontents
```
\pagebreak
And the loggings from the Rmarkdown pane:
processing file: index.Rmd
|......................................................................| 100%
inline R code fragments
output file: index.knit.md
"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS index.knit.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output index.html --lua-filter "C:\PROGRA~1\R\R-36~1.1\library\bookdown\RMARKD~1\lua\CUSTOM~1.LUA" --lua-filter "C:\PROGRA~1\R\R-36~1.1\library\RMARKD~1\RMARKD~1\lua\PAGEBR~1.LUA" --lua-filter "C:\PROGRA~1\R\R-36~1.1\library\RMARKD~1\RMARKD~1\lua\LATEX-~1.LUA" --metadata-file "C:\Users\mpruijs\AppData\Local\Temp\2\RtmpER5E5P\file2bec2a1279b1" --wrap preserve --standalone --section-divs --table-of-contents --toc-depth 3 --template "C:\PROGRA~1\R\R-36~1.1\library\bookdown\TEMPLA~1\GITBOO~1.HTM" --highlight-style pygments --number-sections --css style.css --include-in-header "C:\Users\mpruijs\AppData\Local\Temp\2\RtmpER5E5P\rmarkdown-str2bec4d551488.html" --mathjax
Output created: index.html
Warning message:
In as.POSIXlt.POSIXct(x, tz) : unable to identify current timezone 'C':
please set environment variable 'TZ'
Here's the simplest LaTeX file:
\documentclass[12pt]{article}
\title{How to write a report in LaTeX}
\author{ABC\\abc_z#yahoo.com}
\date{May 2021}
\begin{document}
\maketitle
Hello World
\end{document}
But when I Quick Build then it gives the following ERRORS:
! Missing $ inserted.<inserted text>$ \maketitle
! Extra }, or forgotten $.<template> \unskip \hfil }\hskip \tabcolsep \endtemplate \maketitle
! Missing $ inserted.<inserted text>$ \maketitle
! Missing } inserted.<inserted text>} \maketitle
I got it. I have used _ , with that it gives error. One needs to either remove _ or use \ with, as \_ , then it works.
I am quite new with Knitr, and I am trying to write my first document "importing" some "\newcommand" from my latex files.
All my "\newcommand" are processed perfectly with the exception of those with "arguments".
For instance I have added the packages I normally use in latex:
header-includes:
-\usepackage{a4wide,amsmath,amsthm,epsfig,graphicx}
- \usepackage{amsmath,amsthm,amssymb}
- \usepackage{amsfonts}
- \usepackage{graphics}
- \usepackage{subfigure}
- \usepackage{dsfont}
- \usepackage{bbm}
- \usepackage{bm}
- \usepackage{xcolor}
- \usepackage{dcolumn}
- \usepackage{pstricks,fancyhdr,fancybox}
- \usepackage{dcolumn}
- \usepackage{bm}
But the following does not work
\newcommand{\PR}[1]{\bm{P}\left\{{#1}\right\}}
The error is
output file: newfile.knit.md
"../Documents/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS newfile.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output newfile.pdf --template "C:\Users\P14814\Documents\R\win-library\3.4\rmarkdown\rmd\latex\default-1.17.0.2.tex" --highlight-style tango --latex-engine pdflatex --variable graphics=yes --variable "geometry:margin=1in"
! Missing $ inserted.
<inserted text>
$
l.180 \newcommand{\PR}{[}1{]}\{\bm{P}
pandoc.exe: Error producing PDF
Error: pandoc document conversion failed with error 43
In addition: Warning message:
running command '"../Documents/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS newfile.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output newfile.pdf --template "C:\Users\P14814\Documents\R\win-library\3.4\rmarkdown\rmd\latex\default-1.17.0.2.tex" --highlight-style tango --latex-engine pdflatex --variable graphics=yes --variable "geometry:margin=1in"' had status 43
Execution halted
Your help is very much appreciated!!
I strongly recommend you to put these commands in an external file, say, preamble.tex, and include it via the includes option.
output:
pdf_document:
includes:
in_header: preamble.tex
See Section 3.3.7.3 of the R Markdown book: https://bookdown.org/yihui/rmarkdown/pdf-document.html
Using header-includes is not entirely safe. Pandoc may mangle certain characters when generating the LaTeX output. If your Pandoc version is higher than 2.0 (check rmarkdown::pandoc_version()), you may use a raw LaTeX block to protect the LaTeX content, e.g.,
header-includes: |
```{=latex}
\usepackage{a4wide,amsmath,amsthm,epsfig,graphicx}
\usepackage{amsmath,amsthm,amssymb}
......
```
I have a markdown + latex document that has compiled fine, until now when I added a special character ('ä') and get the error:
hGetContents: invalid argument (invalid UTF-8 byte sequence)
Following some advice I've found I have tried combinations of these in a custom preamble, but with no success:
\usepackage[utf8]{inputenc} % also tried [utf8x]
\usepackage[T1]{fontenc}
\usepackage[swedish]{babel}
Any suggestions on how to solve this?
The full preamble is:
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[a4paper,tmargin=2.5cm,bmargin=2.8cm,lmargin=3.5cm,rmargin=3.5cm]{geometry}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{fixltx2e}
\usepackage[all,error]{onlyamsmath}
\MakeRobust{\overrightarrow}
\usepackage{natbib}
\renewcommand{\normalsize}{\fontsize{11pt}{13.3pt}\selectfont}
pandoc call:
pandoc -f markdown file.mkd -H standard.tex --csl=amnat.csl --bibliography refs.bib -o output.pdf