chrisjsewell/ipypublish

Correct way to set the page size

Closed this issue · 2 comments

I'm trying to figure out the best way to set a custom page size. I can do it by directly editing the .tex file and editing the margins section:

%%%%%%%%%%%% MARGINS

 % Used to adjust the document margins
\usepackage{geometry}
\geometry{tmargin=1in,bmargin=1in,lmargin=1in,rmargin=1in,
nohead,includefoot,footskip=25pt,paperheight=7in,paperwidth=14in}
% you can use showframe option to check the margins visually
%%%%%%%%%%%%

but obviously this is overwritten each time I rerun ipypublish. I have a vague guess that I need to change a template somewhere, but I can't figure it out.

Sorry I'm a bit busy at the moment to look into this in depth.

Ideally, it would be part of the Document metadata, but I haven't added it yet 😞

At present you would need to alter

"\\geometry{tmargin=1in,bmargin=1in,lmargin=1in,rmargin=1in,",

Possibly creating a new Conversion Template

Thanks. I think I figured it out; not sure if this is the best way, but I added a new segment to the config file, then in the segment I put:

  "segments": {
    "document_commands": [
   
      "% set custom page size",
      "\\usepackage{geometry}",
      "\\geometry{tmargin=0.5in,bmargin=0.5in,lmargin=0.5in,rmargin=0.5in,",
      "nohead,includefoot,footskip=25pt,paperheight=11in,paperwidth=8.5in}",
       ],

I have a suspicion that this is not the "correct" way to do it, as it results in two geometry settings in the final .tex file, but I guess that the second one overrides the first and it seems to be working.