Skip to content

Instantly share code, notes, and snippets.

@zr-tex8r
Last active November 22, 2016 02:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save zr-tex8r/6135807 to your computer and use it in GitHub Desktop.
Save zr-tex8r/6135807 to your computer and use it in GitHub Desktop.
LaTeX: CJK パッケージで日本語する
% 文字コードは UTF-8
% pdflatex または latex + dvipdfmx/dvips で組版
\documentclass[a4paper]{article} % pdfTeX の場合
%\documentclass[a4paper,dvipdfmx]{article} % dvipdfmx の場合
%(ドライバ明示指定が必要なのは bxcjkjatype でなく hyperref)
\usepackage[whole]{bxcjkjatype} % 本文全体をCJK*に入れる
% 以降はプレアンブルで和文が使用可能
\newcommand\Nihongo{日本語} % ←和文を含むマクロ定義
\usepackage[unicode,% ←しおりの出力に必要
bookmarks=true,colorlinks=true]{hyperref}
\begin{document}
% ↓和文を含む節見出し
\section{Preparing document in \Nihongo\ using pdf\TeX\ な件}
The 文書 contains \Nihongo\ and English,
with a bit of 髙島屋.
\end{document}
% 文字コードは UTF-8
% latex + dvipdfmx で組版
% (Moga フォントは TTC 形式で, これは pdfTeX で未対応なため)
\documentclass[a4paper]{article}
\usepackage[moga-maruberi]{bxcjkjatype}% Mogaフォント + マルベリ
\begin{document}
Here is some test on Japanese fonts.\par
\begin{uCJK*}% 外側の欧文の総称ファミリ設定を"引き継ぐ"
%(欧文 \rmfamily → 和文 明朝(\mcfamily))
Mincho(明朝) family, and \textbf{in bold(太字)}.\par
\sffamily % 和文は"連動"してゴシック(\gtfamily)になる
Gothic(ゴシック) family, and \textbf{in bold(太字)}.\par
\mgfamily % 和文のみ丸ゴシックに変更
Maru-gothic(丸ゴシック) family.
\end{uCJK*}
\end{document}
%% 文字コードは UTF-8
% (pdf)latex で組版
\documentclass[12pt]{beamer} % pdfTeX の場合
%\documentclass[12pt,dvipdfmx]{beamer} % dvipdfmx の場合
%\usepackage{bxdpx-beamer} % dvipdfmx の場合に必要に応じて
\hypersetup{unicode}% しおりの和文出力に必要
\usepackage[whole]{bxcjkjatype}% whole 指定
%%↓ 後は普通に Beamer するだけ
\usetheme{Warsaw}
%---------------------------------------
% 日本語している
\title{How to do 日本語 with pdf{\TeX}}
\author{ZR 某}
\date{某日 of August, 2013}
%---------------------------------------
\begin{document}
\begin{frame}
\titlepage
\end{frame}
%---------------------------------------
\section{日本語 with bxcjkjatype package}
\begin{frame}[fragile]{First}
Load the \alert{bxcjkjatype} package in preamble.\par
Use of \structure{\texttt{whole}} option is often suitable.\par
\begin{exampleblock}{アレな Example}
\begin{verbatim}
\documentclass[a4paper]{article}
\usepackage[whole]{bxcjkjatype}
\end{verbatim}
\end{exampleblock}
\end{frame}
\begin{frame}[fragile]{Second}
Write whatever 日本語 text you like in the document body.\par
You can use ひらがな, カタカナ, 漢字, and/or
any character available in the standard fonts
(\structure{IPAex明朝/ゴシック}).\par
\begin{exampleblock}{アレな Example}
\begin{verbatim}
\documentclass[a4paper]{article}
\usepackage[whole]{bxcjkjatype}
\begin{document}
鰻が無いならホバークラフトを食べればいいじゃない。
\end{document}
\end{verbatim}
\end{exampleblock}
\structure{※} Must use UTF-8.\par
\end{frame}
\begin{frame}{Third}
Compile the document as usual.\par
\begin{block}{アレな Output}
\rmfamily
鰻が無いならホバークラフトを食べればいいじゃない。
\end{block}
\end{frame}
\begin{frame}{Last}\relax
{\LARGE\alert{楽しい!!}\par}
\bigskip
(AA略
\end{frame}
%---------------------------------------
\section{Conclusion (Not!)}
\begin{frame}{Very important slide}
\transdissolve[duration=0.5]
\centering\Large
ご清聴ありがとうございました。
\end{frame}
\end{document}
@zr-tex8r
Copy link
Author

The package is now distributed at GitHub:zr-tex8r/BXcjkjatpye.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment