在生成的PDF中,希望目录中的abstract的页码正确

2019-12-06 10:38发布

我在用别人写的模板写毕业论文,生成的PDF文件中,目录里英文摘要abstract的页码不正确,希望能显示正确的页码! 以下为MWE.tex文件的代码: \documentclass[format=d...

我在用别人写的模板写毕业论文,生成的PDF文件中,目录里英文摘要abstract的页码不正确,希望能显示正确的页码! 以下为MWE.tex文件的代码: \documentclass[format=draft,language=chinese,degree=phd]{MWE} \zhabstract{ 这这是一个\LaTeX{}模板使用实例文件 } \enabstract { This is a \LaTeX{} template example file } \begin{document} \frontmatter \makeabstract \tableofcontents \end{document} \endinput 以下为MWE.cls文件的代码: \RequirePackage{ifthen} \RequirePackage{xkeyval} \newif\ifHUST@finalformat \HUST@finalformattrue \DeclareOptionX{format}[final]{ \ifthenelse{\equal{#1}{final}}{ \HUST@finalformattrue }{ \ifthenelse{\equal{#1}{draft}}{ \HUST@finalformatfalse }{ \ClassError{hustthesis} {Option format can only be 'final' or 'draft'} {Try to remove option format^^J} } } } \gdef\HUST@language{chinese} \DeclareOptionX{language}[chinese]{ \ifthenelse{\equal{#1}{chinese} \OR \equal{#1}{english} \OR \equal{#1}{english-draft}}{ \gdef\HUST@language{#1} }{ \ClassError{hustthesis} {Option language can only be 'chinese', 'english' or 'english-draft'} {Try to remove option language^^J} } } \DeclareOption*{\PassOptionsToClass{\CurrentOption}{book}} \ProcessOptionsX \LoadClass[12pt, a4paper, openany]{book} \RequirePackage{iftex} \ifXeTeX\else \ifLuaTeX\else \begingroup \errorcontextlines=-1\relax \newlinechar=10\relax \errmessage{^^J *******************************************************^^J * XeTeX or LuaTeX is required to compile this document.^^J * Sorry!^^J *******************************************************^^J }% \endgroup \fi \fi \ifthenelse{\equal{\HUST@language}{english-draft}}{ \RequirePackage{fontspec} \setmainfont[ Ligatures={Common,TeX}, Extension=.otf, UprightFont=*-regular, BoldFont=*-bold, ItalicFont=*-italic, BoldItalicFont=*-bolditalic]{texgyretermes} \setsansfont[Ligatures={Common,TeX}]{Droid Sans} \setmonofont{CMU Typewriter Text} \defaultfontfeatures{Mapping=tex-text} \let\HEI\relax \let\KAI\relax \let\FANGSONG\relax \newcommand{\hei}[1]{#1} \newcommand{\kai}[1]{#1} \newcommand{\fangsong}[1]{#1} }{} \ifthenelse{\equal{\HUST@language}{english-draft}}{}{ \ifXeTeX % XeTeX下使用fontspec + xeCJK处理字体 % 英文字体 \RequirePackage{fontspec} \RequirePackage{xunicode} \setmainfont[ Ligatures={Common,TeX}, Extension=.otf, UprightFont=*-regular, BoldFont=*-bold, ItalicFont=*-italic, BoldItalicFont=*-bolditalic]{texgyretermes} \setsansfont[Ligatures={Common,TeX}]{Droid Sans} \setmonofont{CMU Typewriter Text} \defaultfontfeatures{Mapping=tex-text} % 中文字体 \RequirePackage[CJKmath]{xeCJK} \setCJKmainfont[ BoldFont={Adobe Heiti Std}, ItalicFont={Adobe Kaiti Std}]{Adobe Song Std} \setCJKsansfont{Adobe Kaiti Std} \setCJKmonofont{Adobe Fangsong Std} \xeCJKsetup{PunctStyle=kaiming} \newcommand\ziju[2]{{\renewcommand{\CJKglue}{\hskip #1} #2}} \newCJKfontfamily\HEI{Adobe Heiti Std} \newCJKfontfamily\KAI{Adobe Kaiti Std} \newCJKfontfamily\FANGSONG{Adobe Fangsong Std} \newcommand{\hei}[1]{{\HEI #1}} \newcommand{\kai}[1]{{\KAI #1}} \newcommand{\fangsong}[1]{{\FANGSONG #1}} \else\fi \ifLuaTeX % LuaTeX下使用luatex-ja处理字体 [推荐] \RequirePackage{luatexja-fontspec} % 英文字体 \setmainfont[Ligatures={Common,TeX}]{Tex Gyre Termes} \setsansfont[Ligatures={Common,TeX}]{Droid Sans} \setmonofont{CMU Typewriter Text} \defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase} % 中文字体 \setmainjfont[ BoldFont={AdobeHeitiStd-Regular}, ItalicFont={AdobeKaitiStd-Regular}]{AdobeSongStd-Light} \setsansjfont{AdobeKaitiStd-Regular} \defaultjfontfeatures{JFM=kaiming} \newcommand\ziju[2]{\vbox{\ltjsetparameter{kanjiskip=#1} #2}} \newjfontfamily\HEI{AdobeHeitiStd-Regular} \newjfontfamily\KAI{AdobeKaitiStd-Regular} \newjfontfamily\FANGSONG{AdobeFangsongStd-Regular} \newcommand{\hei}[1]{{\jfontspec{AdobeHeitiStd-Regular} #1}} \newcommand{\kai}[1]{{\jfontspec{AdobeKaitiStd-Regular} #1}} \newcommand{\fangsong}[1]{{\jfontspec{AdobeFangsongStd-Regular} #1}} \else\fi \RequirePackage{zhnumber} \def\CJKnumber#1{\zhnumber{#1}} % 兼容CJKnumb } \RequirePackage[unicode]{hyperref} \RequirePackage{titletoc} \long\def\zhabstract#1{\long\gdef\HUST@zhabstract{#1}} \long\def\enabstract#1{\long\gdef\HUST@enabstract{#1}} \DeclareDocumentCommand\abstract{+m +g} { \IfNoValueTF{#2}{ \zhabstract{#1}\enabstract{#1} }{ \zhabstract{#1}\enabstract{#2} } } \abstract{}{} \def\zhkeywords#1{\gdef\HUST@zhkeywords{#1}\hypersetup{pdfkeywords={#1}}} \def\enkeywords#1{\gdef\HUST@enkeywords{#1}} \DeclareDocumentCommand\keywords{m g} { \IfNoValueTF{#2}{ \zhkeywords{#1}\enkeywords{#1} }{ \zhkeywords{#1}\enkeywords{#2} } } \def\contentsname{目\hspace{1em}录} \def\contentsnamenospace{目录} \def\HUST@zhabstractname{摘\hspace{1em}要} \def\HUST@zhabstractnamenospace{摘要} \def\HUST@enabstractname{Abstract} \def\frontmatter{ \clearpage \@mainmatterfalse \pagenumbering{Roman} } \def\HUST@zhabstractpage{ \chapter*{\HUST@zhabstractname} \begingroup \fontsize{10.5pt}{13.7pt}\selectfont \HUST@zhabstract \par \vskip 1.2ex % \noindent\hei{\HUST@zhkeywordstitle}\hspace{.8em} \HUST@zhkeywords \endgroup } \def\HUST@enabstractpage{ \chapter*{\textsf{\HUST@enabstractname}} \begingroup \fontsize{10.5pt}{13.7pt}\selectfont \HUST@enabstract \par \vskip 1.2ex % \noindent\textbf{\HUST@enkeywordstitle}\hspace{.8em} \HUST@enkeywords \endgroup } \def\makeabstract{ \phantomsection \ifthenelse{\equal{\HUST@language}{chinese}}{ \addcontentsline{toc}{chapter}{\HUST@zhabstractnamenospace} \addcontentsline{toc}{chapter}{\HUST@enabstractname} }{ \addcontentsline{toc}{chapter}{\HUST@enabstractname} } \ifthenelse{\equal{\HUST@language}{english-draft}}{}{ \HUST@zhabstractpage \clearpage } \HUST@enabstractpage \clearpage } \let\HUST@tableofcontents\tableofcontents \def\tableofcontents{ \ifthenelse{\equal{\HUST@language}{chinese}}{ \pdfbookmark{\contentsnamenospace}{\contentsnamenospace} }{ \pdfbookmark{\contentsname}{\contentsname} } \HUST@tableofcontents \clearpage } \endinput
3条回答
Angus
2020-12-25 14:45
修改摘要命令里代码改成这样,就可以生成英文摘要的页码和目录了 ``` \def\makeabstract{ \phantomsection \ifthenelse{\equal{\HUST@language}{chinese}}{ \addcontentsline{toc}{chapter}{\HUST@zhabstractnamenospace} }{ \addcontentsline{toc}{chapter}{\HUST@enabstractname} } \ifthenelse{\equal{\HUST@language}{english-draft}}{}{ \HUST@zhabstractpage \clearpage } \phantomsection \addcontentsline{toc}{chapter}{\HUST@enabstractname} \HUST@enabstractpage \clearpage } ```

一周热门 更多>

相关问答