无法在Rmarkdown中使用block2到pdf

时间:2019-03-20 11:48:24

标签: r bookdown

我尝试使用block2创建一个块,例如warningimportant

```{block2, type='rmdimportant'}
Some text in the important block.

```

我收到以下错误:

output file: Report.knit.md

! Undefined control sequence.
\kframe ...argin \hskip \columnwidth }\MakeFramed 
                                                  {\advance \hsize -\width \...
l.882 \BeginKnitrBlock{rmdimportant}

Error: Failed to compile Report.tex. See Report.log for more info.
Execution halted

我需要在R中安装某些东西吗?

上下文:

  • 我使用了bookdown提供的默认style.csspreamble.tex(请参阅下文)。
  • .rmdimportantstyle.css中定义。
  • preamble.tex包含一个\newenvironment{rmdimportant}

我使用了以下preamble.tex(被要求):

\usepackage{booktabs}
\usepackage{longtable}
\usepackage{array}
\usepackage{multirow}
\usepackage[table]{xcolor}
\usepackage{wrapfig}
\usepackage{float}
\usepackage{colortbl}
\usepackage{pdflscape}
\usepackage{tabu}
\usepackage{threeparttable}
\usepackage{threeparttablex}
\usepackage[normalem]{ulem}
\usepackage{makecell}
\usepackage{graphicx}
\usepackage{fancyhdr}
%\usepackage[ngerman]{babel}

%%%%%%%%The footer on every page
\pagestyle{fancy}
\fancyfoot{\centering\footnotesize\upshape We reserve all rights in this document and in the information contained therein.  Reproduction, use or disclosure to third parties without express authority is strictly forbidden. * 2018 ABB Schweiz AG}
\pagestyle{headings}

%%%%%%%%%Slect the font you want to use
%http://www.tug.dk/FontCatalogue/montserratlight/
%\usepackage[defaultfam,light,tabular,lining]{montserrat} %% Option 'defaultfam'
%% only if the base font of the document is to be sans serig
%\usepackage[T1]{fontenc}
%\renewcommand*\oldstylenums[1]{{\fontfamily{Montserrat-TOsF}\selectfont #1}}

%%%%%%%%The custom rmdnote, rmdinfo etc parts of the pdf.
\makeatletter
\newenvironment{kframe}{%
\medskip{}
\setlength{\fboxsep}{.8em}
 \def\at@end@of@kframe{}%
 \ifinner\ifhmode%
  \def\at@end@of@kframe{\end{minipage}}%
  \begin{minipage}{\columnwidth}%
 \fi\fi%
 \def\FrameCommand##1{\hskip\@totalleftmargin \hskip-\fboxsep
 \colorbox{shadecolor}{##1}\hskip-\fboxsep
     % There is no \\@totalrightmargin, so:
     \hskip-\linewidth \hskip-\@totalleftmargin \hskip\columnwidth}%
 \MakeFramed {\advance\hsize-\width
   \@totalleftmargin\z@ \linewidth\hsize
   \@setminipage}}%
 {\par\unskip\endMakeFramed%
 \at@end@of@kframe}
\makeatother

\makeatletter
\@ifundefined{Shaded}{
}{\renewenvironment{Shaded}{\begin{kframe}}{\end{kframe}}}
\makeatother

\newenvironment{rmdblock}[1]
  {
  \begin{itemize}
  \renewcommand{\labelitemi}{
    \raisebox{-.7\height}[0pt][0pt]{
      {\setkeys{Gin}{width=3em,keepaspectratio}\includegraphics{images/#1}}
    }
  }
  \setlength{\fboxsep}{1em}
  \begin{kframe}
  \item
  }
  {
  \end{kframe}
  \end{itemize}
  }
\newenvironment{rmdnote}
  {\begin{rmdblock}{note}}
  {\end{rmdblock}}
\newenvironment{rmdcaution}
  {\begin{rmdblock}{caution}}
  {\end{rmdblock}}
\newenvironment{rmdimportant}
  {\begin{rmdblock}{important}}
  {\end{rmdblock}}
\newenvironment{rmdtip}
  {\begin{rmdblock}{tip}}
  {\end{rmdblock}}
\newenvironment{rmdwarning}
  {\begin{rmdblock}{warning}}
  {\end{rmdblock}}

0 个答案:

没有答案