KTUG 한국 텍 사용자 그룹

Menu

KTUG :: Q&A 마당 › 한글Markdown문서로 pdf 생성할 때 kotex 설정하는 방법(Sphinx, ReadtheDocs 환경)

jspaik | 2022.10.05 11:16:28 | 메뉴 건너뛰기 쓰기

[배경설명]

ReadtheDocs for business(Sphinx) 서비스를 사용하는 경우 .rst 또는 .md 파일을 소스로 PDF문서를 자동으로 생성할 수 있습니다. 하지만 한글 부분이 표시되는 않는 문제가 있고 매뉴얼에도 중국어와 일본어에 대한 설정사항만 나와 있습니다.

 

[문제점]

PDF 파일 생성기능을 사용하기 위해 설정파일 conf.py에 매뉴얼에 따라 아래처럼 설정합니다.

(파일경로) \Sphinx_Project\docs\source\conf.py
---
latex_engine = 'xelatex'
latex_use_xindy = False
---

conf.py 파일 저장후 빌드하면 pdf 파일이 만들어지고, 화면왼쪽 메뉴에 pdf 파일을 다운로드 할 수있는 링크가 생깁니다. 하지만 한글부분이 모두 물음표(?)로 표시됩니다.

 

[해결방안]

kotex를 사용하도록 preamble 설정을 추가합니다. 설정하려면 아래 내용을 conf.py 파일에 추가해주시면 됩니다.

latex_elements = {
    'preamble': '\\usepackage{kotex}\n',
}

conf.py 설정한 예시:
파일 맨 아래쪽 'Unicode language settings for Korean' 항목을 참고하세요.

 
# -- General configuration ---------------------------------------------------

 
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
    "myst_parser",
    "sphinx.ext.duration",
    "sphinx.ext.autosectionlabel",
    "sphinx.ext.autodoc",
    "nbsphinx", # MyST-NB
    "sphinx_rtd_theme",
]
 
#
intersphinx_mapping = {'python': ('https://docs.python.org/3', None)}
 
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
 
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = []
 
# -- Options for HTML output -------------------------------------------------
 
# The theme to use for HTML and HTML Help pages.  See the documentation for
# a list of builtin themes.
#
# html_theme = 'furo'
html_theme = 'sphinx_rtd_theme'
# html_theme = 'alabaster'
 
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
 
# Add Unicode language settings for Korean
latex_engine = 'xelatex'
latex_use_xindy = False
latex_elements = {
    'preamble': '\\usepackage{kotex}\n',
}

 

[질문사항]

위의 설정으로 진행하면 기본글꼴인 명조체로 PDF파일이 만들어집니다.
고딕 같은 다른 글꼴을 사용하려면 어떻게 하면 되는지 아시는 분 댓글 부탁드립니다.

감사합니다

댓글 [4]

댓글 쓰기

목록 삭제

KTUG 한국 텍 사용자 그룹