3 論文撰寫

3.1 檔案結構

執行以下指令後(詳見 ??

ntuthesis::import_template("project_name")

即會匯入論文模板。以下是論文模板的檔案結構(已簡化):

├── project_name.Rmd     # Useless, please delete it
|
├── R/                   # code chunk root dir, put R scripts and data here
├── figs/                # Put figures to include in the thesis here
|
├── index.Rmd            # Book Layout (font, watermark, biblio, ...)
├── _acknowledge.Rmd     # acknowledgement
├── _abstract-en.Rmd     # abstract
├── _abstract-zh.Rmd     # Same as above, but in Chinese
|
├── 01-intro.Rmd         # Chapter 1 content
├── 02-literature.Rmd    # Chapter 2 content
├── 03-method.Rmd        # Chapter 3 content
├── 80-appx-help.Rmd     # Appendix Content
├── 99-references.Rmd    # Edit "References" Title
├── ref.bib              # References
├── cite-style.csl       # Citation style
|
├── _bookdown.yml        # label names in gitbook; Rmd files order
├── _output.yml          # preamble, pandoc args, cite-pkg
|
├── watermark.pdf        # 臺大浮水印 (PDF 右上角)
├── _person-info.yml      # Info to generate front matter
├── certification-scan.pdf  # 已簽名'口試委員審查書'
└── front_matter
    └── certification.pdf   # 空白'口試委員審查書'

3.2 index.Rmd

index.Rmd 是設定論文內文格式的地方,包含 yaml 以及 R setup code chunk。此模板將 code chunk 預設的 working directory 改成 R/4,如此較符合一般寫 Rscript 的邏輯5。若要更改此設定,至 setup code chunk 更改 knitr::opts_knit$set(root.dir='R')

3.3 撰寫語言

若使用英文撰寫論文,需修改 _output.yml_bookdown.yml 這兩個檔案的內容。

3.3.1 _output.yml

in_header: latex/preamble-zh.tex 改為 in_header: latex/preamble-en.tex

bookdown::pdf_book:
  includes:
    in_header: latex/preamble-en.tex

3.3.2 _bookdown.yml

_bookdown.yml 中,可以對標籤的名稱進行定義。這裡的設定與 PDF 輸出無關,只與 gitbook 輸出格式有關。因此,若無需使用 gitbook 輸出,可忽略此段。

此外,_bookdown.yml 亦可設定 Rmd 檔在輸出文件中的順序。若無設定,就會依序檔名排序6

在以下設定中,可使 gitbook 輸出的章節(順序)與 PDF 不同。

rmd_files:
  html: ["index.Rmd", "abstract.Rmd", "intro.Rmd"]
  latex: ["abstract.Rmd", "intro.Rmd"]