R Markdown中未定义Tex证明环境,生成的Tex文件中没有amsm [英] Tex Proof environment not defined in R Markdown, amsthm not in generated Tex file

查看:402
本文介绍了R Markdown中未定义Tex证明环境,生成的Tex文件中没有amsm的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下R markdown文件生成以下Tex文件.我在我的.rmd标头中包含了amsthm,并且它正在生成没有amsthm的Tex文件.结果,在编译期间未定义证明环境.

I am using the following R markdown file to generate the following Tex file. I am including amsthm in my .rmd header and it is generating a Tex file without amsthm. As a result, the proof environment is not defined during compilation.

这是我的.rmd文件:

Here is my .rmd file:

---
title: Real Analysis Notes 01
header_includes:
- \usepackage{amsthm}
 output:
  pdf_document:
   keep_tex: true
---

This is a test file.

\begin{proof}
This is a proof.
\end{proof}

编译后会显示以下输出:

When compiled gives this output:

> require(rmarkdown); render('RA01-notes.rmd')
Loading required package: rmarkdown


processing file: RA01-notes.rmd
  |.................................................................| 100%
  ordinary text without R code


output file: RA01-notes.knit.md

/usr/bin/pandoc +RTS -K512m -RTS RA01-notes.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output RA01-notes.tex --template /usr/lib/R/library/rmarkdown/rmd/latex/default-1.17.0.2.tex --highlight-style tango --pdf-engine pdflatex --variable graphics=yes --variable 'geometry:margin=1in' --variable 'compact-title:yes' 
! LaTeX Error: Environment proof undefined.

Error: Failed to compile RA01-notes.tex. See RA01-notes.log for more info.
Execution halted

shell returned 1

哪个生成此Tex文件:

Which generates this Tex file:

\documentclass[]{article}
\usepackage{lmodern}
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\usepackage{fixltx2e} % provides \textsubscript
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
  \usepackage[T1]{fontenc}
  \usepackage[utf8]{inputenc}
\else % if luatex or xelatex
  \ifxetex
    \usepackage{mathspec}
  \else
    \usepackage{fontspec}
  \fi
  \defaultfontfeatures{Ligatures=TeX,Scale=MatchLowercase}
\fi
% use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
% use microtype if available
\IfFileExists{microtype.sty}{%
\usepackage{microtype}
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\usepackage[margin=1in]{geometry}
\usepackage{hyperref}
\hypersetup{unicode=true,
            pdftitle={Real Analysis Notes 01},
            pdfborder={0 0 0},
            breaklinks=true}
\urlstyle{same}  % don't use monospace font for urls
\usepackage{graphicx,grffile}
\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
\makeatother
% Scale images if necessary, so that they will not overflow the page
% margins by default, and it is still possible to overwrite the defaults
% using explicit options in \includegraphics[width, height, ...]{}
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
\IfFileExists{parskip.sty}{%
\usepackage{parskip}
}{% else
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}
}
\setlength{\emergencystretch}{3em}  % prevent overfull lines
\providecommand{\tightlist}{%
  \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\setcounter{secnumdepth}{0}
% Redefines (sub)paragraphs to behave more like sections
\ifx\paragraph\undefined\else
\let\oldparagraph\paragraph
\renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}}
\fi
\ifx\subparagraph\undefined\else
\let\oldsubparagraph\subparagraph
\renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}}
\fi

%%% Use protect on footnotes to avoid problems with footnotes in titles
\let\rmarkdownfootnote\footnote%
\def\footnote{\protect\rmarkdownfootnote}

%%% Change title format to be more compact
\usepackage{titling}

% Create subtitle command for use in maketitle
\newcommand{\subtitle}[1]{
  \posttitle{
    \begin{center}\large#1\end{center}
    }
}

\setlength{\droptitle}{-2em}

  \title{Real Analysis Notes 01}
    \pretitle{\vspace{\droptitle}\centering\huge}
  \posttitle{\par}
    \author{}
    \preauthor{}\postauthor{}
    \date{}
    \predate{}\postdate{}


\begin{document}
\maketitle

This is a test file.

\begin{proof}
This is a proof.
\end{proof}


\end{document}

推荐答案

pandoc选项为header-includes(连字符,而不是下划线).

The pandoc option is header-includes (hyphen and not an underscore).

这篇关于R Markdown中未定义Tex证明环境,生成的Tex文件中没有amsm的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆