3

I have just started using latex and I am trying to display Japanese characters on a beamer presentation. I use Miktex on a Windows 7 OS. I have tried every possible example file and tutorial that I found using xelatex of pdflatex, installed all sorts of packages to enable Japanese support and downloaded dozens of japanese fonts. After hours of bug-fixing, I always end up with obscure errors leading to unanswered posts on forgotten threads... In my most successful attempt, I used xelatex with this file ->

\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage{CJKutf8}
\begin{document}

\begin{CJK}{UTF8}{min}abc 因子の部屋\end{CJK}
\end{document}

This file doesn't give me error messages, but the output on the pdf file is just "abc" (the japanese is not displayed). I also get this warning:

LaTeX Font Warning: Font shape `OT1/cmss/m/n' in size <4> not available
(Font) size <5> substituted on input line 8.

And nothing else that looks like an error. As I said before, I failed all other foolproof methods/tutorials found here an there on the web (I even crashed my whole PC just by updating a Miktex package), so please be patient with me... Thank you!

EDIT: I don't think this is a duplicate because I tried all that was written in the "duplicate" question and a dozen others before I posted mine, and it did not solve the problem. For the liked "duplicate" example, I got this error message:

Font shape `C70/min/m/n' undefined

Which is apparently because Miktex for windows 7 lacks some font files for ms mincho that I already downloaded and are still not recognized.

2

This code should work, using TeXworks editor.

% !TeX program = XeLaTeX
% !TeX encoding = UTF-8
\documentclass{beamer}
\usepackage{xeCJK}
\setCJKmainfont{MS Gothic}
\listfiles
\begin{document}

\begin{frame}{テスト Test}
日本語 English
\end{frame}

\end{document}

enter image description here

Note that I use \listfiles command to list all the files included, with file dates and versions. You can check the list produced by your computer, compare it with my list below, to see whether you are using out-of-date expl3 or fontspec packages.

 *File List*
  beamer.cls    2013/04/04 3.31 A class for typesetting presentations (rcs-revi
sion dca7db0ccda1)
beamerbasercs.sty    2013/10/18 (rcs-revision 0925de4405ff)
beamerbasemodes.sty    2013/09/03 (rcs-revision 768f2d98ca64)
beamerbasedecode.sty    2010/05/01 (rcs-revision efa082c6111d)
   ifpdf.sty    2011/01/30 v2.3 Provides the ifpdf switch (HO)
beamerbaseoptions.sty    2013/03/10 (rcs-revision 47431932db0d)
  keyval.sty    1999/03/16 v1.13 key=value parser (DPC)
geometry.sty    2010/09/12 v5.6 Page Geometry
  ifvtex.sty    2010/03/01 v1.5 Detect VTeX and its facilities (HO)
 ifxetex.sty    2010/09/12 v0.6 Provides ifxetex conditional
  size11.clo    2007/10/19 v1.4h Standard LaTeX file (size option)
 pgfcore.sty    2010/04/11 v2.10 (rcs-revision 1.7)
graphicx.sty    1999/02/16 v1.0f Enhanced LaTeX Graphics (DPC,SPQR)
graphics.sty    2009/02/05 v1.0o Standard LaTeX Graphics (DPC,SPQR)
    trig.sty    1999/03/16 v1.09 sin cos tan (DPC)
graphics.cfg    2010/04/23 v1.9 graphics configuration of TeX Live
   xetex.def    2013/04/29 v0.96 LaTeX color/graphics driver for XeTeX (RRM/JK)

  pgfsys.sty    2010/06/30 v2.10 (rcs-revision 1.37)
  pgfrcs.sty    2010/10/25 v2.10 (rcs-revision 1.24)
everyshi.sty    2001/05/15 v3.00 EveryShipout Package (MS)
  pgfrcs.code.tex
  pgfsys.code.tex
pgfsyssoftpath.code.tex    2008/07/18  (rcs-revision 1.7)
pgfsysprotocol.code.tex    2006/10/16  (rcs-revision 1.4)
  xcolor.sty    2007/01/21 v2.11 LaTeX color extensions (UK)
   color.cfg    2007/01/18 v1.5 color configuration of teTeX/TeXLive
 pgfcore.code.tex
 xxcolor.sty    2003/10/24 ver 0.1
hyperref.sty    2012/11/06 v6.83m Hypertext links for LaTeX
hobsub-hyperref.sty    2012/05/28 v1.13 Bundle oberdiek, subset hyperref (HO)
hobsub-generic.sty    2012/05/28 v1.13 Bundle oberdiek, subset generic (HO)
  hobsub.sty    2012/05/28 v1.13 Construct package bundles (HO)
infwarerr.sty    2010/04/08 v1.3 Providing info/warning/error messages (HO)
 ltxcmds.sty    2011/11/09 v1.22 LaTeX kernel commands for general use (HO)
ifluatex.sty    2010/03/01 v1.3 Provides the ifluatex switch (HO)
 intcalc.sty    2007/09/27 v1.1 Expandable calculations with integers (HO)
etexcmds.sty    2011/02/16 v1.5 Avoid name clashes with e-TeX commands (HO)
kvsetkeys.sty    2012/04/25 v1.16 Key value parser (HO)
kvdefinekeys.sty    2011/04/07 v1.3 Define keys (HO)
pdftexcmds.sty    2011/11/29 v0.20 Utility functions of pdfTeX for LuaTeX (HO)
pdfescape.sty    2011/11/25 v1.13 Implements pdfTeX's escape features (HO)
bigintcalc.sty    2012/04/08 v1.3 Expandable calculations on big integers (HO)
  bitset.sty    2011/01/30 v1.1 Handle bit-vector datatype (HO)
uniquecounter.sty    2011/01/30 v1.2 Provide unlimited unique counter (HO)
letltxmacro.sty    2010/09/02 v1.4 Let assignment for LaTeX macros (HO)
 hopatch.sty    2012/05/28 v1.2 Wrapper for package hooks (HO)
xcolor-patch.sty    2011/01/30 xcolor patch
atveryend.sty    2011/06/30 v1.8 Hooks at the very end of document (HO)
atbegshi.sty    2011/10/05 v1.16 At begin shipout hook (HO)
refcount.sty    2011/10/16 v3.4 Data extraction from label references (HO)
 hycolor.sty    2011/01/30 v1.7 Color options for hyperref/bookmark (HO)
 auxhook.sty    2011/03/04 v1.3 Hooks for auxiliary files (HO)
kvoptions.sty    2011/06/30 v3.11 Key value format for package options (HO)
  pd1enc.def    2012/11/06 v6.83m Hyperref: PDFDocEncoding definition (HO)
hyperref.cfg    2002/06/06 v1.2 hyperref configuration of TeXLive
     url.sty    2006/04/12  ver 3.3  Verb mode for urls, etc.
  hxetex.def    2012/11/06 v6.83m Hyperref driver for XeTeX
   puenc.def    2012/11/06 v6.83m Hyperref: PDF Unicode definition (HO)
stringenc.sty    2011/12/02 v1.10 Convert strings between diff. encodings (HO)
rerunfilecheck.sty    2011/04/15 v1.7 Rerun checks for auxiliary files (HO)
se-ascii-print.def    2011/12/02 v1.10 stringenc: Printable ASCII characters
beamerbaserequires.sty    2010/05/01  (rcs-revision efa082c6111d)
beamerbasecompatibility.sty    2012/05/01  (rcs-revision 67c48b3b652d)
beamerbasefont.sty    2013/10/18  (rcs-revision 72f39e01808a)
 amssymb.sty    2013/01/14 v3.01 AMS font symbols
amsfonts.sty    2013/01/14 v3.01 Basic AMSFonts support
sansmathaccent.sty    2013/03/28
filehook.sty    2011/10/12 v0.5d Hooks for input files
beamerbasetranslator.sty    2010/06/11  (rcs-revision 85fd1cc7fc42)
translator.sty    2010/06/12 ver 1.10
translator-language-mappings.tex
beamerbasemisc.sty    2013/09/03  (rcs-revision a55719c41d85)
beamerbasetwoscreens.sty    2010/05/01  (rcs-revision efa082c6111d)
beamerbaseoverlay.sty    2012/11/11  (rcs-revision 6afbc49b1109)
beamerbasetitle.sty    2010/09/21  (rcs-revision f0446ed0b6ae)
beamerbasesection.sty    2013/06/07  (rcs-revision 60b9fe0f342f)
beamerbaseframe.sty    2013/10/02  (rcs-revision cdc8e9a3aaac)
beamerbaseverbatim.sty    2012/08/30  (rcs-revision dfdb135076b3)
beamerbaseframesize.sty    2011/09/12  (rcs-revision 70f9d8411e54)
beamerbaseframecomponents.sty    2013/10/04  (rcs-revision ea094b4278bd)
beamerbasecolor.sty    2010/06/06  (rcs-revision d1a9b48be06d)
beamerbasenotes.sty    2012/12/19  (rcs-revision 1686da3db3c9)
beamerbasetoc.sty    2013/05/23  (rcs-revision 0fdf5bc43be8)
beamerbasetemplates.sty    2010/05/01  (rcs-revision efa082c6111d)
beamerbaseauxtemplates.sty    2013/09/04  (rcs-revision 4ac715c499d0)
beamerbaseboxes.sty    2012/05/13  (rcs-revision 56972908a390)
beamerbaselocalstructure.sty    2013/09/04  (rcs-revision 4ac715c499d0)
enumerate.sty    1999/03/05 v3.00 enumerate extensions (DPC)
beamerbasenavigation.sty    2013/10/05  (rcs-revision 62be157fe783)
beamerbasetheorems.sty    2010/06/06  (rcs-revision 7e7cc5e53e9d)
 amsmath.sty    2013/01/14 v2.14 AMS math features
 amstext.sty    2000/06/29 v2.01
  amsgen.sty    1999/11/30 v2.0
  amsbsy.sty    1999/11/29 v1.2d
  amsopn.sty    1999/12/14 v2.01 operator names
  amsthm.sty    2004/08/06 v2.20
beamerbasethemes.sty    2010/05/01  (rcs-revision efa082c6111d)
beamerthemedefault.sty    2010/06/17  (rcs-revision d02a7cf4d8ae)
beamerfontthemedefault.sty    2012/12/19  (rcs-revision 1686da3db3c9)
beamercolorthemedefault.sty    2012/12/19  (rcs-revision 1686da3db3c9)
beamerinnerthemedefault.sty    2013/10/15  (rcs-revision 65cb471f9634)
beamerouterthemedefault.sty    2012/12/19  (rcs-revision 1686da3db3c9)
   xeCJK.sty    2013/08/15 v3.2.6 Typesetting CJK scripts with XeLaTeX
   expl3.sty    2013/10/13 v4597 L3 Experimental code bundle wrapper
 l3names.sty    2012/12/07 v4346 L3 Namespace for primitives
l3bootstrap.sty    2013/07/28 v4581 L3 Experimental bootstrap code
    etex.sty    1998/03/26 v2.0 eTeX basic definition package (PEB)
l3basics.sty    2013/07/28 v4581 L3 Basic definitions
 l3expan.sty    2013/08/17 v4584 L3 Argument expansion
    l3tl.sty    2013/09/16 v4592 L3 Token lists
   l3seq.sty    2013/07/28 v4581 L3 Sequences and stacks
   l3int.sty    2013/08/02 v4583 L3 Integers
 l3quark.sty    2013/07/21 v4564 L3 Quarks
   l3prg.sty    2013/08/25 v4587 L3 Control structures
 l3clist.sty    2013/07/28 v4581 L3 Comma separated lists
 l3token.sty    2013/08/25 v4587 L3 Experimental token manipulation
  l3prop.sty    2013/07/28 v4581 L3 Property lists
   l3msg.sty    2013/07/28 v4581 L3 Messages
  l3file.sty    2013/10/13 v4596 L3 File and I/O operations
  l3skip.sty    2013/07/28 v4581 L3 Dimensions and skips
  l3keys.sty    2013/07/28 v4581 L3 Experimental key-value interfaces
    l3fp.sty    2013/07/09 v4521 L3 Floating points
   l3box.sty    2013/07/28 v4581 L3 Experimental boxes
l3coffins.sty    2012/09/09 v4212 L3 Coffin code layer
 l3color.sty    2012/08/29 v4156 L3 Experimental color support
l3luatex.sty    2013/07/28 v4581 L3 Experimental LuaTeX-specific functions
l3candidates.sty    2013/07/24 v4576 L3 Experimental additions to l3kernel
xtemplate.sty    2013/10/13 v4597 L3 Experimental prototype document functions
  xparse.sty    2013/10/13 v4597 L3 Experimental document command parser
l3keys2e.sty    2013/10/13 v4597 LaTeX2e option processing using LaTeX3 keys
fontspec.sty    2013/05/20 v2.3c Font selection for XeLaTeX and LuaLaTeX
fontspec-patches.sty    2013/05/20 v2.3c Font selection for XeLaTeX and LuaLaTe
X
fixltx2e.sty    2006/09/13 v1.1m fixes to LaTeX
fontspec-xetex.sty    2013/05/20 v2.3c Font selection for XeLaTeX and LuaLaTeX
 fontenc.sty
  eu1enc.def    2010/05/27 v0.1h Experimental Unicode font encodings
  eu1lmr.fd    2009/10/30 v1.6 Font defs for Latin Modern
xunicode.sty    2011/09/09 v0.981 provides access to latin accents and many oth
er characters in Unicode lower plane
 eu1lmss.fd    2009/10/30 v1.6 Font defs for Latin Modern
fontspec.cfg
xunicode-addon.sty    2013/08/15 v3.2.6 addon file for xunicode
xunicode.sty    2011/09/09 v0.981 provides access to latin accents and many oth
er characters in Unicode lower plane
indentfirst.sty    1995/11/23 v1.03 Indent first paragraph (DPC)
   xeCJK.cfg    2013/08/15 v3.2.6 Configuration file for xeCJK package
   t3cmr.fd    2001/12/31 TIPA font definitions
 nameref.sty    2012/10/27 v2.43 Cross-referencing by name of section
gettitlestring.sty    2010/12/03 v1.4 Cleanup title references (HO)
translator-basic-dictionary-English.dict    
translator-bibliography-dictionary-English.dict    
translator-environment-dictionary-English.dict    
translator-months-dictionary-English.dict    
translator-numbers-dictionary-English.dict    
translator-theorem-dictionary-English.dict    
 ***********

If you do use an old package, update it.

For MiKTeX, use the Update utility or Package Manager:

enter image description here

For TeX Live, use TeX Live Manager instead.

  • 1
    Hi, thank you for your answer. I tried your sample with Texworks in Miktex and Tex live and I got the same error message that I always get. Here it is: ! Undefined control sequence. ("C:\Program Files\MiKTeX 2.9\tex\latex\fontspec\fontspec.cfg" ! Undefined control sequence. <argument> \c_keys_code_root_tl fontspec/Ligatures/Historical l.8 ...tureoption{Ligatures}{Historic}{Historical} ? – Squid Oct 21 '13 at 4:08
  • 1
    @Squid: Then you should update fontspec, l3kernel, and l3packages. See my updated answer. – Leo Liu Oct 21 '13 at 4:31
  • @LeoLiu: I recommanded he/her to install TeX Live 2013. After that installation, however, he/her got the same error. 非科学的な – Ch'en Meng Oct 21 '13 at 4:57
  • By the way, this code works well in my computer. @Squid – Ch'en Meng Oct 21 '13 at 5:01
  • @LeoLiu Awesome ! I updated the 3 packages and it worked like a charm (with Miktex). Thank you so very much. My problem is solved ! – Squid Oct 21 '13 at 5:51
4

If you want to use CJK/CJKutf8 packages to output Japanese characters, you have to generate font files before you compile your source code. Since CJK/CJKutf8 packages are obsolete, I recommend you to use xeCJK package.

Sample:

\documentclass{article}
\usepackage{xeCJK}
\setCJKmainfont{SimSun}
\begin{document}
こんにちは
\end{document}

Save it as UTF-8 encoding, and compile it with XeLaTeX, you will get: enter image description here

Here, the command \setCJKmainfont{SimSun} load a font file whose name is "SimSun" from your system. You can type fc-list > C:\myfonts.txt in cmd window, and find the font name you can fill in \setCJKmainfont{}.

The xeCJK package is a great work of Chinese LaTeX community, LuaTeX-ja, however, is developed by Japanese. Have a look at its document may also help you.

  • Thank you very mush for you answer. I tried your sample. I got an "utf8" icon at the bottom of the window, so I guess it means the encoding is utf8; but i get an error message: the dreaded "undefined control sequence". What do you mean by "generate font files" ? – Squid Oct 17 '13 at 2:48
  • @Squid: Erh, since you provided no more log info, I do not know what happened on your system. Update your question (edit it), and display the MWE with log info. "Generate font files", however, is a long story. Engine TeX/pdfTeX do not support unicode directly, which is one of the reasons that they cannot use fonts installed in one's system. If you want to insert CJK characters in PDF output, as an example, you have to split the original fontfile into many parts, called 'subfont', who has only 256 CJK characters. – Ch'en Meng Oct 17 '13 at 3:14
  • The package CJK divided any asia characters in TeX source file into two parts---the first part points out which subfont contain the specific character, and the second part gives the position of that character in the subfont (range from 0 to 255). So, if you want to use the package CJK, you have to generate such subfonts as the first step. – Ch'en Meng Oct 17 '13 at 3:18
  • The log is really long, but the only error message is: ! Undefined control sequence. <argument> \c_keys_code_root_tl fontspec/Ligatures/Historical l.8 ...tureoption{Ligatures}{Historic}{Historical} ? – Squid Oct 17 '13 at 3:25
  • I don't remember generating any font file, so I suppose that is the problem. I will try to find a step-by-step explanation for that. – Squid Oct 17 '13 at 3:26
1

You have to run your example with pdflatex and not xelatex. Then it will work. For xelatex you can simply use:

\documentclass{beamer}
\usepackage{fontspec}
\setmainfont{Code2000}
\begin{document}
\rmfamily% Code2000 has no sans serif charcters
abc 因子の部屋

\end{document}

or any other font instead of Code2000 which has japanese characters.

enter image description here

  • I used xelatex because I got an error message with pdflatex: "undefined control sequence". I get the same error running your sample with xelatex: "undefined control sequence"... – Squid Oct 17 '13 at 2:50
  • I forgot to thank you for your answer. Thanks! – Squid Oct 17 '13 at 2:57

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.