This is yet another reason to switch to biblatex
(here: in combination with csquotes
). (And with biblatex-trad
there's even a trad-plain
style!)
\documentclass{article}
\usepackage[british,french]{babel}
\usepackage[french=guillemets]{csquotes}
\usepackage[style=trad-plain,babel=other]{biblatex}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{A2012,
hyphenation = {british},
author = {Author, A},
title = {A \enquote{paper}: written in english?},
journal = {Journal},
year = {2012},
volume = {2},
pages = {70--76},
}
@article{B2012,
hyphenation = {french},
author = {Auteur, B},
title = {Un \enquote{article}: \'ecrit en fran\c{c}ais?},
journal = {Journal},
year = {2012},
volume = {2},
pages = {77--79},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\cite{A2012}, \cite{B2012}
\printbibliography
\end{document}
In babel
, you can switch between different ideographic alphabets, including Japanese and traditional Chinese:
\documentclass{standalone} % Replace with the real class.
\usepackage[english]{babel}
\usepackage{fontspec}
% A bug in Babel 3.22 requires setting the script= option to CJK and Kana,
% respectively.
\babelprovide{chinese-traditional}
\babelprovide{japanese}
\defaultfontfeatures{Scale = MatchUppercase}
\babelfont{rm}[Scale = 1.0,
Ligatures = {Common, TeX},
Language = Default
]{Latin Modern Roman}
\babelfont{sf}[Ligatures = {Common, TeX},
Language = Default]{Latin Modern Sans}
\babelfont[chinese-traditional]{rm}{NotoSerifCJKtc-Regular}
\babelfont[chinese-traditional]{sf}{NotoSansCJKtc-Regular}
\babelfont[japanese]{rm}{NotoSerifCJKjp-Regular}
\babelfont[japanese]{sf}{NotoSansCJKjp-Regular}
\begin{document}
\otherlanguage{chinese-traditional}{東風}
\otherlanguage{japanese}{フォント}
\end{document}
This requires XeLaTeX and babel
3.27 or higher. (With babel
3.22, you must manually set Script=CJK
and Script=Kana
to work around a bug.) I substituted the Noto CJK fonts.
A simpler option to Babel that doesn’t require you to write \otherlanguage
all over the place would be ucharclasses
. You could also declare a \newfontfamily
, give it the [Script = Kana, Language = Japanese]
options, and select that.
Update
As of 2021, it’s possible to use multiple ideographic scripts in LuaLaTeX 1.12 or later. In theory, you can set your document up to switch between the languages without tagging. In practice, this does not reliably work for Chinese and Japanese, because the Unicode Consortium chose to use the same codepoints for Kanji and Chinese. (The original sin of Unicode was thinking they could fit everything into 16 bits.)
In this specific example, if the only Japanese we need is Hirigana and Katakana, and all ideographic characters are Chinese, we can make babel
detect Japanese, Chinese and English correctly:
\documentclass{standalone} % Replace with the real class.
\usepackage[english]{babel}
\usepackage[svgnames, HTML]{xcolor}
\usepackage{fontspec}
% A bug in Babel 3.22 requires setting the script= option to CJK and Kana,
% respectively.
\babelprovide[import, onchar=ids fonts]{japanese}
\babelprovide[import, onchar=ids fonts]{chinese-traditional}
\defaultfontfeatures{ Scale = MatchUppercase,
Ligatures=TeX }
\babelfont{rm}
[Scale = 1.0,
Ligatures = Common,
Language = Default
]{Latin Modern Roman}
\babelfont{sf}
[Ligatures = Common,
Language = Default
]{Latin Modern Sans}
\babelfont[chinese-traditional]{rm}
[Renderer=HarfBuzz, Color=DarkGreen]{NotoSerifCJKtc-Regular}
\babelfont[chinese-traditional]{sf}
[Renderer=HarfBuzz, Color=DarkGreen]{NotoSansCJKtc-Regular}
\babelfont[japanese]{rm}
[Renderer=HarfBuzz, Color=NavyBlue]{NotoSerifCJKjp-Regular}
\babelfont[japanese]{sf}
[Renderer=HarfBuzz, Color=NavyBlue]{NotoSansCJKjp-Regular}
\begin{document}
東風
\textsf{フォント}
\end{document}
Here, I set each language to a different color to make the language-switching more obvious.
Best Answer
This is not a bug.
xeCJK
treats ambigious punctuations as CJK punctuations. The ellipsis is treated as CJK punctuation thus it uses STSong font (华文宋体) and the following spaces are ignored.You can use
\ldots
,\dots
or\textellipsis
to get the proper ellipsis for western languages. (In factxeCJK
patches theses macros specially using\makexeCJKinactive
.) Any of these should work well withxeCJK
:Alan's solution is also advisable, if you use only a small amount of CJK materials. It works, but the drawback is that you must specify a
chinese
environment manually everywhere you use Chinese. And it also disables some functions ofpolyglossia
.If you use only a few words of Chinese without long sentences, you don't need
xeCJK
package. The special progress for CJK punctuations and spacing is overkill.xeCJK
is mainly designed for CJK documents with small amounts of other languages.Similar punctuations includes the quotes
“ ”
and‘ ’
, you are supposed to use tradational TeX form`foo'
and``foo''
.Warning:
xeCJK
is NOT supposed to be used together withpolyglossia
.xeCJK
conflicts withpolyglossia
since they both use\XeTeXinterchartoks
heavily, and I can't find a good way to let them work together.xeCJK
has a\makexeCJKinactive
, but it does not help here.\makexeCJKinactive
simply sets\XeTeXinterchartokenstate=0
and then many of the functions ofpolyglossia
are also disabled. You should choose one ofxeCJK
andpolyglossia
.If you decide to not to use
xeCJK
, you can set:and set the Chinese font manually everytime you use Chinese. It is very suitable for temporaryly typesetting a few Chinese words. And it is very safe. For example:
However, if you have some long Chinese texts, you should use
xeCJK
for easier font switching and better puncuations. And if you usepolyglossia
for French, punctuation progress by\french@punctuation
will be broken if you are not carefully. If you insist on usingxeCJK
andpolyglossia
together, usexeCJK
beforepolyglossia
. This might produce less errors, but I didn't make enough test, use it at your own risk.Currently I am the active maintainer of
xeCJK
. For any question aboutxeCJK
, you can email to me (leoliu.pku at gmail dot com) directly.I'm sorry for the incompatibility of
xeCJK
andpolyglossia
. Maybe I'll add some commands to disablexeCJK
safely in future versions.