4

I'm writing a paper in English and need to include a few characters in Korean in the body and title. I've read several other posts and managed to get the Hangul to show up inside the body, but I can't get them to show up inside the title. I am using pdflatex and have all of the necessary fonts installed.

Here's the minimum working example that shows the characters appearing in the body but not in the title on my system:

\documentclass[11pt]{article}

\usepackage[utf8x]{inputenc}
\usepackage[thai,english]{babel}
\addto\extrasthaicjk{\fontencoding{C90}\selectfont}

\makeatletter
\@namedef{[email protected]}{utf8}
\makeatother
\usepackage{CJKutf8}

\newenvironment{Korean}{%
  \CJKfamily{mj}}{}

\title{
  Character does not show up here:
   \begin{CJK}{UTF8}{mj}\begin{Korean}시험\end{Korean}\end{CJK}
}

\begin{document}
\maketitle

It works here  \begin{CJK}{UTF8}{mj}\begin{Korean}시험\end{Korean}\end{CJK}    

\end{document}

I don't see any errors about the title, so I'm stuck on what to do. This is my first time including foreign script characters in a LaTeX, so any help would be much appreciated. Thanks!

2
  • Are you sure you need utf8x? I believe it's simply better to use utf8 (this avoids the disputable [email protected] trick).
    – egreg
    Jul 29, 2014 at 21:24
  • @egreg: The code is from my previous answer. utf8x is needed for Thai language.
    – Leo Liu
    Aug 2, 2014 at 3:36

1 Answer 1

3

In your original document, if you put your \title command after \begin{document} things work. However, if you don't load the inputenc package at all, things also work. I think this is a better solution. I've added the fontenc package to use the T1 encoding for the Latin text and removed the trick that @egreg mentions in his comment.

\documentclass[11pt]{article}

\usepackage[T1]{fontenc}
\usepackage[english]{babel}

\usepackage{CJKutf8}
\newcommand\textkorean[1]{%
  \begin{CJK}{UTF8}{mj}#1\end{CJK}}

\title{
   Character now shows up here:
   \textkorean{시험}
}
\begin{document}
\maketitle

It works here \textkorean{시험}

\end{document}
4
  • Perfect! This solves the problem exactly. I hadn't thought of repositioning the \title due to CJK's preprocessing. Jul 29, 2014 at 21:38
  • @DavidJurgens See my updated answer. This is not the source of the problem.
    – Alan Munn
    Jul 29, 2014 at 21:39
  • 1
    We don't need to load thai option for babel if Thai support is not needed. And the code needs to be clean up.
    – Leo Liu
    Aug 2, 2014 at 3:40
  • Thai was actually needed in my example, as I was using both Thai and Korean for the article. The Thai script worked as expected but the problem was getting Korean script in the title. Aug 8, 2014 at 20:53

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