I was trying to follow this example that shows how to write a separate chapter in RMarkdown and then include it in your main RNW file using \include{}.

However, I have not been able to get pandoc to read the RMD file. It seems that the RNW file compiles without the chunk that calls pandoc to read the RMD file.

The source code is below. The compilation .log file is included at the bottom of this post after the source code. Can anyone see why the RMD file is not being included in the final PDF, and how I can fix it? Are you able to get the original example to work?

My source code

Chapter1.Rmd RMarkdown file:

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

```{r test, echo=FALSE}

LaTeX.Rnw R-noweb aka R-LaTeX file:


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



At least this text should show in the PDF.


I also make sure to setwd() to the directory that contains both LaTeX.Rnw and Chapter1.Rmd before trying to compile.

Compilation log 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
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:\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)
("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
("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.
Package: framed 2011/10/22 v 0.96: framed or shaded text with page breaks
("C:\Program Files\MiKTeX 2.9\tex\latex\base\alltt.sty"
Package: alltt 1997/06/16 v2.0g defines alltt environment
Package: upquote 2012/04/19 v1.3 upright-quote and grave-accent glyphs in verba
(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.

[Loading MPS to PDF converter (version 2006.09.02).]
) ("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
Package grfext Info: Graphics extension search list:
(grfext)             [.pdf,.png,.jpg,.mps,.jpeg,.jbig2,.jb2,.PDF,.PNG,.JPG,.JPE
(grfext)             \AppendGraphicsExtensions on input line 456.
\openout2 = `Chapter1.aux'.

! Undefined control sequence.
l.1 \hypertarget
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.


] [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
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)

I'd like to add that the log line saying Package ifluatex Info: LuaTeX not detected. is confusing to me because when I enter luatex --version into Powershell I get this:

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.

Thank you for your time.


  1. I seem to have had some success changing pandoc Chapter1.Rmd --chapters to pandoc Chapter1.Rmd --top-level-division=chapter. Running the line pandoc Chapter1.Rmd --top-level-division=chapter -f markdown -t latex -o Chapter1.tex in Powershell successfully creates a Chapter1.tex, but compiling the RNW file does not.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.