Quarto Manuscripts를 이용해 학술 논문 작성하기

코드 블록을 포함한 학술 논문을 웹에 발행하고, PDF, docx등 다양한 형식으로 다운받을 수 있는 Quarto Manuscript를 소개합니다.

R
quarto
quarto manuscript
Author
Published

October 18, 2023

개요

지난 9월 R Studio 2023.09.0 버전이 공개되었습니다. 새롭게 추가된 여러 기능 중에서 .qmd 파일을 이용해 학술 논문을 작성하고 웹페이지로 발행할 수 있는 Quarto Manuscript Project를 소개합니다. 본 게시글은 Quarto manuscript 공식 문서를 참고해 작성되었습니다.

Quarto Manuscript 소개

Quarto Manuscript는 .qmd 파일을 통해 학술 논문을 작성할 수 있는 프로젝트로, 다음과 같은 장점을 갖습니다.

  1. 그림, 표, 수식, 인용 정보, 코드 블록 등 학술 논문에 필요한 모든 요소를 포함한 원고를 작성할 수 있습니다.
  2. 작성한 원고를 웹사이트로 발행할 수 있어 공유가 쉽습니다.
  3. 원고를 PDF, docx, 압축 파일 등 다양한 형식으로 손쉽게 다운로드할 수 있습니다.

Quarto Manuscript를 활용해 작성한 학술 논문 예시는 여기에서 확인할 수 있습니다. 이 예시를 참고해 Quarto manuscript 원고를 작성하고 웹사이트로 발행해보겠습니다.

Quarto Manuscript로 학술 논문 작성하기

1. 준비하기

Quarto Manuscript를 사용하기에 앞서 (1) 2023.09 버전 이상의 RStudio와 (2) 1.4 버전 이상의 Quarto를 설치해야 합니다.

2. 원고 작성하기

RStudio에서 New project > New Directory > Quarto Manuscript를 선택해 프로젝트를 생성합니다.

학술 논문 원고는 index.qmd 파일에서 작성합니다. 우선 작성할 논문의 제목, 저자, 키워드, 초록과 같은 정보를 아래 예시와 같이 YAML header에 입력합니다.

index.qmd
# YAML head 작성 예시

---
title: La Palma Earthquakes
author:
  - name: Steve Purves
    orcid: 0000-0002-0760-5497
    corresponding: true
    email: steve@curvenote.com
    roles:
      - Investigation
      - Project administration
      - Software
      - Visualization
    affiliations:
      - Curvenote
  - name: Rowan Cockett
    orcid: 0000-0002-7859-8394
    corresponding: false
    roles: []
    affiliations:
      - Curvenote
keywords:
  - La Palma
  - Earthquakes
abstract: |
  In September 2021, a significant jump in seismic activity on the island of La Palma (Canary Islands, Spain) signaled the start of a volcanic crisis that still continues at the time of writing. Earthquake data is continually collected and published by the Instituto Geográphico Nacional (IGN). ...
plain-language-summary: |
  Earthquake data for the island of La Palma from the September 2021 eruption is found ...
key-points:
  - A web scraping script was developed to pull data from the Instituto Geogràphico Nacional into a machine-readable form for analysis
  - Earthquake events on La Palma are consistent with the presence of both mantle and crustal reservoirs.
date: last-modified
bibliography: references.bib
citation:
  container-title: Earth and Space Science
number-sections: true
---

YAML header 아래에 본문을 작성합니다. 본문은 Quarto markdown 형식으로 작성하며, 기본적인 사용법은 Quarto Markdown Basics 공식 문서 혹은 R markdown 기초를 다루었던 이전 게시글에서 참고할 수 있습니다. 본 게시글에서는 논문 작성에 필요한 몇 가지 기능을 중점적으로 살펴보겠습니다.

2.1. figure 삽입하기

r 코드 블록을 활용해 figure를 삽입할 수 있습니다. 아래 예시와 같이 figure을 생성하는 코드와 함께 figure의 label, caption, alt text, width, height 등을 입력합니다. 본문에는 figure와 캡션만 표시되고 코드는 Article Notebook에서 모아 볼 수 있습니다. 본문에서 @fig-timeline와 같이 @ 기호와 figure의 label을 입력하면 figure을 인용할 수 있습니다.

index.qmd
# figure 작성 예시

# ```{r}
eruptions <- c(1492, 1585, 1646, 1677, 1712, 1949, 1971, 2021)
n_eruptions <- length(eruptions)
# ```

# ```{r}
#| label: fig-timeline
#| fig-cap: Timeline of recent earthquakes on La Palma
#| fig-alt: An event plot of the years of the last 8 eruptions on La Palma.
#| fig-height: 1.5
#| fig-width: 6
par(mar = c(3, 1, 1, 1) + 0.1)
plot(eruptions, rep(0, n_eruptions), 
  pch = "|", axes = FALSE)
axis(1)
box()
# ```

# ```{r}
#| output: false
avg_years_between_eruptions <- mean(diff(eruptions[-n_eruptions]))
avg_years_between_eruptions
#```

2.2. 다른 .qmd 파일에 작성한 plot 삽입하기

Section 3.2.1 에서와 같이 간단한 그림이 아닌, 연구에서 사용된 데이터를 통해 plot을 그리고 이를 본문에 삽입하기 위해서는 디렉토리에 notebooks 폴더를 생성해야 합니다. 생성한 notebooks 폴더 안에 데이터 파일을 넣고 새로운 .qmd 파일을 만들어 plot을 그리는 r 코드 블록을 작성합니다.

이후 index.qmd 파일로 돌아와 아래와 같은 코드를 작성하면 plot이 삽입됩니다.

index.qmd
# explore-earthquakes.qmd 파일에 작성한 fig-spatial-plot 삽입 예시

{{< embed notebooks/explore-earthquakes.qmd#fig-spatial-plot >}}

notebooks 폴더의 .qmd 파일에서 작성한 코드는 마찬가지로 Article Notebook에서 모아 볼 수 있습니다.

2.3. 참고문헌 작성하기

참고문헌은 아래 예시와 같이 references.bib 파일에 BibTeX 형태로 작성합니다. index.qmd 파일의 본문에서 @marrero2019와 같이 @ 기호와 참고문헌의 label을 입력하면 참고문헌을 인용할 수 있습니다.

references.bib
# 참고문헌 작성 예시

@article{marrero2019,
  author = {Marrero, Jos{\' e} and Garc{\' i}a, Alicia and Berrocoso, Manuel and Llinares, {\' A}ngeles and Rodr{\' i}guez-Losada, Antonio and Ortiz, R.},
  journal = {Journal of Applied Volcanology},
  year = {2019},
  month = {7},
  pages = {},
  title = {Strategies for the development of volcanic hazard maps in monogenetic volcanic fields: the example of {La} {Palma} ({Canary} {Islands})},
  volume = {8},
  doi = {10.1186/s13617-019-0085-5},
}

2.4. journal template 적용하기

journal template은 PDF에 적용됩니다. .qmd 파일을 PDF 파일로 내보내려면 tinytex 패키지가 설치되어 있어야 합니다. 아래 코드를 통해 패키지를 설치하겠습니다.

console
# tinytex 설치 후 로드

installed.packages("tinytex")
tinytex::install_tinytex()

library(tinytex)
console
# 패키지 설치 확인(True가 출력되면 성공적으로 설치된 것임)

tinytex:::is_tinytex()

journal format을 추가하기 위해 Quarto Extensions: Journal Articles를 참고해 터미널에 아래 코드를 실행시켜 익스텐션을 설치합니다.

terminal
# acs format 설치 예시

quarto install extension quarto-journals/acs

이후 _quarto.yml 파일의 format:acs-pdf: default를 추가하면 acs format이 적용됩니다.

웹페이지를 발행한 뒤 PDF 파일을 다운로드하면 아래와 같이 journal format이 적용된 것을 확인할 수 있습니다.

(좌) acs format, (우) elsevier format 적용 예시

3. 깃허브 페이지를 통해 웹으로 발행하기

원고를 깃허브 페이지를 통해 웹으로 발행하기 위해 _quarto.yml파일의 project:output-dir: docs 설정을 추가합니다. 이후 index.qmd 파일으로 돌아와 터미널에 quarto render을 입력합니다. 모든 변경사항을 깃허브에 commit 후 push 하면, 원고가 깃허브 페이지를 통해 웹으로 발행됩니다. 깃허브의 해당 레포지토리의 settings > pages에서 웹페이지 링크를 확인할 수 있습니다.

마치며

이번 게시글에서는 새롭게 공개된 Quarto Manuscript를 통해 학술 논문 원고를 작성하고 깃허브 페이지를 통해 웹으로 발행하는 방법을 알아보았습니다. Quarto Manuscript를 통해 논문 작성과 공유가 더욱 편리하게 이루어지기를 기대하며 글을 마칩니다.

Reuse

Citation

BibTeX citation:
@online{han2023,
  author = {Han, Jihee},
  title = {Quarto {Manuscripts를} {이용해} {학술} {논문} {작성하기}},
  date = {2023-10-18},
  url = {https://blog.zarathu.com/posts/2023-10-19-quarto-manuscript},
  langid = {en}
}
For attribution, please cite this work as:
Han, Jihee. 2023. “Quarto Manuscripts를 이용해 학술 논문 작성하기.” October 18, 2023. https://blog.zarathu.com/posts/2023-10-19-quarto-manuscript.