0

I have my preload.tex as

\usepackage{amsmath}
\usepackage{adjustbox} % uses graphicx
\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}
\fancyhead{}
\fancyfoot{}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
%%
%%
\usepackage{pdfpages}
\makeatletter
\newcommand\fitallincludepdf[2][]{%
    \AM@findfile{#2}%
    \setkeys{pdfpages}{#1}%
    \expandafter\AM@readlist\expandafter{\AM@pagestemp}%
    \@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
\def\AM@AddToShipoutPicture{\AddToShipoutPictureFG*}
\makeatother
%\NoBgThispage
%\BgThispage
%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%       - License -     %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[
    type={CC},
    modifier={by-nc-nd},
    version={4.0}
]{doclicense}
%%
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%      - 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
    \sectionmark{#1}% Add section mark (header)
    \addcontentsline{toc}{section}{#1}% Add section to ToC
    % Add more content here, if needed.
}%%
%%
%%
\setlength{\parindent}{0pt}

which is loaded to

\documentclass[12pt, a4paper, UTF8, scheme=plain, twoside]{ctexart}
\input{../../preload2.tex}
%%
\begin{document}
%%
\fancyhead[L]{LogoName}
\fancyhead[R]{Page~\thepage\ of~\pageref{LastPage}}
\fancyfoot[L]{myhyperlink}
\fancyfoot[CO]{center for odd}
\fancyfoot[CE]{center for even}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0pt}

\clearpage
\thispagestyle{empty}
\newgeometry{left=3cm,right=3cm,top=2cm,bottom=2cm}
\lipsum[7]
\phantomsection
\addcontentsline{toc}{section}{TOC} % Add section to ToC
\tableofcontents
\vspace*{\fill}
\doclicenseImage
%%
%%
%%
%%
\clearpage
\pagestyle{fancy}
\normalsize
\newgeometry{top=1cm,left=0.5cm,right=0.5cm,bottom=1.5cm,headsep=0.3cm}
\setlength{\topskip}{0cm}
%%
%%
\lipsum[7]

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

%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%       -   End   -     %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%
\clearpage
\NoBgThispage
\thispagestyle{empty}
\centering
\mbox{}
\vfill
\huge{[This page is intentionally left blank.]
\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. enter image description here enter image description here

Secondly, where are the extra pages at the end from??? enter image description here

  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.