提问于:
浏览数:
3052
# 系统识别功能在windows下无法通过编译
因为在不同操作系统中字体文件名不一样,设置字体时根据不同系统有不同写法。
自己写cls的时候想根据不同系统使用不同的字体设置代码。在cls文件写了:
```Tex
%在spaexp.cls文件中
%Identifications
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesClass{spaexp}
[2020/02/21 SPA physics experiment template non-official edition v1.0 ]
%% Loading Class
\LoadClass[a4paper,no-math,zihao = -4]{ctexart}
%%%设置字体
\ctexset{
punct = banjiao%使用半角标点符号
}
\newif\ifmcm@mac %(代码参考https://github.com/OsbertWang/GMCMthesis 这个是OsbertWang,修正支持让各个系统自适应支持近似字体。)
\newif\ifmcm@windows % 简单设置会有 warning, 待完善吧。
% \newif\ifmcm@fandol
\@ifclasslater{ctexart}{}{
\newcommand\mcm@strifeq{\csname str_if_eq_x:nnTF\endcsname}
\newcommand\mcm@fontset{\csname g__ctex_fontset_tl\endcsname}
\mcm@strifeq{\mcm@fontset}{mac}{\mcm@mactrue}{}
\mcm@strifeq{\mcm@fontset}{windows}{\mcm@windowstrue}{}
% \mcm@strifeq{\mcm@fontset}{fandol}{\mcm@fandoltrue}{}
}{
\mcm@windowstrue
}
\setmainfont{Times New Roman}
\setsansfont{Arial}
\ifmcm@mac
\setmonofont[Scale=MatchLowercase]{Menlo}
\setCJKmainfont[BoldFont = {Songti SC Black}]{Songti SC} %MacOS: 中文字体使用宋体
\else
\ifmcm@windows
\setmonofont[Scale=MatchLowercase]{Courier New}
\setCJKmainfont{simsun.ttc} %Windows: 中文字体使用宋体
\fi
\fi
```
```Tex
%在a.tex文件中
\documentclass{spaexp}
\begin{document}
hello
\end{document}
```
在Windows下使用此模版进行编译时出现编译不通过。
出现报错(报错只截取了我认为有关的部分)
```log
File: ctex.cfg 2019/05/29 v2.4.16 Configuration file (CTEX)
)
./spaexp.cls:27: Undefined control sequence.
\LaTeX3 error:
'\str_if_eq_x:nnTF' deprecated on 2020-01-01. Use...
l.27 }
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
./spaexp.cls:27: LaTeX Error: Missing \begin{document}.
See the LaTeX manual or LaTeX Companion for explanation.
Type H for immediate help.
...
l.27 }
You're in trouble here. Try typing to proceed.
If that doesn't work, type X to quit.
./spaexp.cls:27: Undefined control sequence.
\LaTeX3 error:
'\str_if_eq_x:nnTF' deprecated on 2020-01-01. Use...
l.27 }
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
```
这种情况在Macox中不会出现,请问需要怎么处理呢?