# how can I edit margins without using packages?

I'm trying to change the margins manually from the file bk10.clo, where I want that in twoside mode the margins are symmetric to 3cm and in oneside mode the margins are top = 3cm, left = 4cm, right = 2cm, bottom = 3cm.

This is my code but I think it's not right.

``````\if@twocolumn
\setlength\marginparsep {10\p@}
\else
\setlength\marginparsep{7\p@}
\fi
\setlength\marginparpush{5\p@}
\if@compatibility
\setlength\oddsidemargin   {.5in}
\setlength\evensidemargin  {1.5in}
\setlength\marginparwidth {.75in}
\if@twocolumn
\setlength\oddsidemargin  {30\p@}
\setlength\evensidemargin {30\p@}
\setlength\marginparwidth {48\p@}
\fi
\else
\if@twoside
\setlength\@tempdima        {\paperwidth}
\setlength\oddsidemargin    {.4\@tempdima}
\addtolength\oddsidemargin  {-0.3in} % we add -0.3in to get 3cm of left side margin
\setlength\marginparwidth   {.6\@tempdima}
%\addtolength\textwidth         {1.36in} % we add 1.36in to get 3cm of right side margin
\else
\setlength\@tempdima        {\paperwidth}
\setlength\oddsidemargin    {.5\@tempdima}
\addtolength\oddsidemargin  {-0.28in} % we add -0.28in to get 4cm of left side margin
\setlength\marginparwidth   {.5\@tempdima}
%\addtolength\textwidth     {1.36in} % we add 1.36in to get 2cm of right side margin
\fi
\addtolength\textwidth        {1.36in} % we add 1.36in to get 3cm (resp. 2cm) of right side margin in mode twoside (resp. mode oneside).
\ifdim \marginparwidth >2in
\setlength\marginparwidth{2in}
\fi
\@settopoint\oddsidemargin
\@settopoint\marginparwidth
\setlength\evensidemargin  {\paperwidth}
\@settopoint\evensidemargin
\fi
\if@compatibility
\setlength\topmargin{.75in}
\else
\setlength\topmargin{\paperheight}
\addtolength\topmargin{-\footskip}     % this might be wrong!
\addtolength\textheight{1in} % we add 1in to get 3cm of bottom margin (from the limit of the page at body)
\addtolength\footskip{0.066in} % we add 0.066in to get 2cm of bottom margin (from the limit of the page at footer)
\@settopoint\topmargin
\fi
``````

EDIT: Using

``````\makeatletter
\setlength{\oddsidemargin}{-1in}
\if@twoside
\else
\fi
\setlength{\evensidemargin}{\oddsidemargin}
\setlength{\textwidth}{\paperwidth}
\setlength{\topmargin}{-1in}
\setlength{\textheight}{\paperheight}
\addtolength{\textheight}{-6cm} % top + bottom margins
\makeatother
``````

I appreciate any help...

• Why? Why don't you want to use packages? Why have you tagged this `tex-core` when it seems to have nothing to do with it? – cfr Aug 26 '18 at 1:49
• Why would adding `-0.3in` get you `3cm` left of anything? You are 0.3in to the left of the left edge of the paper as far as I can tell. However, without complete code, it is hard to say. Add `\usepackage[pass,verbose]{geometry}` to see what's happening. Better yet, use `geometry` to do it. – cfr Aug 26 '18 at 1:52
• Somebody else figured out all you are trying to do now and put the result as a nice package. Namely `geometry`. There is no point in reinventing the wheel. – Johannes_B Aug 26 '18 at 4:14

try to understand this

``````\makeatletter
\setlength{\oddsidemargin}{-1in}
\if@twoside
\else
\fi
\setlength{\evensidemargin}{\oddsidemargin}
\setlength{\textwidth}{\paperwidth}
• It is always good to load `showframe` just to see the margins and text/header/footer area. – Sigur Jan 25 '19 at 21:26