# How to set margins and page size in pdfLaTeX without geometry?

What is the TeX equivalent of

\usepackage[paperwidth=10cm,
paperheight=15cm,
margin=0mm,
bottom=1mm]{geometry}


?

I know nothing in TeX and so far, I am playing with expressions such as

\newlength{\initialVerticalHeight}
\setlength{\initialVerticalHeight}{5cm}

\newlength{\bottomMargin}
\setlength{\bottomMargin}{1mm}

\global\setlength\paperheight\initialVerticalHeight%
\global\setlength\pdfpageheight\initialVerticalHeight%
\global\setlength\textheight{\dimexpr\paperheight-\bottomMargin}%


but I can't find the equivalent of left(margin) and top(margin).

Is it very complicated? I'm trying to avoid using geometry package because I'm doing tricky things and want to have a clear understanding of what is happening.

• Why do you want to reinvent the wheel? Btw, do you mean TeX or LaTeX? – Bernard Sep 18 '15 at 0:39
• When I tried to figure it out for myself, I used links listed here: tex.stackexchange.com/questions/241575/… You may use that as a starting point. Also search this forum by voffset, hoffset, hsize, vsize; if you use pdftex, look also into pdftexmagfix.tex – Igor Liferenko Sep 18 '15 at 2:42
• Even better, look into the source of OPmac package, or use it directly. – Igor Liferenko Sep 18 '15 at 2:48
• @Bernard I need to understand how things work. I don't know if this is TeX or LaTeX. What I mean is how can I achieve the same result with more basic tools. What I need to do ultimately is beyond the capabilities of geometry. – Colas Sep 18 '15 at 2:50
• Well, then Touhami's answer looks reasonable, and Igor's is impracticable. By the way, \setlength is LaTeX, not Plain. – erreka Sep 18 '15 at 18:15

Here is a solution

\documentclass{article}
\usepackage{lipsum}

\newlength{\bottomMargin}
\setlength{\bottomMargin}{1mm}

% paper size
\setlength{\paperwidth}{10cm}
\setlength{\paperheight}{15cm}
\setlength{\pdfpagewidth}{\paperwidth}
\setlength{\pdfpageheight}{\paperheight}
% horizontal dimensions
\setlength{\oddsidemargin}{-1in}
\setlength{\evensidemargin}{\oddsidemargin}
\setlength{\textwidth}{\paperwidth}
% vertical dimension
\setlength{\topmargin}{-1in}
%\setlength{\topskip}{10pt}   if you are about new class
%\setlength\footskip{30pt} if you want a footer, here no place for footer
\setlength{\textheight}{\paperheight}

Latex format set \topskip=10pt standard class set it 10pt, 11pt ,12pt. It should never be set 0pt