# set geometry offset but keep page number in the middle

I have set an offset for geometry and center move with the offset. How could I keep the centered content as well as page number the original center?

\documentclass[10pt]{article}
\usepackage{geometry}

\geometry{left=2.5in,top=0.5in,right=1.5in,bottom=0.8in}

\usepackage{lastpage}
\usepackage{fancyhdr}
\pagestyle{fancy}
\cfoot{\thepage\ of \pageref{LastPage}}

\setlength\parindent{0in}

% FONTS
\usepackage{xltxtra}
\begin{document}
{\LARGE Albert Einstein}\\[1cm]
\begin{center}
{Last updated: \today\- •\-

Typeset in {\XeTeX}\\
}
\end{center}

\end{document}


• Please provide a complete but small working example (beginning with \documentclass and ending with \end{document}), so that we don't have to reinvent your problem. – Steven B. Segletes Oct 27 '17 at 14:30
• @StevenB.Segletes Sorry. Just update – CreZce Oct 27 '17 at 14:40
• If you only want this special centering for the title page, you can change the geometry just for this one page. Is that what you are interested in or do you want paper-centered numbering, even with offset margins, throughout the document? – Steven B. Segletes Oct 27 '17 at 15:00
• Please note: If an answer to a question results in another question you should not compromise the answers by completely rewriting the question into another one. Instead you should ask a following-up question using "Ask Question" and add a link into the new question, if knowing the original question would be helpful. – Schweinebacke Oct 28 '17 at 7:30
• @Schweinebacke I'm sorry. I thought solution to the previous question could help solve my following one but it didn't. I think I should keep the previous one. – CreZce Oct 28 '17 at 10:05

easier solution: set a \marginoffset

\def \marginoffset {1in}
% 1in = leftmargin - rightmargin
\newcommand{\newcenter}[1]{\hfill{#1}{\hspace{\marginoffset}}\hfill}

\makeatletter
\renewcommand{\@evenfoot}{\newcenter{page \thepage{}}}
\renewcommand{\@oddfoot}{\@evenfoot}
\makeatother


\documentclass[10pt]{article}

\usepackage{geometry}
\geometry{left=2.5in,top=1in,right=1.5in,bottom=8in, marginparsep=20pt, marginparwidth=2in}
\def \marginoffset {1in}
% 1in = leftmargin - rightmargin

\newcommand{\newcenter}[1]{\hfill{#1}{\hspace{\marginoffset}}\hfill}

\makeatletter
\renewcommand{\@evenfoot}{\newcenter{page \thepage{}}}
\renewcommand{\@oddfoot}{\@evenfoot}
\makeatother

\setlength\parindent{0in}

\usepackage{xcolor}
\usepackage{xltxtra}

% DOCUMENT
\begin{document}

{\LARGE Albert Einstein}\\[1cm]
\begin{center}
{Last updated: \today\- •\-

Typeset in {\XeTeX}\\
}
\end{center}

\newcenter{Last updated: \today\- •\-}

\newcenter{Typeset in {\XeTeX}}

\hspace*{-1in}\hspace*{-\oddsidemargin}{\color{red}\vrule width .5\paperwidth height 0.4pt
\smash{\hspace{-0.2pt}\vrule height 500pt depth 1000pt}}

\end{document}


This likely breaks a host of other things, but what I did is as follows:

1. Revised the left margin in the geometry package to reflect symmetry (1.5in rather than 2.5in left margin).

2. issued a \leftskip1in upon entering the document.

3. simulated an offset header with the comamnds

\chead{\hspace{1in}\rule[-4pt]{\dimexpr\linewidth-1in}{.4pt}}


The MWE, in which the page numbers and the center environment content are paper-centered, despite the offset margins:

\documentclass[10pt]{article}
\usepackage{geometry,lipsum}

\geometry{left=1.5in,top=0.5in,right=1.5in,bottom=0.8in}

\usepackage{lastpage}
\usepackage{fancyhdr}
\pagestyle{fancy}
\cfoot{\thepage\ of \pageref{LastPage}}
\setlength\parindent{0in}

% FONTS
\usepackage{xltxtra}
\begin{document}
\leftskip1in
{\LARGE Albert Einstein}\\[1cm]

\begin{center}
{Last updated: \today\- •\-

Typeset in {\XeTeX}\\
}
\end{center}

\lipsum[1-8]
\end{document}


• (+1 for the idea and code), but the centered page number does really look awful in conjunction with the 'shifted' text body. Of course, this is not your fault; it's a weird feature request – user31729 Oct 27 '17 at 18:33
• Great answer. I just update to add a few new questions. – CreZce Oct 28 '17 at 0:56

You can use \fancyfootoffset:

\documentclass[10pt]{article}
\usepackage{geometry}

% FONTS
\usepackage{fontspec} % not xltxtra

% utilities
\usepackage{lastpage}
\usepackage{fancyhdr}
\usepackage{metalogo}
\usepackage{xcolor}% just for the example

% settings
\geometry{
left=2.5in,
right=1.5in,
top=0.5in,
bottom=9in
}

\pagestyle{fancy}
\fancyfootoffset[L]{1in}
\cfoot{\thepage\ of \pageref{LastPage}}

\setlength\parindent{0in}% Why?

\begin{document}
{\LARGE Albert Einstein\par}

\vspace{1cm}

\begin{center}
Last updated: \today •

Typeset in {\XeTeX}
\end{center}

\hspace*{-1in}\hspace*{-\oddsidemargin}{\color{red}\vrule width .5\paperwidth height 0.4pt
\smash{\hspace{-0.2pt}\vrule height 500pt depth 1000pt}}

\end{document}


Just for making a smaller picture, I set a high value for bottom. The two red rules show the center of the page.

• Now page number is in the middle, but we couldn't do the same to centered content? – CreZce Oct 27 '17 at 23:28
• @CreZce You asked for the page number in the middle; you shouldn't modify your question for asking completely unrelated things. – egreg Oct 28 '17 at 8:40
• I'm sorry. I thought solution to the previous question could help solve my following one but it didn't. I think I should keep the previous one. – CreZce Oct 28 '17 at 10:10
• If you look at version one of the question, he asked for centered content to be paper-centered. That did not arise from a question modification. – Steven B. Segletes Oct 28 '17 at 11:54