Comments (7)
---
title: "Untitled"
output:
officedown::rdocx_document:
default
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
# Chapter1 {#ch1}
# Chapter2 {#ch2}
Refer to \@ref(ch1).
When \@ref(ch1) is surrounded by multibyte strings (e.g., Chinese characters), it would possibly encounter errors.
- Pure multibyte + ref: 上下\@ref(ch1)
- Example: 上a下\@ref(ch1)
- ref + multibyte: \@ref(ch1)。
Your issue is related to the fact you are not working with a UTF-8 encoded file.
R, R Markdown and Windows does not work well when encoding is not UTF-8.
from officedown.
Hi @madlogos,
I am aslo a Chinese user. The multibyte problem has also bothered me for a long time. Here is my trick for it:
- Write
@ref
as usual; - Save the Rmd file and
readr::read_lines
it; - Match the strings containing
"\\\\@ref\\([^\\)]+\\)"
pattern; - Split it and make sure the
"\\\\@ref\\([^\\)]+\\)"
on a single line; - Save the character vector to a new Rmd file and render it with the format you like. Done!
For example, 请参考表\@ref(tab: coco)中的数据
should be splited as
[line 1] 请参考表
[line 2] \@ref(tab: coco)
[line 3] 中的数据
Well, I am not sure if this is an effective solution but it works for me. 😄
from officedown.
Yes, @davidgohel, you are right. Althougth the .Rmd file is in UTF-8, the OS is running on GBK encoding. When I change to bookdown::word_document2
, the knitr engine manages to compile the file. But I still get ?? where the bookmark is supposed to appear.
from officedown.
You don't need to try new output format functions.
The result shown below is made with a Windows with french locale. But I made sure the file was encoded as UTF-8 (I am using readr::guess_encoding()
, if not UTF-8 encoded, I can change it to UTF8 with fpeek::peek_iconv()
).
Could you show the result of
readr::guess_encoding("your/rmd/file")
from officedown.
The results are
no | encoding | confidence |
---|---|---|
1 | UTF-8 | 1 |
2 | windows-1252 | 0.28 |
from officedown.
@bishun945 thank you for the turn-around. Good stuff.
from officedown.
@madlogos I have tried another solution: just switch your system and MS Word language to English.
from officedown.
Related Issues (20)
- Math font in rdocx_document HOT 1
- Add image to word doc header without using reference docx
- Error when using `knit_print_block` in loop HOT 6
- Header Problems concomitant with page numbering HOT 6
- Support {.unlisted .unnumbered} to exclude headings from table of contents HOT 2
- table caption style in yaml not used HOT 4
- insert section with page_margins, header and footer
- How to split long flextable in officedown powerpoint rmarkdown HOT 1
- landscape? HOT 1
- block_caption() in markdown corrups Word files HOT 5
- In-consistencies with the officeverse bookdown HOT 1
- layout='Content with Caption' not working HOT 2
- Header and footer from reference_docx not working with orientation switches.
- accessing different parts of word doc HOT 3
- how to add page numbers, title page and sections in word using officedown HOT 1
- Extra section break is created after MULTCOLUM stop HOT 5
- Option to output Word doc with line numbering HOT 5
- dml bg is always "white" in R Markdown HOT 2
- `block_pour_docx` but only for part of file to be poured
- Images in page headers of reference docx misplaced when using <!---BLOCK_LANDSCAPE_START---> <!---BLOCK_LANDSCAPE_STOP---> HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from officedown.