6

I have basic class file and I would like to set margins of an a4paper to 0mm. Here is the markup of some-class.cls:

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{some-class}[2013/07/29]

\renewcommand{\normalsize}{\fontsize{10pt}{12pt}\selectfont}
\DeclareOption{a4paper}{
    \setlength\paperheight {297mm}%
    \setlength\paperwidth  {210mm}
}
\DeclareOption{landscape} {
    \setlength\@tempdima   {\paperheight}%
    \setlength\paperheight {\paperwidth}%
    \setlength\paperwidth  {\@tempdima}
}

%Default options for design
\ExecuteOptions{a4paper}
%Process user given options
\ProcessOptions

\RequirePackage[top=0mm, bottom=0mm, left=0mm, right=0mm, textwidth=210mm]{geometry}

Content of my document.tex:

\documentclass[]{some-class}
\author{roncsak}
\title{some title}
\date{2013/07/28}
\begin{document}
Lorem ipsum
\end{document}

I would like to set an A4 paper with zero margins. Instead I notice some margin on the left side (approximately 10mm). I could reduce that margin with the \RequirePackage[top=0mm, bottom=0mm, left=-10mm, right=0mm, textwidth=210mm]{geometry} but I would like to understand why this margin left behind.

8

The most basic approach to obtain a zero-width margin is to use

\usepackage[margin=0pt]{geometry}% http://ctan.org/pkg/geometry

(or \RequirePackage within a class/package). The sets the margins and indirectly also the text block size.

The "margin" you notice is due to the paragraph indent that is set by default to 20pt. Add \noindent to a paragraph to remove this indent, or set it to zero in the preamble using \setlength{\parindent}{0pt} which will make the change global.

|improve this answer|||||
  • The \setlength{\parindent}{0pt} worked well! Thank you! – roncsak Jul 29 '13 at 18:59
  • @roncsak: Don't forget to set a non-zero \parskip (or load the package parskip) if you set \parindent to 0. – You Jul 29 '13 at 20:09
  • Can the first method (the geometry package) be made to only zero the vertical margins? – user4417 Jan 26 '18 at 16:21
  • 1
    @user4417: Yes. geometry provides margin for all margins, hmargin for horizontal margins and vmargin for vertical margins. You would be interested in vmargin=0pt I assume. – Werner Jan 26 '18 at 18:04

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.