aaltothesis 课程中的页码不稳定?

aaltothesis 课程中的页码不稳定?

我正在尝试配置独创性班级这里(.cls 文件这里)。.cls 文件设计为第 2-4 页(即摘要页)采用罗马数字页码,而第 5-777 页采用阿拉伯数字。但是,出于某种原因,以下第 1 行会影响全局页码:

  • 如果将第一行更改为第二行,则会在 5-777 页中获得阿拉伯语页码。
  • 如果保留第 1 行,则罗马页码不会出现在第 2-4 页,而是出现在第 5-777 页

    %\pagenumbering{roman}% Line 1% https://tex.stackexchange.com/a/330691/13173 
    \pagenumbering{arabic}% Line 2
    

我的 .tex 文件

\documentclass[english,12pt,a4paper,utf8]{aaltothesis}
\usepackage{mathtools, amssymb, amsbsy}

%% Xelatex
%\usepackage{polyglossia} % also loads package fontspec
%\usepackage{unicode-math} % if you also need maths
%% Pdftex
\usepackage[T1]{fontenc}% %  https://tex.stackexchange.com/q/330683/13173
\usepackage{inputenc}% For scands in both Finnish and English input docs % https://tex.stackexchange.com/q/330683/13173
\setmainlanguage{english} % loads language hyphenation rules and such

\begin{document}
Lorem
\end{document}

.cls 代码的精简版本,但完整这里

你看到的是罗马数字,应该是正确的

% See full copyright here http://paste.ubuntu.com/23212741/
\NeedsTeXFormat{LaTeX2e}%
\ProvidesClass{aaltothesis}[2015/09/24 Aalto Univ. ELEC thesis class v2.2]%
\RequirePackage{ifthen}%
%

%%%%%%% Storage of number of pages and number of abstracts %%%%%%%
\newcounter{NMainPages}%
\newcounter{NInitPages}%
\newcommand*{\storeinipagenumber}{%
\immediate\write\@auxout{\string\setcounter{NInitPages}{\arabic{page}-1}}%
}%
\AtEndDocument{%
\immediate\write\@auxout{\string\setcounter{NMainPages}{\thepage}}%
}%

% ...

\endinput

实验大卫的回答

现在,我有以下内容,但它会无法可靠地获取文档的最后一个数字

\immediate\write\@auxout{\string\setcounter{NMainPages}{\arabic{page}}}%

\immediate如何在有或无包裹的情况下获得稳定的文档最后一个编号lastpage

操作系统:Debian 8.5
TeXLive:2016
LaTeX 执行机器:pdftex,XeLaTeX
.cls 文件:这里

答案1

\immediate\write\@auxout{\string\setcounter{NMainPages}{\thepage}}%

显然是错误的,解决眼前问题的方法是将数字写成数字,这样

\immediate\write\@auxout{\string\setcounter{NMainPages}{\arabic{page}}}%

然而,这并不能可靠地获得文档的最后一个数字,没有\immediate帮助,但准确的数字需要更仔细地控制可能产生输出的任何最终浮动页面,\end{document} 您可以查看lastpage包以了解一些详细信息。

相关内容