%20%E4%B8%AD%E6%9B%B8%E5%90%8D%E7%9A%84%E8%87%AA%E8%A8%82%E6%A0%BC%E5%BC%8F.png)
在中文排版慣例中,書名通常包含在書名標記「《」與「》」內,它們是 UTF-8 Unicode 符號。可以使用 xeCJK 套件支援這些符號(它將中文、日文和韓文的所有字元和符號的 \catcode 設定為 11)。我想詢問是否有一種方法(類似於shortvrb處理‘|’符號的方法)為“《”和“》”設置一個控制序列,允許這些標記中包含的書名的排版具有特定的格式,例如斜體或以藍色顯示等。
漢字排版tex檔通常如下:
% !TEX program = xelatex
\documentclass{article}
\usepackage{xeCJK}
\begin{document}
Here is a book title in chinese book title marks
《A Chinese Book》
\end{document}
儲存為 UTF-8 編碼的 .tex 檔案。
答案1
您可以使用活動類別代碼來發出《
命令。然而,這樣做的缺點是未配對《
會導致錯誤。
\documentclass{ctexart}
\begin{document}
\catcode`《 = \active
\def《#1》{\emph{#1}}
中文
《中文》
《Chinese》
\end{document}
答案2
您可以使用\newunicodechar
:
\documentclass{article}
\usepackage{xeCJK}
\usepackage{newunicodechar}
\newunicodechar{《}{\begingroup《\em\ignorespaces}
\newunicodechar{》}{\/\endgroup》}
\begin{document}
Here is a book title in chinese book title marks
《A Chinese Book》
\end{document}
替代方法:
\documentclass{article}
\usepackage{xeCJK}
\usepackage{newunicodechar}
\newunicodechar{《}{《\hzzhangbook|}
\NewDocumentCommand{\hzzhangbook}{r|》}{\emph{#1}》}
\begin{document}
Here is a book title in chinese book title marks
《A Chinese Book》
\end{document}
不同之處在於,對於後一種程式碼,缺失》
會引發錯誤;使用先前的程式碼,格式化將繼續。隨你挑選。