# How do I create a Lyx layout or document class to handle a different margin for the first page?

I just finished formatting a paper to meet IEEE CDC 18 format requirements: first page has 74pt top margin, 54pt all other margins. Second page and beyond use 54pt margins all around. Note that the "margin" here includes the placement of the page number in the head, so the header offset needs to be added to the top margin in Document > Settings... > Page Margins.

What I wound up doing, is creating a document with the margins for all pages set to 84pt top, 54pt everything else (12pt header offset). I then made a second document with 66pt top margins, 54pt everything else (same offset), and a page break inserted to make sure the second page in the second document starts on the same line as the first document. I then deleted all but the first page of document one and appended the remaining pages from the second document to get a result that was compliant with the margin standards (they won't accept it otherwise).

This seems like a cludgy way to do something that should be easy to set up in either my layout file in Lyx or in the .cls file my layout is based off of. How do I set this up so in the future it is less hassle?

• What are you submitting? It is likely they are just interested in the text and do some final adjustments nevertheless. – Johannes_B Sep 20 '18 at 4:54
• I am submitting a compiled PDF from Lyx compiled using pdflatex. IEEE's website uses an automated system which automatically rejects any uploaded paper that violates their margin guidelines – Frank Sep 20 '18 at 12:44

The following is based on the assumption that the text block changes from the first page to the second, but the text does not flow naturally from page one to two. That is, there is a clear break between content on the first and second page. This might be the usual case when dealing with a title page that stands out from the regular content.

Change the Document > Settings... > Page Margins to suit the bulk of your document (for pages 2 onward) and add the following to your Document > Settings... > LaTeX Preamble:

\AtBeginDocument{
% Page layout for page 1 only
\newgeometry{
% <your geometry settings>
margin = 0.75in
}
}


The above preamble entry changes the geometry for the first page (via \newgeometry) at the start of the document (using \AtBeginDocument). You can then insert a manual ERT to restore the default geometry (using \restoregeometry):

For illustrative purposes, the above geometry settings were used with a 2in margin for the first page, and a 1in margin for the remainder of the document. Here's the output:

Since the IEEE CDC 18 format requirements only change the top margin, there is an easier option. Similar to above, use a default setting for geometry for pages 2 onward and add the following to your Document > Settings... > LaTeX Preamble:

\AtBeginDocument{
% Page layout for page 1 only
\vspace*{0.25in}% Top margin difference for first page
}


The result will give 1/4" less space for the text block on the first page.

A final option is to use the class and sample TeX file provided to authors where the initiate the modifications for you.