# \newgeometry for twoside report

I have my preload.tex as

\usepackage{amsmath}
\usepackage{import}
\usepackage[T1]{fontenc}
\usepackage[math]{iwona} %nice font
\usepackage[top=1.8cm,bottom=1.8cm,left=2cm,right=2cm]{geometry}
\usepackage{lipsum}
%%
%%
\usepackage{fancyhdr}
\usepackage{lastpage}
\fancyfoot{}
\renewcommand{\footrulewidth}{0pt}
%%
%%
\usepackage{pdfpages}
\makeatletter
\newcommand\fitallincludepdf[2][]{%
\AM@findfile{#2}%
\setkeys{pdfpages}{#1}%
\@for\xxx:=\AM@pagelist\do{%
\edef\AM@tmp{[\unexpanded{#1},
width =0.99\textwidth,
height=0.99\textheight,
keepaspectratio,pages=\xxx]}%
\expandafter\includepdf\AM@tmp{#2}%
}}%
\makeatother
%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%      - HYPERREF -     %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{hyperref}
%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%      -    QR    -     %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{qrcode}
\usepackage{background}
\backgroundsetup{
contents={exmaple-image},
pages=some,
placement=bottom,
color=black,
scale=1,
opacity=0.5,
hshift=9cm,
vshift=0.2cm
}%
%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% background - go to back
%%%%%%%%%%%%%%%%%%%%%%%%%%%
\makeatletter
\makeatother
%\NoBgThispage
%\BgThispage
%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[
type={CC},
modifier={by-nc-nd},
version={4.0}
%%
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%      - By Topic -     %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{tcolorbox}
\tcbuselibrary{skins,xparse}
\tcbset{%
colback=white,
tikz={opacity=0.1,transparency group},
colframe=black,
title filled=false,
bookmark={Q\arabic{\tcbcounter}}
}
\NewTColorBox[
auto counter,
number freestyle={ Q\noexpand\arabic{\tcbcounter} }
]{question}{ O{}mo }{
%   lowerbox=ignored, %invisible/ignored
fonttitle=\bfseries,
title=\thetcbcounter: #2,
% after title/after upper
IfValueTF={#3}{after title={\hfill\colorbox{red}{\texttt #3 }}}{},
#1
}%
%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%       -   OWN   -     %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\fakesection}[1]{%
\par\refstepcounter{section}% Increase section counter
% Add more content here, if needed.
}%%
%%
%%
\setlength{\parindent}{0pt}


\documentclass[12pt, a4paper, UTF8, scheme=plain, twoside]{ctexart}
%%
\begin{document}
%%
\fancyfoot[CO]{center for odd}
\fancyfoot[CE]{center for even}
\renewcommand{\footrulewidth}{0pt}

\clearpage
\thispagestyle{empty}
\newgeometry{left=3cm,right=3cm,top=2cm,bottom=2cm}
\lipsum[7]
\phantomsection
\tableofcontents
\vspace*{\fill}
%%
%%
%%
%%
\clearpage
\pagestyle{fancy}
\normalsize
\setlength{\topskip}{0cm}
%%
%%
\lipsum[7]

%%%%%%%%%%%%%%%%%%%
%% Begin
%%%%%%%%%%%%%%%%%%%
\lipsum[20-100]

%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%       -   End   -     %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%
\clearpage
\NoBgThispage
\thispagestyle{empty}
\centering
\mbox{}
\vfill
\vfill
%%
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%


Two problems here:

First, the left and right margins are very odd to me. I don't know what length they have used. How do I enforce the setting from \newgeometry{} so I have the same left and right margin as desired? I only use twoside, so that I can have different footers for odd and even pages.

Secondly, where are the extra pages at the end from???

• I take it you didn't write the preload.tex. Can you modify it? OTOH, if it is required for publication or a thesis, I wouldn't attempt to change the defaults either. And \newgeometry typically adds pages; use \setgeometry instead. – John Kormylo Jul 10 at 14:16
• No, I "wrote" it for my self, it's a compilation of the stuff that I use. Yes, we can MODIFY it as we like. I just dont really get why \newgeometry didn't work. I will try \setgeometry – CasperYC Jul 10 at 15:41
• @JohnKormylo \setgeometry is not defined .... – CasperYC Jul 10 at 15:42
• Oops, just \geometry (page 4 of geometry manual). – John Kormylo Jul 10 at 20:55
• @JohnKormylo But that can only be used in preamble, which would not allow me to change margins later... – CasperYC Jul 11 at 4:43