When using the twoside in the article class, resetting the page counter creates an issue in regards to the odd and even side margins. Is it possible to declare a custom counter that article considers the page counter for odd/even sides?
\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}
I found it really odd that I couldn't find any answers on this? Maybe I've searched for the wrong things?
Related: Odd/even page margins - an odd page has "even page margins", which does not in my opinion provide a sufficient answer at the time of writing.
Edit/remark: I am aware of the \cleardoublepage and how it should be used before \pagenumbering, as \pagenumbering intends. However, I'd like to solve this matter in another way than skipping an extra page.
\pagenumbering: If you just want to change the number format without resetting to 1 then use\renewcommand\thepage{\arabic{page}}not\pagenumbering{arabic}– David Carlisle Dec 13 '18 at 09:39\thepageand\thetechnicalpagein the body text but neither is safe in that context, page references are only guaranteed to give the right number in the page head and foot, in the body you need to use\pageref(and define a similar command for technicalpage references. – David Carlisle Dec 13 '18 at 09:42\thepageand\thetechnicalpage: wouldn't\thetechnicalpagework here due to theeverypagepackage, assuming no one else redefines\thetechnicalpage? – Andreas Storvik Strauman Dec 13 '18 at 09:56\thepageand give the number the last time a page was shipped out but that may or may not be the page that text lands on if there is a paragraph broken over a page, or a float is inserted that pushes this on a page. Try using a paragraph with\thetechnicalpageat the start and the same at the end, the two values will always be the same, even if the paragraph breaks over one or more pages, – David Carlisle Dec 13 '18 at 10:15\getpage{technicalpage}returning 2 on both page 2 and page 3, which is what I would expect, but I can not guess what you want. – David Carlisle Dec 13 '18 at 10:27\oddsidemarginand\evensidemargin. I assume that this algorithm, that probably exists somewhere inarticle.cls, uses thepagecounter to decide whether a page is even or odd. However, I want said algorithm to base it's odd / even decision on a different counter, so that when thepagecounter is reset, the margins stay correct. Even when this entails having even numbers on the right side. – Andreas Storvik Strauman Dec 13 '18 at 10:33\thetechnicalpagein the page foot) because\ifodd\c@pageis used _everywhere(margin setting, positioning of \marginpar, ...) in the format itself and in dozens of packages, and if you change that they will all break, but almost nothing assumes that you print the value of\thepage` in the document. – David Carlisle Dec 13 '18 at 12:15