I've tried following the instructions provided by Joel exactly, except that I'm using the bash terminal rather than Rstudio to create my output files. My system is Ubuntu 14.04. I get the following error:
"pandoc: Error running filter ./pandoc-word-pagebreak
./pandoc-word-pagebreak not found in path "
Where should the result of "
$ghc --make -v pandoc-word-newpage.hs"
be stored? I've put all the resulting files in $HOME/.cabal/bin and added this to my path, but this didn't work.
Command to create the output file:
"pandoc -S -o output.odt --filter pandoc-citeproc --filter ./pandoc-word-pagebreak
input.md --reference-odt=template.odt "
Thanks for any advice you may have. I certainly am very unfamiliar with haskell and properly using custom pandoc filters.
On Wednesday, April 22, 2015 at 12:59:38 PM UTC-4,
hjal...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:
Thanks John!
Note that I had to double up on the backslashes before newpage as in:
insertPgBrks (Para [RawInline (Format "tex") "\\newpage"]) = pgBrkBlock
For a complete summary, here is the system set up, filter and steps I am using to manage page breaks.
System:
RHEL 6.6
ghc 7.8.3
Pandoc 1.13.2.1
R 3.1.3
RStudio 0.98.1028
Filter code:
import Text.Pandoc.JSON
pgBrkXml :: String
pgBrkXml = "<w:p><w:r><w:br w:type=\"page\"/></w:r></w:p>"
pgBrkBlock :: Block
pgBrkBlock = RawBlock (Format "openxml") pgBrkXml
insertPgBrks :: Block -> Block
insertPgBrks (Para [RawInline (Format "tex") "\\newpage"]) = pgBrkBlock
--insertPgBrks (RawBlock (Format "tex") "\newpage") = pgBrkBlock
insertPgBrks blk = blk
main = toJSONFilter insertPgBrks
compile the filter
$ghc --make -v pandoc-word-newpage.hs
.Rmd file
---
title: "Test Doc"
author: "Joel Allen"
date: "04/16/2015"
output:
word_document:
pandoc_args:
- --filter
- pandoc-word-newpage
---
\newpage
Test Page 1
\newpage
Test Page 2
I then knit to word, pdf, or html in Rstudio. Word and pdf now put pagebreaks in the same place.
Thanks to all for the advice!
Joel