57

I have seen the options such as a4paper, a5paper, letterpaper, etc... to go in the square brackets after \documentclass, but what I want is 8.25 inches width by 10.75 inches height for one document and 6 inches width by 9 inches height for another one. How is this done?

1
  • 15
    Use the geometry package. Commented Nov 5, 2012 at 11:41

3 Answers 3

66

Hope the code is self explanatory.

For first,

\documentclass{article}
\usepackage{blindtext}
\usepackage[paperheight=10.75in,paperwidth=8.25in,margin=1in,heightrounded,showframe]{geometry}
\begin{document}

\Blinddocument

\end{document}

and the second:

\documentclass{article}
\usepackage{blindtext}
\usepackage[paperheight=9in,paperwidth=6in,top=1in,bottom=1in,right=1in,left=1in,heightrounded,showframe]{geometry}
\begin{document}

\Blinddocument

\end{document}
3

Here is method without using a package:

\pdfpagewidth 8.25in
\pdfpageheight 10.75in
1
  • NB this won't work if the desired dimensions are less than the default margins of the document type. e.g. I tried making a 8.5" x 1" with \documentclass{article}, and nothing shows up. Once you load the geometry package to address this issue, this solution has no advantage. Perhaps there is another way of changing the default margins?
    – Rax Adaam
    Commented Sep 28, 2018 at 17:59
1

The geometry package, version 2020/01/02 v5.9, now has the command ''heightrounded'', which calculates for you an integer number of lines of text in ''\textheight''. So, it is suggested that that if you change ''\baselineskip'', that this be done before calling geometry:

\documentclass[11pt,openany]{book}  % XeLatex. pdf output.
  \author{Page Paperton}
  \date{2021 Sep}
  \title{A Custom Paper Size Template}
  \usepackage{comment,kantlipsum,verbatim}
  \usepackage{calc}
  \usepackage{fontspec}
  \setmainfont[Mapping=tex-text]{Minion Pro}
  \newlength{\OriginalBaselineSkip}
  \setlength{\OriginalBaselineSkip}{\baselineskip}
  \usepackage{setspace}
    \setstretch{1.05}    % Set font and line spacing before `heightrounded' below.
  \setlength{\paperwidth}{8.25in}
  \setlength{\paperheight}{10.75in}
  \usepackage[% showframe,
   % left=0.8in,   % 'left' means 'insidemargin'
    right=1.446in,  % 'right' means 'outsidemargin'
    hmarginratio={2:3},
    top=1.446in,
    vmarginratio={1:1},
    marginparwidth=0.6in,
    marginparsep=0.125in,
    heightrounded,  % To make the text block height an integer number of lines.
    driver=pdftex   % Final output is pdf.
             ]{geometry}

%  \usepackage{pdflscape}
% ------- \layout --------------------------------------------------- %
 \usepackage{layout}  % Use \layout to show page geometry             %
   % You can change \layout output metric here..                      % (Heiko Oberdiek)
   % in    = 1/72.27    = 0.013837000                                 %
   % picas = 12/72.27   = 0.166044002                                 %
   % bp    = 72/72.27   = 0.996264010                                 %
   % mm    = 25.4/72.27 = 0.351459804                                 %
   \makeatletter                                                      %
     \renewcommand*{\lay@value}[2]                                    %
     {                                                                %
       \strip@pt\dimexpr0.013837\dimexpr\csname#2\endcsname\relax\,in %
     }                                                                %
   \makeatother                                                       %
% ------------------------------------------------------------------- %
  \usepackage{booktabs}  % For nice looking tables \begin{tabular}{lcr...} ... \end{tabular}
  \usepackage{siunitx}   % Adds 'S' option for aligning table values at decimal point.
  %%%%%%%%%% A macro to display parameters in other units: %%%%%%%%%%%%%%%%%%%
       %%% Example useage: \convertto{in}{\pdfpagewidth}in %%% \the\pdfpagewidth also works.
  \makeatletter
    \def\convertto#1#2{\strip@pt\dimexpr #2*65536/\number\dimexpr 1#1 }
  \makeatother
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usepackage[hyphens]{url}
  \usepackage[hidelinks]{hyperref}

  \raggedbottom  % \flushbottom
\begin{document}
%  \pagenumbering{Alph}
  \maketitle
%  \pagenumbering{alph}
  \pagestyle{empty}
  \tableofcontents
  \thispagestyle{empty}
  \pagenumbering{arabic}
  \pagestyle{plain}
 \chapter{Benevolent Misanthropy}
  \section{Mishaps, Adventures, and Battling the Paper Sprites}
     \kant[1-7]
     \newlength{\insidemargin}
       \setlength{\insidemargin}{1.0in}
       \addtolength{\insidemargin}{\oddsidemargin}
     \newlength{\outsidemargin}
       \setlength{\outsidemargin}{\paperwidth}
       \addtolength{\outsidemargin}{-\insidemargin}
       \addtolength{\outsidemargin}{-\textwidth}
     \newlength{\topmrgn}
       \setlength{\topmrgn}{\topmargin}
       \addtolength{\topmrgn}{\headheight}
       \addtolength{\topmrgn}{1.0in}
       \addtolength{\topmrgn}{\headsep}
     \newlength{\bottommrgn}
       \setlength{\bottommrgn}{\paperheight}
       \addtolength{\bottommrgn}{-\topmrgn}
       \addtolength{\bottommrgn}{-\textheight}
     \newlength{\TextWidth}
       \setlength{\TextWidth}{\textwidth}
     \newlength{\TextHeight}
       \setlength{\TextHeight}{\textheight}
     \newlength{\LinesOfText}
     \newlength{\buffer}
       \setlength{\buffer}{\textheight}
       \addtolength{\buffer}{-\topskip}
       \setlength\LinesOfText{1pt*\ratio{\buffer}{\baselineskip}+1pt}

     \newpage
% \begin{landscape}
     \centering
     \begin{tabular}{clSSS} \toprule
       \multicolumn{1}{c}{Number} & Name & pt & in & mm \\ \midrule
        1 & \verb|\paperwidth|     & \convertto{pt}{\paperwidth}     & \convertto{in}{\paperwidth}     & {\convertto{mm}{\paperwidth}}      \\
        2 & \verb|\paperheight|    & \convertto{pt}{\paperheight}    & \convertto{in}{\paperheight}    & {\convertto{mm}{\paperheight}} \\
        3 & \verb|\textwidth|      & \convertto{pt}{\TextWidth}      & \convertto{in}{\TextWidth}      & {\convertto{mm}{\TextWidth}}   \\
        4 & \verb|\textheight|     & \convertto{pt}{\TextHeight}     & \convertto{in}{\TextHeight}     & {\convertto{mm}{\TextHeight}}  \\
        5 & \verb|\left|           & \convertto{pt}{\insidemargin}   & \convertto{in}{\insidemargin}   & {\convertto{mm}{\insidemargin}}    \\
        6 & \verb|\right|          & \convertto{pt}{\outsidemargin}  & \convertto{in}{\outsidemargin}  & {\convertto{mm}{\outsidemargin}}   \\
        7 & \verb|\top|            & \convertto{pt}{\topmrgn}        & \convertto{in}{\topmrgn}        & {\convertto{mm}{\topmrgn}}       \\
        8 & \verb|\bottom|         & \convertto{pt}{\bottommrgn}     & \convertto{in}{\bottommrgn}     & {\convertto{mm}{\bottommrgn}}    \\
        9 & \verb|\marginparwidth| & \convertto{pt}{\marginparwidth} & \convertto{in}{\marginparwidth} & {\convertto{mm}{\marginparwidth}}  \\
       10 & \verb|\marginparsep|   & \convertto{pt}{\marginparsep}   & \convertto{in}{\marginparsep}   & {\convertto{mm}{\marginparsep}}    \\
       11 & \verb|\headheight|     & \convertto{pt}{\headheight}     & \convertto{in}{\headheight}     & {\convertto{mm}{\headheight}}      \\
       12 & \verb|\headsep|        & \convertto{pt}{\headsep}        & \convertto{in}{\headsep}        & {\convertto{mm}{\headsep}}         \\
       13 & \verb|\footskip|       & \convertto{pt}{\footskip}       & \convertto{in}{\footskip}       & {\convertto{mm}{\footskip}}        \\
       \bottomrule
     \end{tabular}

     \flushleft
     \verb|\baslineskip =| \the\OriginalBaselineSkip\ (Original)\par
     \verb|\baslineskip =| \the\baselineskip\ (Current, after \verb|\setstretch|)\par
     \verb|\topskip =| \the\topskip\par
     The number of lines of text = \par
     \verb|(\textheight-\topskip)/\baselineskip + 1 = | \convertto{pt}{\LinesOfText}
% \end{landscape}

     \layout

\end{document}

You must log in to answer this question.

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