0

I use a tex template that includes Korean characters. When I compile it, the PDF document displays the Korean characters correctly. Yet, the Texshop text editor displays some rubbish characters instead. And when I actually type the Korean characters, after the compilation the PDF displays "?" instead of the characters. How do I get the formatting right?

3

This is really impossible to answer without seeing a minimal working example (MWE), but I'm pretty sure you're dealing with the following problem:

The .tex file you're compiling loads CJK which assumes the EUC-KR encoding for Korean text. Your text editor, however, automatically loads the file with UTF-8 encoding, as most modern text editors will do.

If the characters were entered into the .tex file with the EUC-KR encoding, you will see question marks � and various outlandish characters if you open the file with UTF-8 encoding. The file will still compile just fine, since CJK correctly reads the EUC-KR encoded characters and produces a .pdf with Korean characters.

If you've opened the file with the UTF-8 encoding and start typing Korean characters into the file, CJK can't interpret the input correctly, since it's expecting characters with the EUC-KR encoding. So pdflatex will probably throw an error, or it will produce a .pdf with garbage characters instead of Korean characters.

Your actual question "How do I get the formatting right?" is very vague, but if this means that you need to stick to your existing template, then make sure you switch the encoding of your file from UTF-8 to EUC-KR before you enter any new Korean characters into the file, and also to be able to read the existing characters in your document.

This is all only guesswork, since it is impossible to know for sure what problem you're having or what's causing it when you're not providing a MWE. Please always do so in the future.

Here's an example. The following document was typed with EUC-KR encoding, but below I've opened it with the standard UTF-8 encoding, and it looks like this:

\documentclass{article}
\usepackage{CJK}
\begin{document}
\begin{CJK}[HL]{KS}{mj}
�ȳ��ϼ���
\end{CJK}
\end{document}

If I compile this, it nevertheless correctly produces this output: enter image description here

If I instead load the file with EUC-KR encoding, I see this:

\documentclass{article}
\usepackage{CJK}
\begin{document}
\begin{CJK}[HL]{KS}{mj}
안녕하세요
\end{CJK}
\end{document}
1

pdflatex

Using this engine, you can still adopt this solution posted by Medina (remember to set babel to English so the Table of Contents, etc, will be in English).

According to this answer, however, you need the uhc font package installed in order to be able to use mj.

xelatex

If you're already using xelatex (or if you can switch for one document), it's easier since you don't need to enclose Korean in its own environment. However you need to choose a font, otherwise the document typesets without errors but you won't see any glyphs (except for the latin ones). Try commenting out the command \setmainfont{} then compiling, and you'll see what I mean.

The package fontspec must be loaded in order for the command above to work. This allows you to set a font. If you load xeCJK, you can also use the command \setCJKmainfont{} to set a font for your language. Here's an example with Nanum Myeongjo Regular:

enter image description here

\documentclass{article}
\usepackage{fontspec}
\usepackage{xeCJK}

\setmainfont{Century Gothic}
\setCJKmainfont{NanumMyeongjo}

\begin{document}

\centering\Huge\noindent
This is some text in Latin script. And now some Korean:
이 FAQ 은 자주 반복되는 질문과 그에 대한 대답을 간단명료한 양식으로 모아 엮어졌습니다.

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.