1

I would like to have every second page of my rather large document have different margins, top and bottom. Left and right are fine, I have to split up an A4 script into two landscape A5 pages each, see attachment picture below. I have tried editing the geometry package options, but no luck, I get different errors each time:

\ifthenelse{\equal{\value{Hilf}}{0}}{\geometry{top=1.5cm}}{\ifthenelse{\isodd{\value{page}}}{\geometry{top=1.5cm}}{\geometry{top=.5cm}}}

I hope you can see what I've tried to do here, the value "Hilf" is merely unequal to 0 once the document starts. ifthenelse has helped me out a lot, but I've read the texdoc documentation on the geometry package and it doesn't seem like you can do anything other than arithmetics inside the arguments of the package.

\geometry{
top={\ifthenelse{\equal{\value{Hilf}}{0}}{1.5cm}{{\ifthenelse{\isodd{\value{page}}}{1.5cm}{.5cm}}}},
bottom=1.5cm,
footskip=1.4cm, nomarginpar
%top={\ifthenelse{\isodd{\value{page}}}
%{2cm}
%{5cm}}
}

I don't want to have to use \newgeometry and \restoregeometry every second page, there has to be a better way - also as the ToC is many pages long, this manual approach would work there.

Thank you!

Text

1

1 Answer 1

2

For anyone experiencing this problem, or any similar vertical margin problem concerning even/odd pages, or any pages linked to any counter or variable: I managed to solve my own problem!

All the information found online is always about left & right margins for books or twosided or asymmetric documents. The geometry package won't work, nor will the vmargin package (only \newgeometry for a single page perhaps), but like I said, even the ToC will not obey this.

As you have to balance a change in the geometry margin top or bottom, with an overall shift of the page upwards or downwards as you want it with the atbeginshi package, for me it was a reduction of the top margin in the geometry arguments by some 1.25cm, and then this:

\AtBeginShipout{%
    \ifthenelse{\equal{\value{Hilf}}{0}}{}{\ifodd\value{page}%
    \edef\mytemp{%
        \ht\AtBeginShipoutBox=\the\ht\AtBeginShipoutBox\relax
        \dp\AtBeginShipoutBox=\the\dp\AtBeginShipoutBox\relax
    }%
    \sbox\AtBeginShipoutBox{%
        \raisebox{-1.25cm}{\usebox\AtBeginShipoutBox}%
    }%
    \mytemp
        \AtBeginShipoutUpperLeft{%
        \ifthenelse{\equal{\value{page}}{1}\and\equal{\value{Hilf}}{0}}{\put(0,-\paperheight){\includegraphics[width=\paperwidth,height=\paperheight]{art/titel.pdf}}}{     % Titelseite
            \ifthenelse{\isodd{\value{page}}}%
            {\put(0,-\paperheight){\includegraphics[width=\paperwidth,height=\paperheight]{art/top.pdf}}
            }%  
            {}% 
        }
    }
    \fi
}
}

It might appear messy, but you can see I even managed to correct my background PDFs in the same manner. Here the value "Hilf" helps with the implementation of the title page(s), only stepping up once the document truly starts.

As stated before, I wanted to have alternating page margins and thus page backgrounds too, hence only my "top" background PDF needed the shift correction here. For each bottom page, the decrease in top margin was all I needed.

1
  • 3
    While you asked for something, it was never entirely clear why you wanted it. For example, just shifting shipped out pages up/down doesn't change the margins, nor the amount of content on the page. That may have been why there was no immediate answer. However, the question is less than a week old, so a "thanks for nothing" closure doesn't seem necessary. Please rephrase your answer from the perspective of a future visitor here. They don't care about the time difference in answering. They care about the detail of one's answer, so can you reword it for the betterment of the community?
    – Werner
    Apr 4, 2022 at 22:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .