# Custom counter for oddside and evenside margins

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}
%------ 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.

• You could do this but won't the reader find it very strange to have odd numbered pages on the left side of a spread? – David Carlisle Dec 13 '18 at 9:34
• the question isn't that clear but you don't have to use \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 9:39
• As David wrote: in twoside documents, odd page numbers should be on the right. Everything else is very irritating for the reader. – Ulrike Fischer Dec 13 '18 at 9:42
• One reason that the question is not clear is that it isn't clear how you intend to use these commands, The example used both \thepage and \thetechnicalpage in 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 9:42
• It is easier to have the page counter being the internal value used to decide on odd or even pages and just print a value other than page (eg \thetechnicalpage in the page foot) because \ifodd\c@page is 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