How to get rmarkdown and knitr to use em-dash with .docx files? - knitr

I am new to using rmarkdown and knitr to produce .docx word documents. The rmarkdown reference guide states that using -- gives an en-dash, and --- gives an em-dash.
If I knit my .Rmd file to HTML then the en-dashes and em-dashes are working correctly, however when knitting to a word document, they remain as -- and ---.
I am using Microsoft Word 2013, and I have checked the autoformatting options are set to replace hyphens with a dash.
Any help would be very much appreciated, thanks!

You need to add a pandoc_args: ["--smart"] to the header: Then it words for DocX format
---
output:
word_document:
pandoc_args: ["--smart"]
---

Related

rMarkdown: compile word docx document with line numbers

I am trying to produce a document with rMarkdown code that will render a word docx document that contains continuous line numbers. This is to facilitate workflow for publication submissions where line numbers are often requested.
I have tried using a style docx document with line numbers that was originally rendered from rMarkdown and subsequently edited to change heading style and line numbers. Heading style does change according to that style document but line numbers are not introduced. Desperate latex package use also didn't work in yaml as below.
---
output:
pdf_document:
citation_package: natbib
keep_tex: yes
fig_caption: yes
latex_engine: pdflatex
word_document:
reference_docx: ele_style.docx
geometry: margin=1in
fontfamily: mathpazo
fontsize: 11pt
mainfont: Times New Roman
linespread: 2
header-includes:
-\usepackage{helvet}
-\usepackage{setspace}
-\doublespacing
-\usepackage{lineno}
-\linenumbers
bibliography: LitRev_Bibli.bib
biblio-style: Zotero/styles/ecology-letters.csl
---
Does anyone know how to render line numbers into word docx from rMarkdown?

HtmlHelp hhc file doesn't show russian characters

I use free pascal's chmcmd command to create chm file from hhp. After converting content goes right, but left pane side (tree) doesn't show russian characters. I tried to set charset at hhc file to cp1251. And saved file in windows 1251 encoding. After that it shows tree in russian right in cool reader but not in xChm. In windows it still doesnt work, only weird symbols. Utf-8 doesn't work at all.
The Microsoft CHM help format is very old and not maintained anymore. It wasn't created with Unicode in mind and various tricks need to be done in order to be able to generate CHM files for certain encodings:
You Windows is setup in the target language of the help file
The content HTML pages must be created using the proper charset

convert stream file of iText PDF not opening MS word

Our project has requirement to generate end report both in PDF and MS-Word Document. We are using iTextSharp to dynamically generate tables and rows in report. Finally we will upload the file to server as PDF and MS-word. Both will be converted to Byte Array/Stream file and saved as PDF and MS-Word Document. In Which,uploaded PDF working as expected, but MS-word getting error and not opening(Attaching the screen shot).
iTextSharp doesn't produce MS Word documents, so this isn't an actual iText question. When I look at your screen shot, I see that you are trying to import a PDF file into Word. Since Word can't interpret PDF syntax, it shows you the syntax of the PDF file:
%PDF-1.4
%âãÏÓ
1 0 obj
<</Type/Font...
I think your question is wrong. You are not using iTextSharp to create a PDF file and an MS Word file. You are using iTextSharp to create a PDF file, and not an MS Word file.
There is no such thing as "Save a PDF as MS Word file" in iTextSharp, and it will be extremely difficult to find another tool that can convert a PDF document to a Word document in an acceptable way. (There are such tools, but the quality is suboptimal for PDFs that weren't made to be converted to another format.)

Put highlighted code in a word document using Apache POI

I'm generating some docx file (using Apache POI) that has a lot of SQL code in it. Because I'd like that code to be colored in a Word document, I'm first generating HTML with styles that does syntax highlighting. Now I can't put that HTML in a Word document. Is that even possible (using POI)?
What I'd like to achieve is SQL code in a docx being colored based on a generated HTML (like exporting SQL code from Notepad++ as HTML and pasting it in a Word document). Any ideas?

How to determine the content of an Office content type of an saved Document?

The documentation of getFileAsyc says it will always be in (.pptx or .docx) in Office Open XML (OOXML)
Since Office 2016 this holds no longer true, if one saves the file in OpenDocument format (*.odt).
How will I get the information about the filetype? The name ends with *.odt, but in Word 2013 the name also ended with *.odt, but was transferred as *.docx
Example:
In following case, the binary filecontent cannot be determined:
Create an empty file in Word
Insert your TaskpaneApp
Safe the file as *.odt to you PC in Word
call getFileAsync(Compressed), and
get no docx but odt-content in Word 2016 with the name .odt
get docx-content in Word 2013 with the name .odt
For Word 2013 I fixed the problem by adding .docx to the provided name. Exactly this fix causes the Problems with Word 2016, where the file is realy a *.odt
The input parameter of the getFileAsync method is precisely the file type you need. And this is independently on which format you saved the file.
Office.js supports 3 file types: compressed (which is docx,pptx, etc), text (plain text) and PDF. ODT is not a file format supported in the getFileAsync Method. Check the article you referred to see what formats are supported in which Office Applications.
hope this clarification helps.