我正在使用支持 MikTeX 的 WinEdt 10.2 撰写博士论文。我的论文需要包含带有中文字体的封面。大学论文类包含所有定义。当我编译主文本文件时,它出现错误:
几何学驱动程序:自动检测
几何学检测到的驱动程序:pdftex
(主输出)(主输出)
! 包 CJK 错误:无效的字符代码。
请参阅 CJK 包文档以获取解释。
输入 H 可立即获得帮助。...
l.114
\makeCoverPage
?进程已终止...
我在 tex 文件中加入了必要的 CJK 包。之前,它运行良好。上周,我尝试安装 TeX Live,但安装时间太长。之后又出现了这个问题。我删除了 TeX Live 2023,但问题仍然存在。可能是 Tex Live 从我的电脑中删除了一些必要的文件。
如果我不在主 tex 文件中包括 CJK 包,则会出现以下错误:
缺少字符:字体 ptmr7t 中没有·!
! 包 CJK 错误:无效的字符代码。
Main.tex 文件是:
\expandafter\def\csname CTEX@spaceChar\endcsname{\hspace{1em}}
\expandafter\def\csname [email protected]\endcsname{}
\documentclass[oneside]{ZJUthesis}
\usepackage{psfrag}
\usepackage{subcaption}
\usepackage{algorithm}
\usepackage{algorithmic}
\usepackage{bbm}
\usepackage[english]{babel}
\usepackage[toc,page]{appendix}
\usepackage{fullpage}
\usepackage{amsfonts,amsthm,amsmath,mathrsfs,amssymb}
\usepackage{subeqnarray}
%\usepackage{booktabs}
\usepackage{ctex}
\usepackage{longtable}
\usepackage{epstopdf,epsfig}
\usepackage{cite}
\usepackage{url}
%\usepackage[utf8]{inputenc}
%\usepackage{CJKutf8}
%\usepackage{CJK,CJKnumb}
%\usepackage[T1]{fontenc}
\usepackage{nomencl}
\let\abbrev\nomenclature
\renewcommand{\nomname}{List of Abbreviations}
\setlength{\nomlabelwidth}{.25\hsize}
\renewcommand{\nomlabel}[1]{#1 \dotfill}
\setlength{\nomitemsep}{-\parsep}
\makenomenclature
\newcommand{\Abkuerzung}{
\printnomenclature
\newpage
}
\newcommand{\zht}[1]{\begin{CJK}{UTF8}{bsmi}#1\end{CJK}}
\newcommand{\zhs}[1]{\begin{CJK}{UTF8}{gbsn}#1\end{CJK}}
\newcommand{\zh}[4]{\zht{#1}/\zhs{#2} (\emph{#3}) ``#4''}
\numberwithin{equation}{chapter}
\numberwithin{algorithm}{chapter}
\hypersetup{colorlinks=false}
\begin{document}
\fangsong
%\zihao{-4}
\classification{}
\serialnumber{}
\PersonalID{}
\Etitle{}
\Etitletl}
\author{}
\degree{}
\submitdate{2023.7}
\defenddate{2023.9}
\makeCoverPage
\reviewersA{}
\reviewersB{}
\reviewersC{}
\reviewersD{}
\reviewersE{}
\chairman{}
\commissionerA{}
\commissionerB{}
\commissionerC{}
\commissionerD{}
\maketitle
\englishtitle{}
\englishtitletl{}
\EreviewersA{Anonymous}
\EreviewersB{Anonymous}
\EreviewersC{Anonymous}
\EreviewersD{Anonymous}
\EreviewersE{Anonymous}
\Echairman{}
\EcommissionerA{}
\EcommissionerB{}
\EcommissionerC{}
\EcommissionerD{}
\makeenglishtitle
\SignautreDateA{}{}{}
\SignautreDateB{}{}{}
\SignautreDateC{}{}{}
\makeOSandCPRTpage
\ZJUfrontmatter
\input{./Chapters/Thanks}
\input{./Chapters/AbstractC}
\input{./Chapters/AbstractE}
\ZJUListofFigures
\ZJUListofTables
\input{./Chapters/Abbreviations}
\ZJUcontents
\ZJUmainmatter
\input{./Chapters/Chapter1}
\ZJUbackmatter
\appendix
\input{./Chapters/Appendix}
\ZJUindex
\input{./Chapters/PublicationList}
\end{document}
%*******************************
还附上了ZJUthesis.cls供您参考。
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesClass{ZJUthesis}[2013/01/25 v2.0 ZJUthesis document class]
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{ctexart}}
\ProcessOptions
\LoadClass[cs4size,a4paper,fancyhdr,hyperref]{ctexbook}[2009/09/13]
\RequirePackage{amsmath,amsthm,amsfonts,amssymb,bm}
\RequirePackage{graphicx}
\RequirePackage{times}
%\RequirePackage{fontspec}
\RequirePackage{array}
\RequirePackage[titles, subfigure]{tocloft}
\RequirePackage[chapter]{tocbibind}
\RequirePackage{makeidx}
\RequirePackage[sort&compress,longnamesfirst,square,numbers]{natbib}
\RequirePackage[margin=10pt,font={small,bf},labelsep=quad]{caption}
\RequirePackage{booktabs}
\RequirePackage{calc}
\RequirePackage{multirow}
\RequirePackage{xcolor}
\hypersetup{CJKbookmarks=true,%
bookmarksnumbered,%
linkcolor=blue,%
plainpages=false,%
pdfstartview=FitH,
hidelinks
}
\AtBeginDocument{\makeatletter\input{ZJUthesis.cfg}\makeatother}
\RequirePackage[a4paper,%
top=51pt,bottom=51pt,left=68pt,right=57pt,%
headsep=14pt,footskip=26pt,%
footnotesep=10.8pt plus 1fil minus 2.0pt,%
includehead, includefoot]{geometry}
\RequirePackage{subfigure}
\RequirePackage{upgreek}
\RequirePackage{enumerate}
%\oddsidemargin -0.14 true cm
% ż��ҳ�����߾���������˫��ģʽ�뵥��ģʽ��������
%\if@twoside
% \evensidemargin -0.34 true cm
%\else
% \evensidemargin -0.14 true cm
%\fi
% ����ҳͷ�հ׳ߴ�
%\topmargin -0.74 true cm
%\headheight 0.8 true cm
%\headsep 0.5 true cm
\topsep 0.7 true cm
%\textheight 23.9 true cm
%\textwidth 16.6 true cm
%\footskip 0.9 true cm
\parskip 0.5ex plus 0.25ex minus 0.25ex
% cleardoublepage���������Ķ���
\def\cleardoublepage{%
\clearpage
\if@twoside
\ifodd
\c@page
\else
\thispagestyle{empty}%
\hbox{}\newpage
\if@twocolumn
\hbox{}\newpage
\fi
\fi
\fi}
\renewcommand{\textfraction}{0.15}
\renewcommand{\topfraction}{0.85}
\renewcommand{\bottomfraction}{0.65}
\renewcommand{\floatpagefraction}{0.60}
%\setmainfont{Times New Roman}
\renewcommand{\thetable}{\arabic{chapter}-\arabic{table}}
\renewcommand{\theequation}{\arabic{chapter}-\arabic{equation}}
\renewcommand{\thefigure}{\arabic{chapter}-\arabic{figure}}
\newcommand\ZJUspace{\protect\CTEX@spaceChar\protect\CTEX@spaceChar}
\def\reserved@a#1 #2 #3\@nil{%
\def\ZJUfiledate{#1}%
\def\ZJUfileversion{#2}%
\def\ZJUfileinfo{#3}}%
\edef\reserved@b{\csname [email protected]\endcsname}
\expandafter\reserved@a\reserved@b\@nil\relax
% ������Nchapter�Ķ���
% ������mainmatter��Ӧ��tex�ĵ��еĶ���
\newcommand\Nchapter[1]{%
\if@mainmatter%
\@mainmatterfalse%
\chapter{#1}%
\@mainmattertrue%
\else
\chapter{#1}%
\fi}
\def\ZJU@underline[#1]#2{%
\underline{\hbox to #1{\hfil#2\hfil}}}
\def\ZJUunderline{\@ifnextchar[\ZJU@underline\underline}
\newcommand\classification[1]{\def\ZJU@value@classification{#1}}
\newcommand\confidential[1]{\def\ZJU@value@confidential{#1}}
\newcommand\UDC[1]{\def\ZJU@value@UDC{#1}}
\newcommand\serialnumber[1]{\def\ZJU@value@serialnumber{#1}}
\newcommand\school[1]{\def\ZJU@value@school{#1}}
\newcommand\SecretLevel[1]{%
\def\ZJU@value@SecretLevel{#1}
\def\ZJU@value@IsSecret{1}}
\newcommand\PersonalID[1]{\def\ZJU@value@PersonalID{#1}}
\newcommand\degree[1]{\def\ZJU@value@degree{#1}}
\renewcommand\title[2][\ZJU@value@title]{%
\def\ZJU@value@title{#2}
\def\ZJU@value@titlemark{\MakeUppercase{#1}}}
\newcommand\titletl[1]{\def\ZJU@value@titletl{#1}}
\newcommand\Etitle[1]{\def\ZJU@value@Etitle{#1}}
\newcommand\Etitletl[1]{\def\ZJU@value@Etitletl{#1}}
\newcommand\EtitletB[1]{\def\ZJU@value@EtitletB{#1}}
\renewcommand\author[1]{\def\ZJU@value@author{#1}}
\newcommand\supervisor[1]{\def\ZJU@value@supervisor{#1}}
\newcommand\cpsupervisor[1]{\def\ZJU@value@cpsupervisor{#1}}
\newcommand\supervisorinstitute[1]{\def\ZJU@value@supervisorinstitute{#1}}
\newcommand\major[1]{\def\ZJU@value@major{#1}}
\newcommand\researchdm[1]{\def\ZJU@value@researchdm{#1}}
\newcommand\submitdate[1]{\def\ZJU@value@submitdate{#1}}
\newcommand\defenddate[1]{\def\ZJU@value@defenddate{#1}}
\newcommand\defenddateE[1]{\def\ZJU@value@defenddateE{#1}}
\newcommand\institute[1]{\def\ZJU@value@institute{#1}}
\newcommand\chairman[1]{\def\ZJU@value@chairman{#1}}
\newcommand\commissionerA[1]{\def\ZJU@value@commissionerA{#1}}
\newcommand\commissionerB[1]{\def\ZJU@value@commissionerB{#1}}
\newcommand\commissionerC[1]{\def\ZJU@value@commissionerC{#1}}
\newcommand\commissionerD[1]{\def\ZJU@value@commissionerD{#1}}
%\newcommand\commissionerE[1]{\def\ZJU@value@commissionerE{#1}}
\newcommand\reviewersA[1]{\def\ZJU@value@reviewersA{#1}}
\newcommand\reviewersB[1]{\def\ZJU@value@reviewersB{#1}}
\newcommand\reviewersC[1]{\def\ZJU@value@reviewersC{#1}}
\newcommand\reviewersD[1]{\def\ZJU@value@reviewersD{#1}}
\newcommand\reviewersE[1]{\def\ZJU@value@reviewersE{#1}}
\newcommand\SignautreDateA[3]{%
\def\ZJU@value@signaturedateAy{#1}
\def\ZJU@value@signaturedateAm{#2}
\def\ZJU@value@signaturedateAd{#3}}
\newcommand\SignautreDateB[3]{%
\def\ZJU@value@signaturedateBy{#1}
\def\ZJU@value@signaturedateBm{#2}
\def\ZJU@value@signaturedateBd{#3}}
\newcommand\SignautreDateC[3]{%
\def\ZJU@value@signaturedateCy{#1}
\def\ZJU@value@signaturedateCm{#2}
\def\ZJU@value@signaturedateCd{#3}}
\newcommand\PutsigndateA{%
ǩ�����ڣ�{\includegraphics[width=40pt,height=20pt]{./Signature/2022.pdf}}��
{\includegraphics[width=20pt,height=20pt]{./Signature/6.pdf}}��
{\includegraphics[width=20pt,height=20pt]{./Signature/7.pdf}}��
}
\newcommand\PutsigndateB{%
ǩ�����ڣ�{\includegraphics[width=40pt,height=20pt]{./Signature/2022.pdf}}��
{\includegraphics[width=20pt,height=20pt]{./Signature/6.pdf}}��
{\includegraphics[width=20pt,height=20pt]{./Signature/7.pdf}}��
}
\newcommand\PutsigndateC{%
ǩ�����ڣ�{\includegraphics[width=40pt,height=20pt]{./Signature/2022.pdf}}��
{\includegraphics[width=20pt,height=20pt]{./Signature/6.pdf}}��
{\includegraphics[width=20pt,height=20pt]{./Signature/7.pdf}}��
}
% ��������������
\newcommand\makeCoverPage{%
% �����ط�д���Ƿ����ϵķ�������ѧ�ţ������ֺſ��Ը���
\pagenumbering{alph}
\cleardoublepage
\thispagestyle{empty}
{
\songti\zihao{-4}
\linespread{1.3}
\begin{center}
{\hspace{2em}
\ZJU@label@classification~
\ZJUunderline[90pt]{\ZJU@value@classification}
\hfill
\ZJU@label@serialnumber~
\ZJUunderline[60pt]{\ZJU@value@serialnumber} \\
\vspace{3pt}
\ifx\ZJU@value@IsSecret\undefined
\else
\hspace{2em}
\ZJU@label@SecretLevel~
\ZJUunderline[90pt]{\ZJU@value@SecretLevel}
\fi
\hfill
\ZJU@label@PersonalID~
\ZJUunderline[60pt]{\ZJU@value@PersonalID}\\
}
% �����ߴ����Ը���
\vspace{10mm}
% �㽭��ѧ�ĸ���
\ifpdf
\includegraphics[width=60.3mm]{./CoverPagepic/ZJDX.pdf} \\
\else
\includegraphics[width=60.3mm]{./CoverPagepic/ZJDX.eps} \\
\fi
% �����ߴ����Ը���
\vspace{4mm}
%% \ZJU@value@school \\ \zihao{-1}
% ������ʿѧλ������def�ļ������У���Ȼ��tex�ļ��л����Ը���
\centerline{\songti \zihao{-1}{\ZJU@value@degree\ZJU@label@thesis} }
% �����ߴ����Ը���
\vspace{4mm}
% �����ط����������ձ�
\ifpdf
\includegraphics[width=22.8mm]{./CoverPagepic/QSY.pdf} \\
\else
\includegraphics[width=22.8mm]{./CoverPagepic/QSY.eps} \\
\fi
\end{center}
\vspace{2mm}
\begin{center}
% ������Ŀ�������ݣ�������
\begin{tabular}{rl}
{\bfseries\fangsong\zihao{3}\ZJU@label@title:}
&
\bfseries\fangsong\zihao{-2} \ZJUunderline[260pt]{\ZJU@value@title} \\[3mm]
&
% �����ط������ڶ��б������жϣ���������һ��д���£��еڶ�������ʾ����������ʾ
\ifx\ZJU@value@titletl\undefined
\hfil
\else
{\bfseries\fangsong\zihao{-2}\ZJUunderline[260pt]{\ZJU@value@titletl}}
\fi \\[4mm]
{\bfseries\fangsong\zihao{3}\ZJU@label@Etitle:}
&
{\bf\zihao{-3}\ZJUunderline[300pt]{\ZJU@value@Etitle}}\\[3mm]
&
%ͬ����Ӣ�ı����Ķ����жϣ�����һ��д���£��еڶ�����ʾ����������ʾ�ڶ���
\ifx\ZJU@value@Etitletl\undefined
\hfil
\else
{\bf\zihao{-3}\ZJUunderline[300pt]{\ZJU@value@Etitletl}}
\fi\\[2mm]
&
\ifx\ZJU@value@EtitletB\undefined
\hfil
\else
{\bf\zihao{-3}\ZJUunderline[300pt]{\ZJU@value@EtitletB}}
\fi\\
\end{tabular}
% ��������������
\vspace{6mm}
% �����������岻ͬ������������AB���
答案1
由于您没有提供 MWE,我将提供针对中文文档的解决方案供您参考。
我使用\documentclass{ctexbook}
的基本上是中文\documentclass{book}
。您可以切换到ctexart
冠词等。无需明确包含 CJK。
ctex 类强制您在 XeLaTeX 中进行编译。tex 文件应采用 UTF-8 编码。
我使用 TeXLive。无论出于什么原因,如果你无法安装它,那么你还有一些其他选择。
- 使用在线服务,例如 Overleaf 或其中文对应产品 TeXPage。请注意,它们有运行时间限制,如果您的论文中包含大量图表,则可能会超出该限制,在这种情况下您需要支付额外费用。GitHub 工作流程对单个编译的时间上限要长得多。它确实有一个月 2000 分钟的上限,但这应该足够长了。
- 卸载并重新安装 MikTeX。