4

Here's my mwe: enter image description here

I keep getting the following error: enter image description here

How can I write Korean in LaTeX? Also, I tried compiling with both XeLaTeX and LuaLaTeX but I still get the same errors. Please help and thank you.

3
  • 3
    that is a warning not an error. Simply remove the line with inputenc to get rid of it. And don't show code as screenshot. Copy it into the question so that other can copy&paste and test it. Commented Oct 29, 2022 at 8:23
  • Thank you very much. I appreciate your help and I'll input my code next time. Sorry. Commented Oct 29, 2022 at 8:40
  • Is there a way to make it a sans serif type of font? Commented Oct 29, 2022 at 8:52

2 Answers 2

7

You don’t need both babel and polyglossia. Here is a document with babel, with english as the main language and korean as the secondary one, using different fonts (with luatex):

\documentclass{article}

\usepackage[english]{babel}
\babelprovide[import, onchar=ids fonts]{korean}

\babelfont{rm}{FreeSerif}
\babelfont[korean]{rm}{Un Batang}

\begin{document}

English text. 한국어는 어근과 접사 등 특정 표지가
붙음에 따라 단어의 기능이 결정되는 교착어로 분류된다.
More English text.

\end{document}

enter image description here

Line breaking is by default character based, but this can be changed. In my tests, kotex seems to be compatible with babel.

4

You asked,

How can I write Korean in LaTeX?

As long as you have suitable OpenType fonts at hand and know how to load the fontspec package -- either directly or indirectly (via, say, the polyglossia package) -- and know how to execute \setmainfont and \setsansfont directives, there's really nothing special to do in order to write Korean in LaTeX.

If the polyglossia package is loaded, one could use \textkorean to apply Korean-specific typographic rules to short strings. E.g., compare the outputs of \today and \textkorean{\today} in the screenshot shown below. (Writing \textkorean{Hello World} does nothing special, i.e., it outputs "Hello World".) One would employ \begin{korean} and \end{korean} mainly to typeset longer passages, e.g., one or more paragraphs of text, in a way that implements Korean-specific formatting rules.

By "suitable" OpenType fonts, I mean a font that provides both Latin glyphs and Korean glyphs. Noto Serif KR and Noto Sans KR satisfy this condition.

enter image description here

% !TEX TS-program = lualatex
\documentclass{article}

\usepackage{polyglossia}
\setdefaultlanguage{english}
\setotherlanguage{korean}

%% Next, load suitable Opentype fonts, e.g., Noto Serif/Sans KR.
\usepackage{iftex}
\ifluatex
   \setmainfont{Noto Serif KR}
   \setsansfont{Noto Sans  KR}[Scale=MatchUppercase]
\else\ifxetex 
   \defaultfontfeatures{Path=/Users/mico/Library/Fonts/} % set as needed
   \setmainfont{NotoSerifKR-Regular}[BoldFont=NotoSerifKR-Bold]
   \setsansfont{NotoSansKR-Regular}[BoldFont=NotoSansKR-Bold,
                                    Scale=MatchUppercase]
\fi\fi

\begin{document}
Hello World. 헬로월드 

\textbf{Hello World. 헬로월드} 

\textsf{Hello World. 헬로월드} 

\textbf{\textsf{Hello World. 헬로월드}}

\today\ vs.\ \textkorean{\today}.
\end{document}
5
  • Thank you so much. I copied and pasted your code but I keep getting multiple errors regarding it cannot find NotoSerifKRRegular and NotoSansKRRegular. I just have to make sure my compiler is either LuaLaTeX or XeLaTeX right? Commented Oct 29, 2022 at 9:26
  • @cantor'ssloth - Yes, in order to load the polyglossia package, you must compile the document with either XeLaTeX or LuaLaTeX. How to organize the arguments of \setmainfont and \setsansfont under XeLaTeX can (and often does) depend significantly on the operating system that's in use. I happen to use MacOS 12.6.1 "Monterey", and fonts supplied by Google -- such as the Noto Serif and Noto Sans font families -- happen to have been installed in /Users/mico/Library/Fonts/. Try the LuaLaTeX approach first on your system, as LuaLaTeX is a bit more relaxed about how fonts can be loaded.
    – Mico
    Commented Oct 29, 2022 at 9:34
  • Ok, I use Windows11 and neither one of the compilers is working. I keep getting the same errors. Does Windows11 require a workaround? Commented Oct 29, 2022 at 9:38
  • @cantor'ssloth - Sorry, but I don't do Windows. By the way, have you checked that the Noto Serif KR and Noto Sans KR fonts are installed on your computer? (If they're not, that would explain why your system can't find NotoSerifKRRegular and NotoSansKRRegular.) You may download the Noto Serif/Sans KR fonts for free from Google. After downloading and installing the two font families, be sure to activate them as appropriate for Windows 11.
    – Mico
    Commented Oct 29, 2022 at 10:09
  • 2
    @cantor'ssloth you can install noto fonts for windows but you can use any font you use in a browser or Word processor, you do not have to use noto fonts Commented Oct 29, 2022 at 10:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .