pandoc

从 Word 到 Docbook, 最后用 Pandoc, 让程序员爱上写文档

妖精的绣舞 提交于 2019-12-03 03:32:25
写文档一直是程序员非常讨厌的工作, 甚至和改需求一样令人厌烦. 在程序员眼里比写程序还难, 即便强制执行下来文档质量也很难让人满意. 相信大多数公司写文档都是用 Word, 笔者也是用了 Word 写了好几个项目的文档. 架构, 设计, 运维等好几份, 呵呵, 即便是写的再好, 交给客户也基本是不看的. 一个文档是项目组内好几个成员编写的, 大家各写各的模块, 各自的实现, 然后一起合并, 合并时修改字体, 字号, 目录等, 第一次合并还好, 再升级几个版本后, 大家改了哪里, 没改哪里, 根本看不出来. 于是我就开始找一些文档工具. 个人一直看 Spring 的项目文档, Pdf 格式和在线 Html 格式都写的非常漂亮. 相信大家都很熟悉. 如下: 于是锁定了 Docbook 这个文档工具. Docbook 是支持 Maven 的, 在 pom 的 plugins 中加上支持 Docbook 的 plugin. ''' <plugin> <groupId>org.jboss.maven.plugins</groupId> <artifactId>maven-jdocbook-plugin</artifactId> <version>2.3.8</version> <extensions>true</extensions> <dependencies> <dependency>

How to suppress automatic figure numbering in Rmarkdown / pandoc

主宰稳场 提交于 2019-12-03 03:25:59
I have the following Rmarkdown (.Rmd) document where I call existing .png images and create a .pdf with captions. By default, pandoc? is automatically adding "Figure #." before the caption for each picture. I can see how this would be the normal thing to do, but in my case I would like to define this. I have found variations on this topic but don't seem to find a solution. Below is an example of how my .Rmd file looks: --- title: "TITLE" author: "ME" date: "`r Sys.Date()`" output: pdf_document --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE) ``` ![Caption for figure 1]

pandoc not converting latex style citations correctly

倖福魔咒の 提交于 2019-12-03 03:24:21
I want to use latex-style citations \cite{key} in my markdown so that I can create tex and pdf documents nicely using pandoc. However, when I cite something, it shows the keyword in brackets instead of the citation style, such as author name or citation number. In other words, I want it to show up in the PDF as "This is my citation [1]" but instead it is appearing as "This is my citation [mykey]". Also, my references list isn't showing up after I add my # References header. What is going on here? Below is my sample command for producing this along with the sample files and my current incorrect

Plots in beamer slides converted from .md by pandoc are extremely large

流过昼夜 提交于 2019-12-03 01:13:24
Normal plots generated by R chunks in R markdown files are exactly there when converted to html slides or pdf. However, when they are converted to beamer slides by pandoc -t beamer ex.md -V theme:Warsaw -o beamer.pdf , the plots become extremely large, especially for those generated by par(mfrow=c(n,m)) , in which case only a little part of the plot is displayed. I tried to fix by setting the chunk option dev='pdf' , but it doesn't work out. The plot in html is The plot in beamer is The development version of pandoc includes some code in the beamer template that should scale images to the

Poor resolution in knitr using Rmd

可紊 提交于 2019-12-03 01:11:08
I have a .Rmd file and I am trying to create a .docx file via the function pandoc. I want to have a figure with final resolution of 504x504 pixels (i.e., 7x7inch with 72dpi). Unfortunately, the default 72 dpi is too poor in quality, and I would like to increase it to, say, 150 dpi without altering the final resolution (so it will already have the correct size within the .docx file). If I keep options fig.width and fig.height=7 and set dpi=150, I get the quality I want but the final resolution increases and the figure blows outside the .docx margins. I tried playing with the arguments out.width

Relationship between R Markdown, Knitr, Pandoc, and Bookdown

流过昼夜 提交于 2019-12-03 00:24:01
问题 What is the relationship between the functionality of R Markdown, Knitr, Pandoc, and Bookdown? Specifically what is the 'division of labour' between these packages in converting markup documents with embedded R code (e.g. .Rnw or .Rmd ) into final outputs (e.g. .pdf or .html )? And if Knitr is used to process RMarkdown, what does the rmarkdown package do and how is it different to the markdown package ? 回答1: Pandoc Pandoc is a document converter. It can convert from a number of different

pandoc document conversion failed with error 67

假如想象 提交于 2019-12-02 23:33:07
问题 I'm using R 3.3.2 and Rstudio Version 1.0.44, here's the format of my RMarkdown file --- title: "Sentiment Analysis" output: rmdformats::material: highlight: kate --- When I try to knit, I got the following error pandoc: Could not fetch /tabsets.js /tabsets.js: openBinaryFile: does not exist (No such file or directory) Error: pandoc document conversion failed with error 67 In addition: Warning messages: 1: In sink() : no sink to remove 2: In sink() : no sink to remove 3: MathJax doesn't work

Reduce cell width and font size of table using pandoc.table()

安稳与你 提交于 2019-12-02 22:43:06
I'm using knitr and pander to make a table in a markdown file. I'm converting the markdown file to a PDF using Pandoc from within R. This code: library(knitr) ```{r myTable, echo=FALSE, message=FALSE, results='asis', comment=""} library(pander) pandoc.table(head(iris)) ``` then running this function within R: knitsPDF <- function(name) { knit(paste0(name, ".Rmd"), encoding = "utf-8") callformat <-"pandoc -V geometry:margin=1in %s.md -o %s.pdf" system(sprintf(callformat, name, name)) } knitsPDF(name) # insert file name of .Rmd file produces this table in the PDF file: How can I 1. Reduce width

Knitr: R code within LaTeX environment in a Markdown document

二次信任 提交于 2019-12-02 21:07:54
I have a document in Markdown, which incorporates R code via Knitr . For rendering equations I use LaTeX, simply writing its commands in the text. Say I have the following LaTeX code: \begin{displaymath} \mathbf{X} = \begin{bmatrix} 2 & 12\\ 3 & 17\\ 5 & 10\\ 7 & 18\\ 9 & 13\\ \end{bmatrix} \end{displaymath} Which renders me a nice mathematical matrix representation (in square brackets), when I convert everything to PDF (the full workflow is then: RMD -> knitr -> MD -> pandoc -> TeX -> pandoc -> PDF). Now, suppose we want the said matrix to be generated on-the-fly from an R object, some R

Reduce space between code chunks and code output in rmarkdown beamer presentation

泪湿孤枕 提交于 2019-12-02 19:20:39
I'm building a presentation using rmarkdown and LaTeX/Beamer. I would like to reduce the spacing between the displayed R-commands and R-output. I believe this is related to the paragraph spacing options in LaTeX/Beamer. Is this something I should do in rmarkdown (chunk options, knit_hooks, or something else?), in the pandoc Yaml header (some pandoc option?), or in the LaTeX beamer template file? I feel like it should be in the LaTeX template file. Below is a working example of a minimal markdown file, and a .tex template file I'm using to control some beamer settings. example.Rmd --- title: