奇数边和偶数边边距的自定义计数器

奇数边和偶数边边距的自定义计数器

在文章类中使用时twoside,重置页码计数器会产生与奇数边和偶数边距有关的问题。是否可以声明一个自定义计数器,让文章将页码计数器视为奇数边/偶数边?

\documentclass[twoside]{article}
\usepackage{everypage}
\usepackage{lipsum}
\newcounter{technicalpage}
\setcounter{technicalpage}{1}
\AddEverypageHook{\stepcounter{technicalpage}}
%------ For counting and referring correctly ------%
\makeatletter
\newcounter{labelnumber}
% Same as \label, but also specify counter
\def\setlabel#1#2{\@bsphack%
    \protected@write\@auxout{}%
    {\string\newlabel{#1}{{\@currentlabel}{\csname the#2\endcsname}}}%
    \@esphack}
\def\getpage#1{%
    \bgroup%
  % Define current label (temporarily within group)
    \edef\@currentlabel{\the\csname c@#1\endcsname}%
  % Set a unique label name (unique by counter).
  % Extra {} for intention to use with \expandafter
    \xdef\tst@labelName{{page:labelno:\thelabelnumber}}%
    \stepcounter{labelnumber}%
  % Set the label
    \expandafter\setlabel\tst@labelName{#1}%
  % Do pageref to display page
  \expandafter\pageref\tst@labelName%
    \egroup%
}
\makeatother
%------ End counting / referring ------%
\begin{document}
  \pagenumbering{roman}%
  %On page 1 (even)
  This is page \getpage{page} for intro stuff and the page counter will reset further down. Technically page \getpage{technicalpage}.\par\lipsum
  \pagenumbering{arabic}
  Claims to be page \getpage{page}, but is technically page \getpage{technicalpage}\space and should, internally, be treated as such.
  % Should say page 1, as it is, but should be treated like even with regards to margins,
  % because it's technically the second page. So I want't article to consider
  % \c@technicalpage as the counter for determining odd/even page.


   TP=\getpage{technicalpage}
aaa\\aaa\\aaa\\aaa\\aaa\\aaa\\aaa\\aaa\\aaa\\aaa\\aaa\\aaa\\
aaa\\aaa\\aaa\\aaa\\aaa\\aaa\\aaa\\aaa\\aaa\\aaa\\aaa\\aaa\\aaa\\aaa\\aaa\\aaa\\
aaa\\aaa\\
   TP=\getpage{technicalpage}

\end{document}

我觉得很奇怪,我找不到任何关于这个问题的答案?也许我搜索错了?

有关的:奇数/偶数页边距 - 奇数页有“偶数页边距”,在我看来,在撰写本文时它并没有提供足够的答案。

编辑/备注:我知道 以及\cleardoublepage它应该如何在 之前使用\pagenumbering,正如\pagenumbering预期的那样。但是,我想用另一种方式来解决这个问题,而不是跳过额外的页面。

相关内容