16

Using

\usepackage[margin=1in]{geometry}

I can create a margin of 1 inch around my document. What would be the equivalent commands if I used the native LaTeX commands such as \textwidth, \evensidemargin, etc?

5
\documentclass{article} 
%\usepackage[margin=1in]{geometry}
\setlength\topmargin{0pt}
\addtolength\topmargin{-\headheight}
\addtolength\topmargin{-\headsep}
\setlength\oddsidemargin{0pt}
\setlength\textwidth{\paperwidth}
\addtolength\textwidth{-2in}
\setlength\textheight{\paperheight}
\addtolength\textheight{-2in}
\usepackage{layout}

\begin{document} 
\layout
\end{document}
| improve this answer | |
1
\addtolength{\oddsidemargin}{-.875in}
\addtolength{\evensidemargin}{-.875in}
\addtolength{\textwidth}{1.75in}

\addtolength{\topmargin}{-.875in}
\addtolength{\textheight}{1.75in}

If I remember correctly, these are the measurements for a 1 inch margin.

| improve this answer | |
1

Make it a little bit more sophisticated by setting the text height to an integer number of text lines and setting the margin pars

\usepackage{calc}

\makeatletter
\normalsize
\setlength\textheight{\paperheight-2in}%
\setlength\textwidth{\paperwidth-2in}%

\newlength\my@tdima
\newlength\my@tdimb
\newcounter{my@tcnta}
\newcounter{my@tcntb}

\setlength\my@tdima{\textheight-\topskip}%
\setcounter{my@tcnta}{\my@tdima}%
\setcounter{my@tcntb}{\baselineskip}%
\setcounter{my@tcnta}{\value{my@tcnta}/\value{my@tcntb}}%
\setlength\textheight{\baselineskip*\value{my@tcnta}+\topskip}%
\setlength\my@tdima{\paperheight-\textheight}%
\setlength\topmargin{0.5\my@tdima-\headheight-\headsep-1in}%-- Can add a ratio here
\@settopoint\topmargin

\@settopoint\textwidth
\setlength\my@tdima{\paperwidth-\textwidth}%
\setlength\oddsidemargin{0.5\my@tdima-1in}%------------------- Can add a ratio here
\@settopoint\oddsidemargin
\setlength\evensidemargin{\my@tdima-\oddsidemargin-2in}%
\@settopoint\evensidemargin

\setlength\marginparwidth{\evensidemargin+1in-\marginparsep-0.25in}%
\@settopoint\marginparwidth
\setlength\marginparsep {7pt}%
\setlength\marginparpush{7pt}%
\makeatother
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.