更改特定命令的字體

更改特定命令的字體

我想更改與\mathcalto專門關聯的字體cambria而不是預設字體,而不更改文件的其餘部分。

我該怎麼做呢?我不介意設定一個newcommand既調用字體又mathcal調用字體的字體,但我不希望它周圍的文字從預設設定的任何數學字體中更改字體。

謝謝

編輯:根據要求,我只想生成此線程中討論的內容: 如何在 LaTeX 中表示 Word 中的這些符號?不改變整個文件的字體,即cambria字體應該只對命令有效\mathcal

我的想法是,必須有一種方法可以合併,\newcommand以便設定一個新命令,該命令能夠起到類似的作用\mathcal,但也可以將字體更改為cambria.

編輯 2:對於可能正在使用的人,pdflatex您需要切換到 XeLaTeX 或 LuaLaTeX 並在序言中添加以下行,以便數學字體與pdflatexwith中的幾乎相同cambria \mathcal

%In Texmaker change the options for quickbuild to XeLaTeX + View PDF or LuaLaTeX + View PDF 
\documentclass{article}
\usepackage{unicode-math}
\setmathfont{Latin Modern Math}
\setmathfont{Cambria Math}[range=\mathcal]
\renewcommand{\boldsymbol}[1]{\symbfit{#1}} %You can continue to use \boldsymbol.
\let\mathbb\relax
\DeclareMathAlphabet{\mathbb}{U}{msb}{m}{n}
\begin{document}
%Document info
\end{document}

答案1

我認為 Cambria 不適用於pdflatex.這是 XeLaTeX 或 LuaLaTeX 的簡單設定。

\documentclass{article}
\usepackage{unicode-math}

\setmathfont{Latin Modern Math}% or whatever
\setmathfont{Cambria Math}[range=\mathcal]

\begin{document}

$a+b\in\mathcal{C}$

$
\mathcal{A}
\mathcal{B}
\mathcal{C}
\mathcal{D}
\mathcal{E}
\mathcal{F}
\mathcal{G}
$

\end{document}

在此輸入影像描述

相關內容