更新

更新

我试图跟随这个例子它展示了如何在 RMarkdown 中编写单独的章节,然后使用 将其包含在主 RNW 文件中\include{}

但是,我无法让 pandoc 读取 RMD 文件。RNW 文件似乎在没有调用 pandoc 读取 RMD 文件的块的情况下进行编译。

源代码如下。编译.log文件包含在本文底部的源代码之后。有人能看出为什么 RMD 文件没有包含在最终 PDF 中吗?我该如何修复它?你能得到原始示例上班?

我的源代码

Chapter1.RmdRMarkdown 文件:

# My first Chapter
This is a {\huge first} chapter $E=mc^2$ 

```{r test, echo=FALSE}
2+3
```

LaTeX.RnwR-noweb 又名 R-LaTeX 文件:

\documentclass{book}

<<calltopandoc, echo=F,include=F, engine='sh'>>=
pandoc Chapter1.Rmd --top-level-division=chapter -f markdown -t latex -o Chapter1.tex
@

\begin{document}

\include{Chapter1}

At least this text should show in the PDF.

\end{document}

在尝试编译之前,我还确保进入包含和setwd()的目录。LaTeX.RnwChapter1.Rmd

编译日志LaTeX.log

This is pdfTeX, Version 3.14159265-2.6-1.40.19 (MiKTeX 2.9.6630 64-bit) (preloaded format=pdflatex 2018.5.18)  31 AUG 2018 10:59
entering extended mode
**./LaTeX.tex
(LaTeX.tex
LaTeX2e <2017-04-15>
Babel <3.18> and hyphenation patterns for 75 language(s) loaded.
("C:\Program Files\MiKTeX 2.9\tex\latex\base\book.cls"
Document Class: book 2014/09/29 v1.4h Standard LaTeX document class
("C:\Program Files\MiKTeX 2.9\tex\latex\base\bk10.clo"
File: bk10.clo 2014/09/29 v1.4h Standard LaTeX file (size option)
)
\c@part=\count79
\c@chapter=\count80
\c@section=\count81
\c@subsection=\count82
\c@subsubsection=\count83
\c@paragraph=\count84
\c@subparagraph=\count85
\c@figure=\count86
\c@table=\count87
\abovecaptionskip=\skip41
\belowcaptionskip=\skip42
\bibindent=\dimen102
)
("C:\Program Files\MiKTeX 2.9\tex\latex\graphics\graphicx.sty"
Package: graphicx 2017/06/01 v1.1a Enhanced LaTeX Graphics (DPC,SPQR)

("C:\Program Files\MiKTeX 2.9\tex\latex\graphics\keyval.sty"
Package: keyval 2014/10/28 v1.15 key=value parser (DPC)
\KV@toks@=\toks14
)
("C:\Program Files\MiKTeX 2.9\tex\latex\graphics\graphics.sty"
Package: graphics 2017/06/25 v1.2c Standard LaTeX Graphics (DPC,SPQR)

("C:\Program Files\MiKTeX 2.9\tex\latex\graphics\trig.sty"
Package: trig 2016/01/03 v1.10 sin cos tan (DPC)
)
("C:\Program Files\MiKTeX 2.9\tex\latex\graphics-cfg\graphics.cfg"
File: graphics.cfg 2016/06/04 v1.11 sample graphics configuration
)
Package graphics Info: Driver file: pdftex.def on input line 99.

("C:\Program Files\MiKTeX 2.9\tex\latex\graphics-def\pdftex.def"
File: pdftex.def 2018/01/08 v1.0l Graphics/color driver for pdftex
))
\Gin@req@height=\dimen103
\Gin@req@width=\dimen104
)
("C:\Program Files\MiKTeX 2.9\tex\latex\graphics\color.sty"
Package: color 2016/07/10 v1.1e Standard LaTeX Color (DPC)

("C:\Program Files\MiKTeX 2.9\tex\latex\graphics-cfg\color.cfg"
File: color.cfg 2016/01/02 v1.6 sample color configuration
)
Package color Info: Driver file: pdftex.def on input line 147.
)
(C:\Users\eli02\AppData\Roaming\MiKTeX\2.9\tex\latex\framed\framed.sty
Package: framed 2011/10/22 v 0.96: framed or shaded text with page breaks
\OuterFrameSep=\skip43
\fb@frw=\dimen105
\fb@frh=\dimen106
\FrameRule=\dimen107
\FrameSep=\dimen108
)
("C:\Program Files\MiKTeX 2.9\tex\latex\base\alltt.sty"
Package: alltt 1997/06/16 v2.0g defines alltt environment
)
(C:\Users\eli02\AppData\Roaming\MiKTeX\2.9\tex\latex\upquote\upquote.sty
Package: upquote 2012/04/19 v1.3 upright-quote and grave-accent glyphs in verba
tim
)
(LaTeX.aux (Chapter1.aux))
\openout1 = `LaTeX.aux'.

LaTeX Font Info:    Checking defaults for OML/cmm/m/it on input line 56.
LaTeX Font Info:    ... okay on input line 56.
LaTeX Font Info:    Checking defaults for T1/cmr/m/n on input line 56.
LaTeX Font Info:    ... okay on input line 56.
LaTeX Font Info:    Checking defaults for OT1/cmr/m/n on input line 56.
LaTeX Font Info:    ... okay on input line 56.
LaTeX Font Info:    Checking defaults for OMS/cmsy/m/n on input line 56.
LaTeX Font Info:    ... okay on input line 56.
LaTeX Font Info:    Checking defaults for OMX/cmex/m/n on input line 56.
LaTeX Font Info:    ... okay on input line 56.
LaTeX Font Info:    Checking defaults for U/cmr/m/n on input line 56.
LaTeX Font Info:    ... okay on input line 56.

(C:\Users\eli02\AppData\Roaming\MiKTeX\2.9\tex\context\base\supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
\scratchcounter=\count88
\scratchdimen=\dimen109
\scratchbox=\box26
\nofMPsegments=\count89
\nofMParguments=\count90
\everyMPshowfont=\toks15
\MPscratchCnt=\count91
\MPscratchDim=\dimen110
\MPnumerator=\count92
\makeMPintoPDFobject=\count93
\everyMPtoPDFconversion=\toks16
) ("C:\Program Files\MiKTeX 2.9\tex\latex\oberdiek\epstopdf-base.sty"
Package: epstopdf-base 2016/05/15 v2.6 Base part for package epstopdf

("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\infwarerr.sty"
Package: infwarerr 2016/05/16 v1.4 Providing info/warning/error messages (HO)
)
("C:\Program Files\MiKTeX 2.9\tex\latex\oberdiek\grfext.sty"
Package: grfext 2016/05/16 v1.2 Manage graphics extensions (HO)

("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\kvdefinekeys.sty"
Package: kvdefinekeys 2016/05/16 v1.4 Define keys (HO)

("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\ltxcmds.sty"
Package: ltxcmds 2016/05/16 v1.23 LaTeX kernel commands for general use (HO)
)))
("C:\Program Files\MiKTeX 2.9\tex\latex\oberdiek\kvoptions.sty"
Package: kvoptions 2016/05/16 v3.12 Key value format for package options (HO)

("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\kvsetkeys.sty"
Package: kvsetkeys 2016/05/16 v1.17 Key value parser (HO)

("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\etexcmds.sty"
Package: etexcmds 2016/05/16 v1.6 Avoid name clashes with e-TeX commands (HO)

("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\ifluatex.sty"
Package: ifluatex 2016/05/16 v1.4 Provides the ifluatex switch (HO)
Package ifluatex Info: LuaTeX not detected.
)
Package etexcmds Info: Could not find \expanded.
(etexcmds)             That can mean that you are not using pdfTeX 1.50 or
(etexcmds)             that some package has redefined \expanded.
(etexcmds)             In the latter case, load this package earlier.
)))
("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\pdftexcmds.sty"
Package: pdftexcmds 2018/01/21 v0.26 Utility functions of pdfTeX for LuaTeX (HO
)

("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\ifpdf.sty"
Package: ifpdf 2017/03/15 v3.2 Provides the ifpdf switch
)
Package pdftexcmds Info: LuaTeX not detected.
Package pdftexcmds Info: \pdf@primitive is available.
Package pdftexcmds Info: \pdf@ifprimitive is available.
Package pdftexcmds Info: \pdfdraftmode found.
)
Package epstopdf-base Info: Redefining graphics rule for `.eps' on input line 4
38.
Package grfext Info: Graphics extension search list:
(grfext)             [.pdf,.png,.jpg,.mps,.jpeg,.jbig2,.jb2,.PDF,.PNG,.JPG,.JPE
G,.JBIG2,.JB2,.eps]
(grfext)             \AppendGraphicsExtensions on input line 456.
)
\openout2 = `Chapter1.aux'.

 (Chapter1.tex
! Undefined control sequence.
l.1 \hypertarget
                {my-first-chapter}{%
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

[1{C:/Users/eli02/AppData/Local/MiKTeX/2.9/pdftex/config/pdftex.map}


] [2

]
Chapter 1.
LaTeX Font Info:    Try loading font information for OMS+cmtt on input line 6.
LaTeX Font Info:    No file OMScmtt.fd. on input line 6.

LaTeX Font Warning: Font shape `OMS/cmtt/m/n' undefined
(Font)              using `OMS/cmsy/m/n' instead
(Font)              for symbol `textbraceleft' on input line 6.

) [3] [4

] (LaTeX.aux (Chapter1.aux))

LaTeX Font Warning: Some font shapes were not available, defaults substituted.

 ) 
Here is how much of TeX's memory you used:
 1597 strings out of 493305
 23624 string characters out of 3138874
 77885 words of memory out of 3000000
 5143 multiletter control sequences out of 15000+200000
 5074 words of font info for 19 fonts, out of 3000000 for 9000
 1141 hyphenation exceptions out of 8191
 41i,5n,25p,274b,151s stack positions out of 5000i,500n,10000p,200000b,50000s
<C:/Program Files/MiKTeX 2.9/fonts/type1/public/amsfonts/cm/cmbx12.pfb><C:/Pr
ogram Files/MiKTeX 2.9/fonts/type1/public/amsfonts/cm/cmr10.pfb><C:/Program Fil
es/MiKTeX 2.9/fonts/type1/public/amsfonts/cm/cmsl10.pfb><C:/Program Files/MiKTe
X 2.9/fonts/type1/public/amsfonts/cm/cmsy10.pfb><C:/Program Files/MiKTeX 2.9/fo
nts/type1/public/amsfonts/cm/cmtt10.pfb>
Output written on LaTeX.pdf (4 pages, 59242 bytes).
PDF statistics:
 35 PDF objects out of 1000 (max. 8388607)
 0 named destinations out of 1000 (max. 500000)
 1 words of extra memory for PDF output out of 10000 (max. 10000000)

我想补充一点,日志行的说法Package ifluatex Info: LuaTeX not detected.让我感到困惑,因为当我进入luatex --versionPowershell 时,我得到了这个:

This is LuaTeX, Version 1.07.0 (MiKTeX 2.9.6630 64-bit)

Execute  'luatex --credits'  for credits and version details.

There is NO warranty. Redistribution of this software is covered by
the terms of the GNU General Public License, version 2 or (at your option)
any later version. For more information about these matters, see the file
named COPYING and the LuaTeX source.

LuaTeX is Copyright 2018 Taco Hoekwater and the LuaTeX Team.

感谢您的时间。

更新

  1. 我似乎在更改为pandoc Chapter1.Rmd --chapters方面取得了一些成功pandoc Chapter1.Rmd --top-level-division=chapter。在 Powershell 中运行该行pandoc Chapter1.Rmd --top-level-division=chapter -f markdown -t latex -o Chapter1.tex可以成功创建Chapter1.tex,但编译 RNW 文件却不会。

相关内容