如何检测 \thepage 是否未定义?

如何检测 \thepage 是否未定义?

sig-alternate默认情况下,类禁用页码,这会破坏mparhack(除其他外)。

如何仅在\thepage正确定义时才包含 tex 代码?我尝试了和\ifcsname,但都没有用。\ifcsemptyetoolbox

梅威瑟:

\documentclass{sig-alternate}

%\pagenumbering{arabic}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{mparhack}

\begin{document}

\title{A Sample {\ttlit ACM} SIG Proceedings Paper in LaTeX}

\numberofauthors{1} 
\author{
\alignauthor
Ben Trovato\titlenote{Dr.~Trovato insisted his name be first.}\\
       \affaddr{Institute for Clarity in Documentation}\\
       \affaddr{1932 Wallamaloo Lane}\\
       \affaddr{Wallamaloo, New Zealand}\\
       \email{[email protected]}
}
\date{30 July 1999}

\maketitle

\section{Introduction}

The \textit{proceedings} are the records of a conference.
\end{document}

答案1

使用\@ifundefined

\documentclass{sig-alternate}
%\pagenumbering{arabic}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{mparhack}

\makeatletter
\@ifundefined{thepage}{\def\thepage{\arabic{page}}}{}%
\makeatother

\begin{document}
\title{A Sample {\ttlit ACM} SIG Proceedings Paper in LaTeX}

\numberofauthors{1}
\author{
\alignauthor
Ben Trovato\titlenote{Dr.~Trovato insisted his name be first.}\\
       \affaddr{Institute for Clarity in Documentation}\\
       \affaddr{1932 Wallamaloo Lane}\\
       \affaddr{Wallamaloo, New Zealand}\\
       \email{[email protected]}
}
\date{30 July 1999}

\maketitle

\section{Introduction}

The \textit{proceedings} are the records of a conference.
\end{document}

无论有无 都可以工作\pagenumbering{arabic}

相关内容