ulyngs / oxforddown

Template for writing an Oxford University thesis in R Markdown; uses the OxThesis LaTeX template and was inspired by thesisdown.

Home Page:https://ulyngs.github.io/oxforddown/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Japanese

kizen777 opened this issue · comments

I would like to use it for my thesis in Japanese, but to output it in Japanese on your template, it was garbled.

I have just started using Rstudio and found your excellent template in RMarkdown and would be happy to modify it to my graduate school of Health and Sports Sciences format for use.

Thanks for flagging this! :)

Can you show me an example of Japanese input, and the garbled output, so I can have a look at what the issue is?

The part before "Why use it?" in the Introduction is now in Japanese as attached.
BTW, Is this the correct way to contact you?

#########################################

options for knitting a single chapter

#########################################

オックスフォード大学で自分の博士論文を書く際に作成したRMark-down用の論文テンプレート、oxforddown [@lyngsOxforddown2019]へようこそ。このテンプレートでは、RMarkdownで書きながら、美しく実績のあるOxThesisLaTeXテンプレートでPDF出力をフォーマットすることができ,かつ,長い間使われてきた美しいOxThesisLaTeXテンプレートでPDF出力をフォーマットすることができます。my own PhD thesis at the University of Oxford.
もしあなたがTeXやLaTeXを使ったことがないのであればR Markdownで論文を書くことで、OxThesisテンプレートへのより良いインターフェイスを提供できることを願っています。さらに重要なことは、R Markdownを使うと、論文の中にコードの塊を埋め込むことができ、コピー&ペーストの手順を避けて、基礎となるデータから直接プロットや表を生成することができるということです。これにより、再現可能な研究を行う習慣が身に付き、研究者としての長期的な利益となり、将来的にあなたの結果を再現したり構築したりしようとする人の助けにもなるのです。

Why use it? {.unnumbered}

-------Error message------
processing file: 00-introduction.Rmd
output file: 00-introduction.knit.md

! Package inputenc Error: Unicode character オ (U+30AA)
(inputenc) not set up for use with LaTeX.

Try other LaTeX engines instead (e.g., xelatex) if you are using pdflatex. See https://bookdown.org/yihui/rmarkdown-cookbook/latex-unicode.html
エラー: LaTeX failed to compile 00-introduction.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See 00-introduction.log for more info.
追加情報: 警告メッセージ:
1: grep("^\s*$", x) で: 入力文字列 1824 はこのロケールでは不適切です
2: grep("^! ", x) で: 入力文字列 1824 はこのロケールでは不適切です
実行が停止されました

Fonts are specified: "MS Mincho" for Japanese and Times "New Roman for Roman" for Europe, US matters.

I just looked into this:

As per this latex stack exchange, one way to write Japanese characters in LaTeX is to

  • use the xelatex LaTeX engine instead of pdflatex (which oxforddown uses by default)
  • add the LaTeX package xeCJK

To do this with oxforddown, adjust the 'output details' section of index.Rmd to the following:

header-includes:
  - \usepackage{xeCJK}
output:
  bookdown::pdf_book:
    latex_engine: xelatex
    citation_pa... (etc.)

Does this work?

before input, Japanese characters got an
Error message:
register() で:
Can't find generic scale_type in package ggplot2 to register S3 method.
yaml::yaml.load(..., eval.expr = TRUE) でエラー:
Parser error: while parsing a block collection at line 152, column 3 did not find expected '-' indicator at line 153, column 3
呼び出し: ... parse_yaml_front_matter -> yaml_load ->
実行が停止されました
When I add #####################

output details

#####################
header-includes:
-\usepackage{xeCJK}
output:
bookdown::pdf_book:
latex_engine: xelatex
citation_package: biblatex

macOS Big Sur 11.5.2, XQuartz 2.8.1(xorg-server 1.20.11)
R version 4.1.3(2022-03-10) -- "One Push-Up"
RStudio 1.4.1717

Can you confirm that you used exactly the same indentation as in my example above? It seems like this is just a parsing error of the YAML header. So, for example, you must put two spaces before " - \usepackage{xeCJK}".

As a starting point, try creating a new, R Markdown file that contains only the following, and knit it:

---
header-includes:
  - \usepackage{xeCJK}
output: 
  pdf_document:
    latex_engine: xelatex
---

オックスフォ

Can you confirm that this works?

I did a new RMarkdown with only 4 lines and put two spaces before " -\usepackage{xeCJK} then showed the following;

The following objects are masked from 'package:base':

errorCondition

Error message:

Can't find generic scale_type in package ggplot2 to register S3 method.
|......................................................................| 100%
ordinary text without R code

/Applications/RStudio.app/Contents/MacOS/pandoc/pandoc +RTS -K512m -RTS test_Japanese_character.knit.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output test_Japanese_character.html --lua-filter /Library/Frameworks/R.framework/Versions/4.1/Resources/library/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /Library/Frameworks/R.framework/Versions/4.1/Resources/library/rmarkdown/rmarkdown/lua/latex-div.lua --self-contained --variable bs3=TRUE --standalone --section-divs --template /Library/Frameworks/R.framework/Versions/4.1/Resources/library/rmarkdown/rmd/h/default.html --no-highlight --variable highlightjs=1 --variable theme=bootstrap --mathjax --variable 'mathjax-url=https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' --include-in-header /var/folders/vg/yh8xwzx52dq7dy_mzblw7dl40000gn/T//RtmpGcI3iC/rmarkdown-str28fe35ba391d.html

processing file: test_Japanese_character.Rmd
output file: test_Japanese_character.knit.md

[WARNING] This document format requires a nonempty <title> element.
Defaulting to 'test_Japanese_character.knit' as the title.
To specify a title, use 'title' in metadata or --metadata title="...".

Output created: test_Japanese_character.html

Can you show me the content of the entire R Markdown file you created, and I'll try to reproduce the error?

No, I meant can you confirm that you put only this content in a brand-new R Markdown file in a brand-new project?

---
header-includes:
  - \usepackage{xeCJK}
output: 
  pdf_document:
    latex_engine: xelatex
---

オックスフォ

So forgetting everything about oxforddown for a minute, are you normally able to use Japanese characters in R Markdown documents and output to PDF without any issues?