Odd numbered pages should always be right pages!
So you should always use \cleardoublepage
before changing page numbering, because it makes no sense to change page numbering on the left side of a double sided print:
\documentclass[twoside]{article}% It's better to tell already the class to use twoside!
\usepackage[showframe]{geometry}
\begin{document}
This is the first page; it should be a right page (recto).
\cleardoublepage
\pagenumbering{arabic}
This is the third page; it should be a right page, because changing page numbering should always be done on right pages!
\end{document}
If you simply wanted to suppress page number at the first page of an article, try:
\documentclass[twoside]{article}% It's better to tell already the class to use twoside!
\usepackage[showframe]{geometry}
\begin{document}
\title{Title}
\author{Me}
\maketitle\thispagestyle{empty}
\begin{abstract}A short abstract of the document.\end{abstract}
Some more text, e.g. a table of contents.
\clearpage
This is the second page; it should be a left page and numbered 2!
\end{document}
Note: You may use \cleardoublepage
before \pagenumbering
even at oneside documents, because in this case it would have the same result \clearpage
would have.
But, if you really, really must have odd pages left and even pages right, you may simply switch the margins (and the margin used for \marginpar
):
\documentclass[twoside]{article}% It's better to tell already the class to use twoside!
\usepackage[showframe]{geometry}
\makeatletter
\newcommand*{\flipmargins}{%
\clearpage
\setlength{\@tempdima}{\oddsidemargin}%
\setlength{\oddsidemargin}{\evensidemargin}%
\setlength{\evensidemargin}{\@tempdima}%
\if@reversemargin
\normalmarginpar
\else
\reversemarginpar
\fi
}
\makeatother
\begin{document}
This is the first page; it should be a right page (recto).
\flipmargins
\pagenumbering{roman}
This is the second page; it should be a left page (verso).
\end{document}
Using a page style like headings
you may also need to change the page style, e.g., to print the numbers near the outer margin. You may do this, using either scrpage2 or fancyhrd. Here an example using scrpage2
:
\documentclass[twoside]{article}% It's better to tell already the class to use twoside!
\usepackage[showframe]{geometry}
\usepackage[automark]{scrpage2}
\pagestyle{scrheadings}
\makeatletter
\newcommand*{\flipmargins}{%
\clearpage
\setlength{\@tempdima}{\oddsidemargin}%
\setlength{\oddsidemargin}{\evensidemargin}%
\setlength{\evensidemargin}{\@tempdima}%
\if@reversemargin
\normalmarginpar
\else
\reversemarginpar
\fi
\ifdim \evensidemargin>\oddsidemargin
\ihead{\headmark}%
\ohead[\pagemark]{\pagemark}%
\else
\ihead[\pagemark]{\pagemark}%
\ohead{\headmark}%
\fi
}
\makeatother
\begin{document}
\section{Normal pages}
This is the first page; it should be a right page (recto).
\flipmargins
\pagenumbering{roman}
\section{Inverse margin pages}
This is the second page; it should be a left page (verso).
\end{document}
Alternative:
One completely different alternative would be to fake the page number, given by \thepage
:
\documentclass[twoside]{article}% It's better to tell already the class to use twoside!
\usepackage[showframe]{geometry}
\makeatletter
\newcommand{\@arabicplusone}[1]{\@arabic{\numexpr #1+1\relax}}
\newcommand{\@romanplusone}[1]{\@roman{\numexpr #1+1\relax}}
\newcommand{\@Romanplusone}[1]{\@Roman{\numexpr #1+1\relax}}
\newcommand{\@alphplusone}[1]{\@alph{\numexpr #1+1\relax}}
\newcommand{\@Alphplusone}[1]{\@Alph{\numexpr #1+1\relax}}
\makeatother
\newcommand*{\pagenumberingplusone}[1]{%
\pagenumbering{#1plusone}\setcounter{page}{0}%
}
\begin{document}
This is the first page; it should be a right page (recto). See
page~\pageref{test}.
\clearpage\pagenumberingplusone{roman}
This\label{test} is the second page; it should be a left page (verso).
\end{document}
Disadvantage of this suggestion would be, that if a package uses page counter directly for something else but testing odd or even the result may be unexpected. The advantage of this suggestion would be, that pages with odd value of counter page
shows not only an even page number but will be handled to be a even=left page by LaTeX and every class or package that uses \c@page
or \value{page}
for the test (and vica versa).
You can use the background
package to put things on every page, the rest is done by TikZ:
Code
\documentclass{scrartcl}
\usepackage[margin=25mm]{geometry}
\usepackage{background}
\usepackage{lipsum}
\usetikzlibrary{calc,shapes.geometric}
\backgroundsetup%
{ contents=%
{ \begin{tikzpicture}
[ overlay,
remember picture,
wx/.style={draw,regular polygon, minimum size=1.5cm, above,fill=red!10,thick},
w4820/.style={wx, regular polygon sides=3},
w6/.style={wx, regular polygon sides=4},
w12/.style={wx, regular polygon sides=5},
w10/.style={wx, kite,kite vertex angles=100 and 60,minimum size=1cm},
line join=round,
]
\node[w4820] at ($(current page.north west)+(4,-2)$) {\pgfmathparse{random(1,4)}\pgfmathresult};
\node[w6] at ($(current page.north west)+(6,-2)$) {\pgfmathparse{random(1,6)}\pgfmathresult};
\node[w4820] at ($(current page.north west)+(8,-2)$) {\pgfmathparse{random(1,8)}\pgfmathresult};
\node[w10] at ($(current page.north west)+(10,-2)$) {\pgfmathparse{random(1,10)}\pgfmathresult};
\node[w12] at ($(current page.north west)+(12,-2)$) {\pgfmathparse{random(1,12)}\pgfmathresult};
\node[w4820] at ($(current page.north west)+(14,-2)$) {\pgfmathparse{random(1,20)}\pgfmathresult};
\end{tikzpicture}
},
color=black,
angle=0,
scale=1,
opacity=1,
}
\begin{document}
\lipsum[1-100]
\end{document}
Output
Edit 1
Here's finally an automatic version. It checks the total number of pages, and then draws the dices, the values equally distributed, and does not draw any further if there's no more room for an other set.
The dices are supposed to be, from left to right, d4, d6, d8, d10,d12 and d20.
As it turns out, most d10 of people I know actually use the "inverted" kite.
To use different dice, just change the values in the for lop in \setinitialdicevalues
, e.g. \foreach \x [count=\c] in {6,10,12,20,24,30}
and provide fitting syles in the tikzpicture
, e.g. add stlyes w24
and w30
Code
\documentclass{scrartcl}
\usepackage[margin=25mm]{geometry}
\usepackage{background}
\usepackage{lipsum}
\usepackage{xstring}
\usepackage{xifthen}
\usetikzlibrary{calc,shapes.geometric}
\usepackage{totcount}
\regtotcounter{page}
\newcommand{\setinitialdicevalues}
{ \xdef\dicedata{+}
\foreach \x [count=\c] in {4,6,8,10,12,20}
{ \pgfmathtruncatemacro{\maxsets}{(\totvalue{page}-1)/\x}
\pgfmathtruncatemacro{\maxpage}{\maxsets*\x}
\xdef\mytemplist{,}
\ifthenelse{\maxsets > 0}
{ \foreach \y in {1,...,\maxpage}
{ \pgfmathtruncatemacro{\mytempvalue}{mod(\y-1,\x)+1}
\xdef\mytemplist{\mytemplist\mytempvalue,}
}
\xdef\myrandomlist{,}
\foreach \y in {\maxpage,...,1}
{ \pgfmathtruncatemacro{\nei}{random(1,\y)}
\pgfmathtruncatemacro{\neipo}{\nei+1}
\StrBetween[\nei,\neipo]{\mytemplist}{,}{,}[\nextelement]
\StrSubstitute[1]{\mytemplist}{,\nextelement,}{,}[\mytemplisttwo]
\xdef\mytemplist{\mytemplisttwo}
\xdef\myrandomlist{\myrandomlist\nextelement,}
}
\xdef\dicedata{\dicedata\maxpage+\myrandomlist+}
}
{ \xdef\dicedata{\dicedata0++}
}
}
\typeout{\dicedata}
}
\newcommand{\getdicelist}[1]%
{ \pgfmathtruncatemacro{\lowerindex}{2*#1}%
\pgfmathtruncatemacro{\upperindex}{2*#1+1}%
\StrBetween[\lowerindex,\upperindex]{\dicedata}{+}{+}[\mytempdata]%
\xdef\currentdicelist{\mytempdata}%
}
\backgroundsetup%
{ contents=%
{ \begin{tikzpicture}
[ overlay,
remember picture,
wx/.style={draw, minimum size=1.5cm, above,fill=red,font=\bfseries\selectfont,text=white,rounded corners=0.5mm,inner sep=1pt},
w4/.style={wx, regular polygon, regular polygon sides=3},
w6/.style={wx, regular polygon, regular polygon sides=4},
w8/.style={w4},
w10/.style={wx, kite,kite vertex angles=100 and 60,minimum size=1cm,shape border rotate=180},
w12/.style={wx, regular polygon, regular polygon sides=5},
w20/.style={w4},
]
\foreach \x [count=\c] in {4,6,8,10,12,20}
{ \pgfmathtruncatemacro{\lowerindex}{2*\c-1}
\pgfmathtruncatemacro{\upperindex}{2*\c}
\StrBetween[\lowerindex,\upperindex]{\dicedata}{+}{+}[\currentlastpage]%
\pgfmathtruncatemacro{\firstemptypage}{\currentlastpage+1}
\ifthenelse{\value{page} < \firstemptypage}
{ \pgfmathtruncatemacro{\lowerindex}{2*\c}%
\pgfmathtruncatemacro{\upperindex}{2*\c+1}%
\StrBetween[\lowerindex,\upperindex]{\dicedata}{+}{+}[\currentdicelist]%
\StrBetween[1,2]{\currentdicelist}{,}{,}[\mynextnumber]
\node[w\x] at ($(current page.north west)+(2+2*\c,-2)$) {\mynextnumber};
\StrSubstitute[1]{\currentdicelist}{,\mynextnumber,}{,}[\mytempdicelist]
\StrSubstitute[1]{\dicedata}{+\currentdicelist+}{+\mytempdicelist+}[\mytempdicedata]
\xdef\dicedata{\mytempdicedata}
%\node[w\x] at ($(current page.north west)+(2+2*\c,-2)$) {\pgfmathparse{random(1,\x)}\pgfmathresult};
}
{
}
}
\end{tikzpicture}
},
color=black,
angle=0,
scale=1,
opacity=1,
}
\AtBeginDocument{\setinitialdicevalues\par\bigskip}
\begin{document}
total pages: \pgfmathparse{int(\totvalue{page}-1)}\pgfmathresult\bigskip
\lipsum[1-100]
\lipsum[1-100]
\lipsum[1-60]
\end{document}
Output
This is page 31 of 37. So we see d4, d6, d8 and d12, but not d10 (last on page 30) or d20 (last on page 20).
Best Answer
In a twoside layout even pages are always on the left side and odd pages on the right side. If you insert one unnumbered page this get out of sync. So you must also insert its (unnumbered) back.