
我不明白如何在我的 XeLaTeX 文件中獲取 ▼(U+25BC;實心倒三角形)。以下幾行是我的 XeLaTeX 的一部分,似乎與此問題相關。我希望修改文件以獲得▼(U+25BC;實心倒三角形),但沒有取得進展。我想許多包在文件中互相爭鬥。如果您能分享一些針對這種情況的好方法,我將不勝感激。
至於您的訊息,我正在使用基於 MacBook Pro 的 TeXShop 版本 4.31 (XeLaTeX)。我應該在這個文件中使用英文、梵文、藏文和繁體中文字母。
\usepackage{polyglossia, fontspec, xunicode}
\usepackage[Apara, Bpara,Cpara]{ednotes}
\usepackage{setspace}
\setmainlanguage{english}
\setotherlanguages{sanskrit}
\usepackage{xeCJK}
\setCJKsansfont[Path=/Users/XXX/Library/Fonts/]{NotoSerifCJK.ttc}
\usepackage{ucs}
\usepackage[utf8x]{inputenc}
\usepackage{textcomp}
\DeclareUnicodeCharacter{"2100}{\textcelsius}
\DeclareUnicodeCharacter{"2103}{\textcelsius}
\DeclareUnicodeCharacter{"25BC}{\textcelsius}
%%%%%Sigla and Symbols
\usepackage{enumitem}
\usepackage{setspace}
\usepackage{ltablex}
%%%%%critical_apparatus
\usepackage{bbding}
\usepackage{ulem}
\usepackage{xstring}
\usepackage{ifthen}
\usepackage{wasysym} %This line is related to \astrosun ⊙
\begin{document}
\char "2100\relax
\char "2103\relax
\char "25BC\relax
\end{document}
答案1
這是一個簡化的 MWE:
\documentclass{standalone}
\usepackage{polyglossia} % Includes fontspec
\usepackage{newunicodechar}
\defaultfontfeatures{Scale=MatchUppercase}
\setmainlanguage{english}
\setotherlanguage{sanskrit}
% \setmainfont, \newfontfamily\devanagarifontsf, \setCJKfont, etc.
% Alternatively, you could use babel.
\newfontfamily\symbolfont{DejaVu Sans Mono}
\newunicodechar{^^^^25bc}{{\symbolfont\symbol{"25BC}}} % ▼
\begin{document}
▼{^^^^25bc}
\end{document}
它使用fontspec
(由 載入polyglossia
)來設定包含字形的符號字體並newunicodechar
切換到該符號的字體。 (如果您還想在數學模式下使用它,則需要使用更複雜的命令\ifmmode
,但您似乎不需要。)
一個問題是,您似乎從幾個彼此不相容的範例中貼上了程式碼。例如,您只能將inputenc
,\DeclareUnicodeCharacter
和textcomp
與舊版 7 位元和 8 位元字體一起使用,而不是與現代 Unicode 字體一起使用。我建議您從序言中取出所有您不確定需要的軟體包。
另一個是\char
或\symbol
選擇當前字體中給定位置的字形。這是您在序言中定義命令時想要的,但在文件中使用它時則不是。您將字符設為活動字符,因此它會被命令替換,並且需要 TeX 引擎將某些代碼視為您鍵入了字符本身。那是^^^^xxxx
。
您還組合了不同的國際包,這可能適合您,也可能不適合您。您可以嘗試babel
使用\babelfont
一致的介面來支援所有四種語言。
多語言模板
評論中的後續問題有兩種可能的答案,具體取決於您想要的答案。
如果您正在製作類似符號字典的東西並且只需要獨立的字形,您可能需要ucharclasses
包裹。這樣您就可以為晦澀的漢字指定一種字體,例如 Babelstone Han,另一種為占星符號指定字體,等等。然後您輸入一個字形,XeTeX 會自動顯示正確字體的每個字形。
如果您確實需要以所有四種語言排版整個單字和段落,下面的序言可以讓您用babel
.它需要 XeLaTeX。 (實驗性的 HarfTeX 也可能有效。)我還設定了名為polyglossia
.
\documentclass{article} % Or whatever is appropriate.
% The next line is only to make the output narrower, to fit into an image
% on TeX.SX: Remove geometry from your document and just give the paper
% size as an option to the document class.
\usepackage[paperwidth=10cm]{geometry}
\usepackage{babel} % You would need the bidi option if using RTL.
\usepackage{newunicodechar} % For \newunicodechar
\usepackage{fontspec} % For \defaultfontfeature
% This allows you to typeset passages in these langauges. If you only need
% to display individual, stand-alone glyphs, `ucharclasses` is simpler and
% allows you to just type the leeters in as UTF-8.
\babelprovide[import, main, language=Default]{english}
\babelprovide[import]{sanskrit-devanagari}
\babelprovide[import]{chinese-traditional}
\babelprovide[import]{tibetan}
\defaultfontfeatures{Scale=MatchUppercase}
% Set these to your fonts of choice:
\babelfont{rm}
[Scale=1.0, Ligatures=Common]{Linux Libertine O}
\babelfont{sf}
[Ligatures=Common]{Linux Biolinum O}
\babelfont[chinese-traditional]{rm}
[Ligatures={Common, Discretionary}]{Noto Serif CJK TC}
\babelfont[chinese-traditional]{sf}
{Noto Sans CJK TC}
\babelfont[sanskrit-devanagari]{rm}
[Language=Default]{Noto Serif Devanagari}
\babelfont[sanskrit-devanagari]{sf}
[Language=Default]{Noto Sans Devanagari}
\babelfont[tibetan]{rm}
[Language=Default]{Noto Sans Tibetan}
\babelfont[tibetan]{sf}
[Language=Default]{Noto Sans Tibetan}
\newfontfamily\symbolfont{Linux Libertine}
% You might or might not need to set up these symbols specifically. They
% might just work.
\newunicodechar{^^^^2100}{{\symbolfont\symbol{"2100}}} % ℀
\newunicodechar{^^^^2103}{{\symbolfont\symbol{"2103}}} % ℃
\newunicodechar{^^^^25bc}{{\symbolfont\symbol{"25BC}}} % ▼
\newcommand\textenglish[1]{\foreignlanguage{english}{#1}}
\newcommand\textchinese[1]{\foreignlanguage{chinese-traditional}{#1}}
\newcommand\textsanskrit[1]{\foreignlanguage{sanskrit-devanagari}{#1}}
\newcommand\texttibetan[1]{\foreignlanguage{tibetan}{#1}}
% Enables \begin{chinese}, etc., for full paragraphs in another language.
\newenvironment{english}%
{\begin{otherlanguage}{english}}%
{\end{otherlanguage}}
\newenvironment{chinese}%
{\begin{otherlanguage}{chinese-traditional}}%
{\end{otherlanguage}}
\newenvironment{sanskrit}%
{\begin{otherlanguage}{sanskrit-devanagari}}%
{\end{otherlanguage}}
\newenvironment{tibetan}%
{\begin{otherlanguage}{tibetan}}%
{\end{otherlanguage}}
\begin{document}
This document is in English, \textsanskrit{संस्कृतम्},
\textchinese{繁體字} and \texttibetan{བོད་སྐད་}, brought to you by the symbols
{^^^^2100}, {^^^^2103} and {^^^^25bc}.
\end{document}
使用的樣品Google的 Noto 字體,您可能需要下載。
您可能不希望以這種方式定義諸如攝氏度之類的符號:您可能希望它與目前選擇的字體相符。但是,如果您確實需要修補主要字體沒有的幾個字形,這些範例將向您展示如何操作。
由於字體的怪癖,我在字體上設定了一些選項。例如,所有Language=Default
選項都可以抑製字體不支援該特定語言的警告訊息。像諾託的藏文字體不支援藏文標籤並使用DFLT
它之類的東西是無害的,你可以忽略它們。如果您想為諸如 之類的東西煩惱Numbers=OldStyle
,該otfinfo
命令是檢查字體支援哪些功能的好方法。
最小化 MWE
您詢問哪些軟體包是您不需要的。你絕對不需要inputenc
或textcomp
。這些套件適用於舊版 8 位元字體。如果不使用 ,則只需要polyglossia
或,但如果只需要一種表意文字,您可能會發現很方便。除了 之外,您不需要加載,它會自動加載它,並且加載兩次會有選項衝突的風險。 (如果您確實想要,請在之前加載,而不是之後加載。)您可能不想要or 。xeCJK
babel
xeCJK
fontspec
polyglossia
fontspec
ucs
xunicode
bbding
和包wasysym
都會載入符號字體,因此如果您使用的符號是 Unicode 格式的,則不需要它們。例如,註釋顯示wasysym
正在載入占星太陽符號,即 ☉ (U+2609)。您仍然可以將該字元作為 符號的別名\astrosun
,wasysym
但如果可以的話,我建議您堅持使用 Unicode。您將獲得正確的縮放比例並能夠從 PDF 文件進行複製。
其他軟體包看起來更重要,但您可以嘗試刪除其中一個並查看是否有任何損壞。如果沒有,它可能沒有被實際使用。
答案2
首先,當您使用 XeLaTeX 時,請避免使用、 、xunicode
和。ucs
inputenc
\DeclareUnicodeCharacter
將 U+2100 ACCOUNT OF 或 U+25BC BLACK DOWN-POINTING TRIANGLE 對應到 是很奇怪的\textcelsius
。
Noto Serif CJK 字體包含 U+2100 和 U+25BC 的字形,但這些字元不會觸發切換到 CJK 字體,因此應明確選擇此類字體。
正如其他人所提到的,newunicodechar
可以完成這項工作:
\documentclass{article}
\usepackage{polyglossia, fontspec}
\usepackage{xeCJK}
\usepackage[Bpara,Cpara]{ednotes}
\usepackage{setspace}
%%%%%Sigla and Symbols
\usepackage{enumitem}
\usepackage{ltablex}
%%%%%critical_apparatus
\usepackage{bbding}
\usepackage{ulem}
\usepackage{xstring}
\usepackage{ifthen}
\usepackage{wasysym} %This line is related to \astrosun ⊙
\usepackage{newunicodechar}
\setmainlanguage{english}
\setotherlanguages{sanskrit}
\setCJKmainfont{NotoSerifCJK}[Path=./,Extension=.ttc]
\newfontfamily{\various}{NotoSerifCJK}[Path=./,Extension=.ttc]
\newunicodechar{℀}{{\various ℀}}
\newunicodechar{▼}{{\various ▼}}
\begin{document}
℀
℃
▼
\end{document}
順便說一下,不設定主字體是無法設定CJK sans字體的;此外,Noto Serif CJK 不是無襯線字體。
當然,您可以對正在使用的主要字體中缺少的符號使用不同的字體。
答案3
由於您已經加載了wasysym
,因此您可以\DOWNarrow
從該套件中使用。它比 Unicode 字元稍大。
MWE,感謝戴維斯勒:
\documentclass{standalone}
\usepackage{polyglossia} % Includes fontspec
\usepackage{newunicodechar}
\usepackage{wasysym}
\defaultfontfeatures{Scale=MatchUppercase}
\setmainlanguage{english}
\setotherlanguage{sanskrit}
% \setmainfont, \newfontfamily\devanagarifontsf, \setCJKfont, etc.
% Alternatively, you could use babel.
\newfontfamily\symbolfont{DejaVu Sans Mono}
\newunicodechar{^^^^25bc}{{\symbolfont\symbol{"25BC}}} % ▼
\begin{document}
▼{^^^^25bc}\DOWNarrow
\end{document}
結果: