Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want to write 鋼の錬金術師 (aka "Alchemist of Steel") is latex. I have the CJK package but just a simple copy and paste of the above kanji to gvim does not do the trick. The code I have is

\begin{CJK*}[dnp]{JIS}{min}
Fullmetal Alchemist (鋼の錬金術師 Hagane no Renkinjutsushi, literally "Alchemist of Steel")
\end{CJK*}\end{document}

What I get is the error:

./preface.tex:56: Package CJK Error: Invalid character code.

I may have missed something vital though... Anyone has any idea?

share|improve this question
2  
Because I can view this properly in UTF-8 html, I think the problem is that the input is not in JIS encoding. You probably need {UTF8} instead of {JIS} to get rid of the Package Error (but I have no idea whether or not you need to set up fonts) –  Taco Hoekwater Jul 28 '11 at 11:04
    
If I save that text with euc-jis-2004 (that's Emacs slang for JIS-2004), the output is correct. –  egreg Jul 28 '11 at 11:57
add comment

2 Answers

up vote 13 down vote accepted

It's probably an encoding problem. If I save the example in UTF-8 encoding changing it into

\begin{CJK}{UTF8}{min}
Fullmetal Alchemist (鋼の錬金術師 Hagane no Renkinjutsushi, literally "Alchemist of Steel")
\end{CJK}

I get correct output. Check the encoding used by gvim. However with

\newcommand{\japanesetext}[1]{\begin{CJK}{UTF8}{min}#1\end{CJK}}

in the preamble, typing the phrase as

Fullmetal Alchemist (\japanesetext{鋼の錬金術師} Hagane no Renkinjutsushi,
literally "Alchemist of Steel")

seems more practical.

share|improve this answer
    
Awesome. Many thanks indeed. –  Sardathrion Jul 28 '11 at 12:36
    
CJK* environment ignores the spaces after CJK characters. It is better to use CJK environment here. –  Leo Liu Jan 15 '12 at 12:27
add comment

Inputting Japanese is quite a pain, as far as I know.

Rather than a direct solution using CJK, I suggest, if you can, a way round, using platex:

\documentclass{article}  
\begin{document}  
Fullmetal Alchemist (鋼の錬金術師 Hagane no Renkinjutsushi, literally "Alchemist of Steel")  
\end{document}

and then platex foo.tex followed by dvipdf foo.dvi (or maybe dvipdfmx foo.dvi) if you need pdf output.

However, this might prove problematic if you use packages incompatible with platex.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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