是否可以使用语言 Unicode 字符?

是否可以使用语言 Unicode 字符?

我需要在使用 Overleaf 编写的文档中使用几个 Unicode 字符。我不需要它们做任何特殊的事情,我只需要能够将它们写入我的源文本并在编译的输出中以相同的方式看到它们。我需要使用整个 Ogham 块(U+1680 到 U+169C)以及各种其他语言符号,例如 tironian et(U+204A)、一些组合变音符号(U+030C 和 U+0304)等等。

我尝试了几个我找到的解决方案,使用 XeTeX 和 LuaTeX 编译器。当我使用 LuaTex 时,我没有收到任何错误消息,这很好。但是,只有部分字符显示在输出中,而且我丢失了很多文档的格式,而使用 pdfTeX 时这些格式可以正常工作。例如,我的所有章节标题都以小写而不是大写进行编译,并且文档标题间距发生变化并且丢失了粗体。

其他线程建议使用类似的方法\DeclareUnicodeCharacter{"204A}{},但将其添加到我的包下面会引发新的错误:

Missing number, treated as zero.
LaTeX Error: Missing \Begin{document}.
Package inputenc Error: Cannot define non-active Unicode char value < 00A0.

有什么方法可以解决这个问题,只需让 pdfTeX 编译文档,以便它在输出中显示我的 Unicode 字符,就像在输入中一样?

答案1

使用 lualatex 或 xelatex 时,您只需要一种具有字符的字体。Noto Sans Ogham 安装在 Overleaf 上,并且毫不奇怪地覆盖了 Ogham 块:

在此处输入图片描述

该文件是

\documentclass{article}

\title{Ogham}
\usepackage{fontspec}

\newfontfamily\og{Noto Sans Ogham}
\date{September 2021}

\begin{document}

\maketitle
\tracinglostchars=2

\section{Introduction}

Some Ogham\\
U+1680 {\og ^^^^1680}\\
U+1681 {\og ^^^^1681}\\
U+1682 {\og ^^^^1682}\\
U+1683 {\og ^^^^1683}\\
U+1684 {\og ^^^^1684}\\
U+1685 {\og ^^^^1685}\\
U+1686 {\og ^^^^1686}\\
U+1687 {\og ^^^^1687}\\
U+1688 {\og ^^^^1688}\\
U+1689 {\og ^^^^1689}\\
U+168A {\og ^^^^168a}\\
U+168B {\og ^^^^168b}\\
U+168C {\og ^^^^168c}\\
U+168D {\og ^^^^168d}\\
U+168E {\og ^^^^168e}\\
U+168F {\og ^^^^168f}\\
U+1690 {\og ^^^^1690}\\
U+1691 {\og ^^^^1691}\\
U+1692 {\og ^^^^1692}\\
U+1693 {\og ^^^^1693}\\
U+1694 {\og ^^^^1694}\\
U+1695 {\og ^^^^1695}\\
U+1696 {\og ^^^^1696}\\
U+1697 {\og ^^^^1697}\\
U+1698 {\og ^^^^1698}\\
U+1699 {\og ^^^^1699}\\
U+169A {\og ^^^^169a}\\
U+169B {\og ^^^^169b}\\
U+169C {\og ^^^^169c}

\end{document}

^^^^如果这样更方便,您也可以直接输入字符,而不是通过。

相关内容