我正在将我的代码从 pdflatex 转换为 XeLaTeX
最小情况
\documentclass{article}
\usepackage{polyglossia} % also loads package fontspec
\setmainfont{Minion Pro} % or whatever OTF you have on your system
\setmainlanguage{english} % loads language hyphenation rules and such
\usepackage{unicode-math} % if you also need maths
\setmathfont{Cambria Math} % or whatever math OTF you have on your
% Problem with these declarations which I like to use
\DeclarePairedDelimiter{\abs}{\lvert}{\rvert}
\DeclarePairedDelimiter{\norm}{\lVert}{\rVert}
\begin{document}
\begin{equation}
\norm{x} + \abs{y} = 1
\end{equation}
\end{document}
我以前
% \usepackage{amsmath, amsfonts, amssymb, textcomp, mathtools, xparse}
% \usepackage[T4, OT1]{fontenc}
在 XeLaTeX 中这些声明的正确方法是什么?
Egreg 面临的一些挑战方法
示例数据
\begin{equation}
\norm{x} + \abs{y} = 1 is \norm{x} + \abs{y} = 1 \square.
\end{equation}
我可以通过这个解决这些错误
\usepackage{mathtools, xparse} % load mathtools before loading fontspec
% amsmath never needed with mathtools
\usepackage{amsfonts, amssymb, textcomp} % not sure if these are necessary
% https://tex.stackexchange.com/a/213430/13173
\usepackage{polyglossia} % also loads package fontspec
\setmainfont{Minion Pro} % or whatever OTF you have on your system
\setmainlanguage{english} % loads language hyphenation rules and such
\usepackage{unicode-math} % if you also need maths
\setmathfont{Cambria Math} % or whatever math OTF you have on your system
我无法理解哪个包是关键包。我认为xparse
是需要的,但当将此包与 Egreg 的代码一起使用时,它无法解决 square-symbol 挑战。
答案1
该命令\DeclarePairedDelimiter
由 定义mathtools
。由于此包也加载,amsmath
因此必须前 fontspec
:
\documentclass{article}
\usepackage{mathtools}
\usepackage{polyglossia} % also loads package fontspec
\usepackage{unicode-math} % if you also need maths
\setmainlanguage{english} % loads language hyphenation rules and such
\setmainfont{Minion Pro} % or whatever OTF you have on your system
\setmathfont{Cambria Math} % or whatever math OTF you have on your
% Problem with these declarations which I like to use
\DeclarePairedDelimiter{\abs}{\lvert}{\rvert}
\DeclarePairedDelimiter{\norm}{\lVert}{\rVert}
\begin{document}
\begin{equation}
\norm{x} + \abs{y} = 1
\end{equation}
\end{document}
答案2
关于 的额外问题\square
。我没有 Minion Pro,但是注释掉两\setm...
行字体并添加amssymb
,然后使用 编译就好了xelatex
\documentclass{article}
\usepackage{mathtools,amssymb}
\usepackage{polyglossia} % also loads package fontspec
\usepackage{unicode-math} % if you also need maths
\setmainlanguage{english} % loads language hyphenation rules and such
%\setmainfont{Minion Pro} % or whatever OTF you have on your system
%\setmathfont{Cambria Math} % or whatever math OTF you have on your
% Problem with these declarations which I like to use
\DeclarePairedDelimiter{\abs}{\lvert}{\rvert}
\DeclarePairedDelimiter{\norm}{\lVert}{\rVert}
\begin{document}
\begin{equation}
\norm{x} + \abs{y} = 1 \square
\end{equation}
\end{document}