
我正在使用該包xpinyin
來顯示拼音,即漢字上方的漢語拼音文字。這看起來效果很好,但我想改變拼音文字的字體。我在中找到了一些程式碼包文件,雖然那個只有中文:
\xpinyinsetup{ratio=0.5, vsep=1em, multiple={\color{red}}, font=Liberation Sans}
文件中的中文對我來說還是太高級了,所以我簡單猜測它的作用是這樣的:
- 將拼音hal設為主字體的大小
- 垂直間隔1em,拼音與下面的漢字間隔1em
- 如果一個字元有多個拼音(多音字),則該拼音將是最可能的一個,並塗成紅色
- 使用字體
Liberation Sans
但是,我不知道是否可以簡單地在Liberation
和之間留一個空格Sans
。主要問題是結果如下:
(在這張圖片中,我使用它是Arial
因為它的名稱足夠短,易於閱讀。)所以我想:“這一定是字體問題。”我嘗試使用Liberation Sans
Libre Office中的字體,檢查它是否可以用音調顯示缺失的人聲。它能夠在不指示字體更改的情況下顯示它,但我不知道它是否隱藏了這些訊息,也許字體真的無法顯示這些聲音。
也要注意字體名稱是如何添加到拼音腳本中的。這可能是故意的,儘管它看起來像是一個錯誤。但我不明白文件。
第一個字元的拼音文字中沒有字體名稱,如何才能使xpinyin正確顯示?
這裡有一些範例程式碼:
\documentclass[10pt, a4paper, parskip=full]{article} % twoside can be added if two sided margin layout is desired
\usepackage[a4paper,vmargin={30mm, 20mm},hmargin={30mm, 25mm},includeheadfoot]{geometry}
\usepackage{amsmath}
\usepackage[UTF8]{ctex}
\usepackage{xpinyin}
\xpinyinsetup{ratio=0.5, vsep=1em, multiple={\color{red}}, font=Liberation Sans}
\usepackage{fontspec,xunicode}
\setCJKmainfont[]{WenQuanYi Micro Hei}
\defaultfontfeatures{Mapping=tex-text, Scale=MatchLowercase} % what does this do? -- influences how quotes are rendered
\setmainfont[Scale=1]{Open Sans}
\setmonofont{Liberation Mono}
\DeclareMathSizes{10}{10}{8}{7}
\usepackage[english, ngerman]{babel}
\selectlanguage{ngerman}
\begin{document}
\begin{pinyinscope}
我有一个送给你的礼物.
\end{pinyinscope}
\end{document}
答案1
我找到了一個解決方法,也許這可以被視為一個解決方案:
\usepackage{xpinyin}
\xpinyinsetup{ratio={.7}, hsep={.5em plus .1em}, vsep={1.1em}, multiple={\color{red}}}
% redefine the pinyinscope environment, so that it uses a font which can display all pinyin syllables and vocals with diacritics
\newenvironment{pinyinscopeboxed}%
{\setmainfont{DejaVu Sans}\begin{pinyinscope}}%
{\end{pinyinscope}\setmainfont{Open Sans}}
這會將字體變更為一種字體,每當環境pinyinscopeboxed
開始時,該字體都可以顯示拼音的所有變音符號,並在環境結束時將其變更回另一種字體。必須根據需要配置特定字體,並且可以透過在更改主字體之前以某種方式使用變數來包含主字體,然後使用該變數切換回來來改進它,但我還不知道如何做到這一點。對於如何做到這一點或如何改進解決方案的建議,我將不勝感激。
這也避免了錯誤行為,導致字體名稱顯示在 rubies 中,因為它不font
使用xpinyin
.
編輯#1
李慶告訴我一個正確的做法。
不要更新環境,但如果您使用該fontspec
套件,您可以執行以下操作:
\usepackage{fontspec}
\newfontfamily{\DVS}{DejaVu Sans}
\usepackage{xpinyin}
\xpinyinsetup{ratio={.7}, hsep={.5em plus .1em}, vsep={1.1em}, multiple={\color{red}}, pysep={.2em}, font=\DVS}
(除 之外的其他值font=
僅用於舉例。)