1

I am trying to set different margins for the first page of my document. As I am not sure about the content of the first page, the \afterpage command has been used to achieve the required effect. However, I have noticed that the first paragraph on the second page (the red ellipse on top of Page 2) still has the margins of the first page (please check the example below).

  1. Is there any way where I can force the new margins on the entire content of the second page?
  2. Starting from the second page, is there a way where I can have a grey rectangle (Page 2 and Page 3 currently are drawn by hand only to demonstrate what I am after) covering the entire wide margin of the page (edge-to-edge vertically and edge-to-text on the wide margin horizontally)?

    \documentclass[11pt,a4paper,twoside]{article}
    
    \usepackage{lipsum,afterpage}
    
    \usepackage[left=1.5cm, top=1.5cm, right=3cm, bottom=1.5cm, nohead, nofoot]{geometry}
    
    \begin{document}
    
    \newgeometry{left=7.5cm, top=1cm, right=1cm, bottom=1cm}
    
    \afterpage{\globaldefs=1 \restoregeometry}
    
    \lipsum\lipsum\lipsum
    
    \end{document}
    

Thank you.

Page 1 Page 2 Page 3

  • You are probably looking for \clearpage, not \afterpage. – Johannes_B Dec 29 '18 at 11:52
  • 1
    Personally, i consider using this hocus pocus for the first page of a document completely unneeded. – Johannes_B Dec 29 '18 at 11:53
  • Welcome to TeX.SE. Please mark up code as such by selecting it, clicking on the {} - symbol in the editor or pressing CTRL-K –  Dec 29 '18 at 11:53
  • @Johannes_B but I do not know the content of the first page beforehand. My understanding is that \clearpage has a similar effect to \newpage. – It's me again Dec 29 '18 at 11:55
  • @ChristianHupfer thank you for your comment. I have tried that but for some reasons the code did not get the correct format :( – It's me again Dec 29 '18 at 11:56
  • I didn't see the pictures. Ignore my comments. Why is your first page soo different from the rest? – Johannes_B Dec 29 '18 at 11:57
  • I guess TeX will have a very hard time figuring out what you want to happen. It assembles one paragraph at a time (and margin setting). – Johannes_B Dec 29 '18 at 11:58
  • @Johannes_B it has some extra information on the blank side that is only needed on the first page. – It's me again Dec 29 '18 at 11:59
  • The entire paragraph is set before page breaking is considered so you should not use afterpage or newgeometry but instead set \parshape before the paragraph that breaks over the page – David Carlisle Dec 29 '18 at 13:27
  • To tackle the first problem, I have added \newpage before the \item on the second page. Although it is not a solution and other suggestions are welcomed, it solves my problem for now. Any idea how to solve the second problem (adding the grey box on the wider margin starting from the second page)? – It's me again Dec 30 '18 at 23:25

1 Answers1

0

The solution to the second point (the grey bar on the margin) is found here.

\documentclass[11pt,a4paper,twoside]{article}
\usepackage{lipsum,afterpage,eso-pic,ifthen}
\usepackage[left=3cm, top=1.5cm, right=1.5cm, bottom=1.5cm, nohead, nofoot]{geometry}

\AddToShipoutPicture{% from package eso-pic: put something to the background
    \ifthenelse{\isodd{\thepage}}{
          % ODD page: left bar
          \AtPageLowerLeft{% start the bar at the left bottom of the page
                 \color{black!20}\rule{2.8cm}{\LenToUnit\paperheight}%

          }%
      }%
      {%
          % EVEN page: right bar
          \AtPageLowerLeft{% start the bar at the bottom left of the page
          \put(\LenToUnit{\dimexpr\paperwidth-2.8cm},0){% move it to the top right
              \color{black!20}\rule{2.8cm}{\LenToUnit\paperheight}%
           }%
           }%
       }%
}

\begin{document}
\newgeometry{left=7.5cm, top=1cm, right=1cm, bottom=1cm}
\afterpage{\globaldefs=1 \restoregeometry}

\lipsum\lipsum\lipsum

\end{document}