更新
2022/04/17发布的新版本utfsym.sty
适用于所有引擎。
为什么我们不能使用该utfsym
软件包中的 XeLaTeX?有什么方法可以解决这个问题吗?以下是一个最小的工作示例。
\documentclass{article}
\usepackage{utfsym}
\begin{document}
\usym{2680} Many
\end{document}
此外,我知道一种调用某些特定符号的解决方案,该符号允许使用 XeLaTeX 或 LulaLaTeX:如果我们想调用编码为的符号abcd
,我们只需要找到abcd.tikz
文件在包裹里并将文件中的代码复制abcd.tikz
到下面的空白处。
\usepackage{tikz}
\makeatletter
\newcommand{\heart}{\mathord{%
\resizebox{!}{\fontcharht\font`M}{%
}%
}%
}%
\makeatother
例如,如果我们要调用编码为的符号2665
,那么我们将获得如下代码和输出。
\documentclass{article}
\usepackage{tikz}
\makeatletter
\newcommand{\heart}{\mathord{%
\resizebox{!}{\fontcharht\font`M}{%
\begin{tikzpicture}[y=0.80pt, x=0.80pt, yscale=-1.000000, xscale=1.000000, inner sep=0pt, outer sep=0pt]
\begin{scope}[shift={(100.0,1876.0)},nonzero rule]
\path[draw=.,fill=.,line width=1.600pt] (1460.0000,-1216.0000) ..
controls (1460.0000,-1126.0000) and (1430.6667,-1028.3333) ..
(1372.0000,-923.0000) .. controls (1335.3333,-857.0000) and
(1276.0000,-772.3333) .. (1194.0000,-669.0000) .. controls
(1082.0000,-527.6667) and (1001.0000,-417.6667) .. (951.0000,-339.0000) ..
controls (869.0000,-211.0000) and (812.0000,-87.6667) .. (780.0000,31.0000) ..
controls (748.0000,-87.6667) and (691.0000,-211.0000) .. (609.0000,-339.0000)
.. controls (559.0000,-417.6667) and (478.0000,-527.6667) ..
(366.0000,-669.0000) .. controls (284.0000,-772.3333) and (224.6667,-857.0000)
.. (188.0000,-923.0000) .. controls (129.3333,-1028.3333) and
(100.0000,-1126.0000) .. (100.0000,-1216.0000) .. controls
(100.0000,-1308.0000) and (131.6667,-1384.3333) .. (195.0000,-1445.0000) ..
controls (258.3333,-1505.6667) and (336.3333,-1536.0000) ..
(429.0000,-1536.0000) .. controls (514.3333,-1536.0000) and
(590.3333,-1504.3333) .. (657.0000,-1441.0000) .. controls
(719.6667,-1381.6667) and (760.6667,-1308.6667) .. (780.0000,-1222.0000) ..
controls (799.3333,-1308.6667) and (840.3333,-1381.6667) ..
(903.0000,-1441.0000) .. controls (969.6667,-1504.3333) and
(1045.6667,-1536.0000) .. (1131.0000,-1536.0000) .. controls
(1223.6667,-1536.0000) and (1301.6667,-1505.6667) .. (1365.0000,-1445.0000) ..
controls (1428.3333,-1384.3333) and (1460.0000,-1308.0000) ..
(1460.0000,-1216.0000) -- cycle;
\end{scope}
\end{tikzpicture}
}%
}%
}%
\makeatother
\begin{document}
\Huge
$\heart$ Many things
\end{document}
但它似乎有点复杂,有没有什么简单的解决方案来调用一些特定的符号?
答案1
ufsym
是一个似乎使用多个
\DeclareUnicodeCharacter
将 Unicode 代码点映射到使用适合 pdftex 的 tikz 绘制的字符,在 xetex 或 luatex 中不需要,因为它们可以使用 Unicode Opentype 字体直接排版 Unicode 代码点。
\documentclass{article}
\usepackage{fontspec}
\setmainfont{DejaVu Sans}
\begin{document}
\symbol{"2680} Many ⚀ Many
\end{document}
如果你想要这些字符的 tikz 版本而不是真正的字体,即使使用 xetex,你也可以隐藏inputenc
\DeclareUnicodeCharacter
\documentclass{article}
% hide inputenc commands
\makeatletter
\def\DeclareUnicodeCharacter#1#2{}
\makeatother
\usepackage{utfsym}
\begin{document}
\usym{2680} Many
\end{document}
答案2
更新
2022/04/17发布的新版本utfsym.sty
适用于所有引擎。
旧答案
utfsym
与 XeLaTeX 或 LuaLaTeX 配合使用会很容易。
文件xutfsym.sty
文件已被剪切,但的修改utfsym.sty
很简单:只需将第一部分更改为\DeclareUnicodeCharacter
以下内容,并将所有出现的更改\DeclareUnicodeCharacter
为\xutfsym@declare
。
\NeedsTeXFormat{LaTeX2e}[1994/06/01]
\ProvidesPackage{xutfsym}[2022/04/16 Use TikZ to support icons from Unicode blocks ]
%% developed for use in package 'schule' 2016 by Daniel Spittank
%% this package is public domain, CC0
%% modified to work with (Xe|Lua)LaTeX (egreg)
%% - needs ut8 as input encoding
%% - TikZ paths are extracted from Symbola.ttf public domain font by George Douros,
%% see: http://users.teilar.gr/~g1951d/
%% - supports direct use of unicode symbols
%% - supports textcolor
%% - supports fontsizes
%% - supported Blocks:
%% - Miscellaneous Symbols and Arrows (2600-26FF)
%% - Dingbats (2700-27BF)
%% - Mahjong Tiles (1F000-1F02F)
%% - Domino Tiles (1F030-1F09F)
%% - Playing Cards (1F0A0-1F0FF)
%% - Miscellaneous Symbols and Pictographs (1F300-1F5FF)
%% - Emoticons / Emoji (1F600-1F64F)
%% - Transport and Map Symbols (1F680-1F6FF)
\RequirePackage{xcolor}
\RequirePackage{tikz}
\RequirePackage{graphicx}
\RequirePackage{iftex}
%% command for symbol usage \usym{unicode number}
\newcommand{\usym}[1]{\resizebox{!}{\fontcharht\font`M}{\input{usym#1.tikz}}}
%% command for symbol usage as a picture, scaling by height
%% \usymH{unicode number}{height}
\newcommand{\usymH}[2]{\resizebox{!}{#2}{\input{usym#1.tikz}}}
%% command for symbol usage as a picture, scaling by width
%% \usymW{unicode number}{width}
\newcommand{\usymW}[2]{\resizebox{#2}{!}{\input{usym#1.tikz}}}
\iftutex
% unicode engine
\def\xutfsym@declare#1#2{%
\begingroup\lccode`~="#1\lowercase{\endgroup\protected\def~}{#2}%
\catcode"#1=\active
}%
\else
\let\xutfsym@declare\DeclareUnicodeCharacter
\fi
%% direct unicode support
\xutfsym@declare{1F000}{\usym{1F000}}
\xutfsym@declare{1F001}{\usym{1F001}}
% many other similar lines where the original
% file has \DeclareUnicodeCharacter
% I had to cut because of size limit in answers
% Up to the following one
\xutfsym@declare{27BF}{\usym{27BF}}
\endinput
测试
pdflatex
现在,您可以尝试使用或来输入以下文件xelatex
。
\documentclass{article}
\usepackage{xutfsym}
\begin{document}
♠
答案3
使用最新版本,可在以下网址找到https://gitlab.com/gi-fg-ibnw/utfsym。