The following compiles without errors using xelatex on TeX Live 2020:
\documentclass[twoside]{book}
\tracinglostchars=2
\usepackage{xeCJK}
\defaultfontfeatures{Scale = MatchLowercase, Ligatures = TeX}
\setmainfont{Noto Sans}[Scale = 1.0]
\setmonofont{Noto Sans Mono}
%% The Noto Korean fonts can be downloaded from:
%% https://www.google.com/get/noto/help/cjk/
\setCJKmainfont{Noto Sans CJK KR}[Script=Hangul, Language=Korean]
\setCJKmonofont{Noto Sans Mono CJK KR}[Script=Hangul, Language=Korean]
\begin{document}
\obeylines
00027 printf({"{}JUST A PRINT STATEMENT\(\backslash\)n"{}});
00027 printf({"{}Just a print statement\(\backslash\)n"{}});
00028 printf({"large 다음에 의해 생성됨 Doxygen 1.8.19\(\backslash\)n"{}});
\begin{verbatim}
00027 printf({"{}JUST A PRINT STATEMENT SOME MORE TEXT SOME MORE TEXT\(\backslash\)n"{}});
00027 printf({"{}Just a print statement some more text some more text\(\backslash\)n"{}});
00028 printf({"large 다음에 의해 생성됨 Doxygen 1.8.19\(\backslash\)n"{}});
\end{verbatim}
\end{document}
You must first download the fonts you need, such as Noto Sans CJK KR. On Windows or Mac, make sure you install them as system fonts, and not just for yourself.
They are not distributed through CTAN, but you can put the files in any of the following places:
- Install them as system fonts. On Windows or Mac, make sure to install them for all users, so XeTeX can find them.
- Some Linux distributions package them and keep them updated. On Debian or Ubuntu, they are in the
apt package fonts-noto-cjk.
- Copy them to a local TEXMF tree. With MikTeX, you would set the environment variable
TEXINPUTS= to this local directory.
- Download them to a local folder and select them with
Path=, e.g. \setCJKmonofont{NotoSansMonoCJKkr}[Path = ./customfonts , UprightFont = *-Regular , BoldFont = *-Bold , Extension = .otf] (If this is the version you downloaded.) This will break if you try to compile the document on another computer with a different version of the fonts. On the other hand, it’s the only way to be certain that you’re archiving the exact same version of the fonts, with the exact same output.
- Put the files, or symbolic links to them, in your project directory along with your
.tex files and change to that directory to compile them.
- On Linux, you can copy fonts to a subdirectory of
/usr/local/share/fonts/ to install them for everyone, or ~/.fonts/ to install them for yourself.
The reason only the Simplified Chinese fonts were working for you is that there is a CTAN package to install those.
\setmonofont{Noto Sans Mono CJK KR}.Noto Sans Mono CJK KR. Why are you using xeCJK? Use fontspec instead, if you don't need it.\setCJKmonofont{Noto Sans Mono CJK KR}. You might also wish to set some additional features such asScript=andLanguage=.