Unverified Commit 697bc6b8 authored by liziwl's avatar liziwl Committed by GitHub
Browse files

Merge pull request #49 from SUSTech-CRA/feat/add-math-style

加入 math style 选项
parents 8ef24914 8d16921a
Loading
Loading
Loading
Loading
+12 −7
Original line number Diff line number Diff line
@@ -137,19 +137,24 @@

\section{数学字体}

按照《撰写规范》全文统一采用 Xits Math 或 Cambria Math 中一种字体作为表达式字体即可
按照《撰写规范》全文统一采用 Cambria Math (MS Word默认字体)或 Xits Math 中一种字体作为表达式字体即可。Cambria Math 缺少部分样式,例如:积分符号设定为 upright 也看起来没有变化

Cambria Math 字体样例:

\thusetup{math-font = cambria}
\makeatletter
\thu@load@math@font@cambria
\begin{equation}
  f(x)=a_0+ \sum_{n=1}^{\infty}   \left(  a_n\ \cos \frac{n\pi x}{L} +b_n  \sin\frac{n\pi x}{L}   \right)
  \frac{1}{2 \uppi \symup{i}} \int_\gamma f = \sum_{k=1}^m n(\gamma; a_k) \mathscr{R}(f; a_k)
  \label{eq:example}
\end{equation}
\makeatother

Xits Math 字体样例:
\thusetup{math-font = xits}
\makeatletter
\thu@load@math@font@xits
\begin{equation}
  f(x)=a_0+ \sum_{n=1}^{\infty}   \left(  a_n\ \cos \frac{n\pi x}{L} +b_n  \sin\frac{n\pi x}{L}   \right)
  \frac{1}{2 \uppi \symup{i}} \int_\gamma f = \sum_{k=1}^m n(\gamma; a_k) \mathscr{R}(f; a_k)
  \label{eq:example}
\end{equation}

\thusetup{math-font = cambria}
\thu@load@math@font@cambria
\makeatother
+7 −0
Original line number Diff line number Diff line
@@ -84,6 +84,13 @@
  intclassifiedindex={xx-x},
}

\thusetup{
  %
  % 数学字体
  % math-style = GB,  % GB (中文默认) | TeX (英文默认)
  math-font  = cambria,  % cambria (默认,同 Word 默认数学字体一致) | xits (TeX 内常用数学字体)
}

% 载入所需的宏包

% 可以使用 nomencl 生成符号和缩略语说明
+1 −3
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@
% !TeX program = xelatex
% !TeX spellcheck = en_US

\documentclass[degree=master,language=chinese,cjk-font=external,math-font=cambria]{sustechthesis}
\documentclass[degree=master,language=chinese,cjk-font=external]{sustechthesis}
  % 学位 degree:
  %   master (默认) | doctor
  % 语言 language:
@@ -12,8 +12,6 @@
  %   在 **非Windows** 的系统上推荐使用包内字体,而非系统字体。
  %   以达到和 Windows 系统上显示的字体效果。
  %   Windows 系统上可以删除该参数,使用系统内置字体。
  % 数学字体 math-font
  %   cambria (默认,同 Word 默认数学字体一致) | xits (TeX 内常用数学字体) 等。


% 论文基本配置,加载宏包等全局配置
+111 −61
Original line number Diff line number Diff line
@@ -687,6 +687,15 @@
%   \item 微分号和积分号使用使用正体,比如 $\int f(x) \dif x$。
% \end{enumerate}
%
% \DescribeOption{math-style}
% 用户可以通过设置 \option{math-style} 选择数学符号样式(可选:
% \option{GB}(中文默认),\option{TeX}(英文默认)),比如:
% \begin{latex}
%   \thusetup{
%     math-style = GB,
%   }
% \end{latex}
%
% 关于数学符号更多的用法,参考
% \href{http://mirrors.ctan.org/macros/latex/contrib/unicode-math/unicode-math.pdf}{\pkg{unicode-math}}
% 宏包的使用说明,
@@ -1154,9 +1163,6 @@
    choices = {
      times,
      termes,
      xits,
      libertinus,
      lm,
      auto,
      none,
    },
@@ -1181,12 +1187,17 @@
      cambria,
      xits,
      stix,
      libertinus,
      lm,
      none,
    },
    default = cambria,
  },
  math-style = {
    name = math@style,
    choices = {
      GB,
      TeX,
    },
  },
%    \end{macrocode}
%
% 选择打印版还是用于上传的电子版。
@@ -1709,20 +1720,21 @@
%
% 使用 \pkg{unicode-math} 配置数学字体
%    \begin{macrocode}
\unimathsetup{
  math-style = TeX,
  bold-style = TeX,
}
\ifthu@language@chinese
  \unimathsetup{
    math-style = ISO,
    bold-style = ISO,
    nabla      = upright,
    partial    = upright,
  }
  \thusetup{math-style=GB}%
\else
  \thusetup{math-style=TeX}%
\fi
\newcommand\thu@xits@integral@stylistic@set{%
\thu@option@hook{language}{%
  \ifthu@language@chinese
    \thusetup{math-style=GB}%
  \else
    \thusetup{math-style=TeX}%
  \fi
}
\newcommand\thu@xits@integral@stylistic@set{%
  %\ifthu@language@english
  \ifthu@math@style@GB
    8%upright
  \fi
}
@@ -1760,11 +1772,6 @@
\newcommand\thu@load@math@font@cambria{%
  \setmathfont[Path = "fonts/"]{CambriaMath.otf}%
}
\newcommand\thu@load@math@font{%
  \@nameuse{thu@load@math@font@\thu@math@font}
}
\thu@load@math@font
\thu@option@hook{math-font}{\thu@load@math@font}
%    \end{macrocode}
%
% 中文字体
@@ -2461,16 +2468,16 @@
% 省略号一律居中,所以 \cs{ldots} 不再居于底部。
%    \begin{macrocode}
\newcommand\thu@set@math@ellipsis{%
  \ifthu@language@chinese
  \AtBeginDocument{%
    \ifthu@math@style@GB
      \DeclareRobustCommand\mathellipsis{\mathinner{\unicodecdots}}%
    \else
    \ifthu@language@english
      \ifthu@math@style@TeX
        \DeclareRobustCommand\mathellipsis{\mathinner{\unicodeellipsis}}%
      \fi
    \fi
  }
\thu@set@math@ellipsis
\thu@option@hook{language}{\thu@set@math@ellipsis}
}
%    \end{macrocode}
% \end{macro}
%
@@ -2480,14 +2487,16 @@
% \begin{macro}{\geq}
% 小于等于号要使用倾斜的形式,仅中文生效。
%    \begin{macrocode}
\ifthu@language@chinese
\newcommand\thu@set@math@leq{%
  \AtBeginDocument{%
    \ifthu@math@style@GB
      \protected\def\le{\leqslant}
      \protected\def\ge{\geqslant}
  \AtBeginDocument{%
      \renewcommand\leq{\leqslant}%
      \renewcommand\geq{\geqslant}%
  }
    \fi
  }
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
@@ -2497,7 +2506,9 @@
% \begin{macro}{\int}
% 积分号 \cs{int} 使用正体,并且上下限默认置于积分号上下两侧。
%    \begin{macrocode}
\ifthu@language@chinese
\newcommand\thu@set@unimath@integral@limits{
  \AtBeginDocument{%
    \ifthu@math@style@GB
      \removenolimits{%
        \int\iint\iiint\iiiint\oint\oiint\oiiint
        \intclockwise\varointclockwise\ointctrclockwise\sumint
@@ -2506,6 +2517,7 @@
        \intcap\intcup\upint\lowint
      }%
    \else
      \ifthu@math@style@TeX
        \addnolimits{%
          \int\iint\iiint\iiiint\oint\oiint\oiiint
          \intclockwise\varointclockwise\ointctrclockwise\sumint
@@ -2514,6 +2526,10 @@
          \intcap\intcup\upint\lowint
        }%
      \fi
    \fi
  }
}

%    \end{macrocode}
% \end{macro}
%
@@ -2522,12 +2538,14 @@
% 实部、虚部操作符使用罗马体 $\mathrm{Re}$、$\mathrm{Im}$ 而不是 fraktur 体
% $\Re$、$\Im$。
%    \begin{macrocode}
\newcommand\thu@set@unimath@real@part{%
  \AtBeginDocument{%
  \ifthu@language@chinese
    \ifthu@math@style@GB
      \renewcommand{\Re}{\operatorname{Re}}%
      \renewcommand{\Im}{\operatorname{Im}}%
    \fi
  }
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
@@ -2535,14 +2553,46 @@
% \begin{macro}{\nabla}
% \cs{nabla} 使用粗正体。
%    \begin{macrocode}
\newcommand\thu@set@unimath@nabla{
  \AtBeginDocument{%
  \ifthu@language@chinese
    \ifthu@math@style@GB
      \renewcommand\nabla{\mbfnabla}%
    \fi
  }
}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
\newcommand\thu@set@unimath@style{%
  \thu@set@math@ellipsis
  \thu@set@math@leq
  \thu@set@unimath@integral@limits
  \thu@set@unimath@real@part
  \thu@set@unimath@nabla
}
\newcommand\thu@load@math@font{%
  \AtBeginDocument{%
    \unimathsetup{
      math-style = TeX,
      bold-style = TeX,
    }
    \ifthu@math@style@GB
      \unimathsetup{
        math-style = ISO,
        bold-style = ISO,
        nabla      = upright,
        partial    = upright,
      }
    \fi
    \@nameuse{thu@load@math@font@\thu@math@font}
  }
  \thu@set@unimath@style
}
\thu@load@math@font
\thu@option@hook{math-font}{\thu@load@math@font}
%    \end{macrocode}
%
% \begin{macro}{\bm}
% \begin{macro}{\boldsymbol}
% 兼容旧的粗体命令:\pkg{bm} 的 \cs{bm} 和 \pkg{amsmath} 的 \cs{boldsymbol}。