2

I have seen a similar question at a4paper, where should I declare it? In document class or geometry? and the selected answer there implies that there is no difference in whether we use \documentclass[a4paper]{article} or if we use \usepackage[a4paper]{geometry}.

But my observations contradict the selected answer there.

Here is my code in file foo.tex:

\documentclass[a4paper]{article}
\begin{document}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas nec
lobortis justo. Praesent ut scelerisque risus, sit amet mollis erat.
Fusce at lacus at libero consequat consectetur.

Proin at vehicula ligula. Vivamus quis ligula id lacus aliquet
ultricies. Vivamus tristique, velit vestibulum tincidunt fermentum,
lacus sem euismod risus, ut volutpat augue dolor vitae est. Proin odio
nunc, sollicitudin quis nisi a, sodales efficitur quam. Phasellus ex
velit, porttitor vestibulum consectetur eu, maximus et nisi.

Nulla pharetra augue ex, quis scelerisque sem iaculis id. Aliquam in
tincidunt quam. Praesent ac laoreet elit. Aenean varius ullamcorper
dolor ac finibus. Proin est sapien, tempor nec mollis ut, ultricies et
ante. Maecenas hendrerit velit non augue rutrum, mollis pharetra nisl
auctor. Ut nisl mauris, porta ut nisi ut, elementum tristique nibh. 
\end{document}

Here is another one in file bar.tex. The only thing that is different here is the usage of \usepackage[a4paper]{geometry} instead of \documentclass[a4paper]{article}.

\documentclass{article}
\usepackage[a4paper]{geometry}
\begin{document}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas nec
lobortis justo. Praesent ut scelerisque risus, sit amet mollis erat.
Fusce at lacus at libero consequat consectetur.

Proin at vehicula ligula. Vivamus quis ligula id lacus aliquet
ultricies. Vivamus tristique, velit vestibulum tincidunt fermentum,
lacus sem euismod risus, ut volutpat augue dolor vitae est. Proin odio
nunc, sollicitudin quis nisi a, sodales efficitur quam. Phasellus ex
velit, porttitor vestibulum consectetur eu, maximus et nisi.

Nulla pharetra augue ex, quis scelerisque sem iaculis id. Aliquam in
tincidunt quam. Praesent ac laoreet elit. Aenean varius ullamcorper
dolor ac finibus. Proin est sapien, tempor nec mollis ut, ultricies et
ante. Maecenas hendrerit velit non augue rutrum, mollis pharetra nisl
auctor. Ut nisl mauris, porta ut nisi ut, elementum tristique nibh.
\end{document}

But the output from both files are different. Here is a side by side comparison with foo.pdf on left and bar.pdf on right.

I have three questions:

  • What is your default document setting when you installed, say, TeX Live? Was it set to letterpaper or a4paper? – Werner Jan 28 at 16:33
  • @Werner letterpaper – Lone Learner Jan 28 at 16:43
3

geometry changes the layout (unless you use the option pass).

So there is a difference between documents with geometry and documents without geometry.

But if you load geometry it doesn't make a difference if you set a4paper with

\documentclass[a4paper]{article}
\usepackage{geometry}

or with

\documentclass{article}
\usepackage[a4paper]{geometry}
4

I think the clearest way to see the differences is to use package layout showing you the current writing area and margins and several length of the document in mm.

Please see this code

\documentclass[a4paper]{article}

\usepackage{layout}
% from https://tex.stackexchange.com/questions/173244/to-display-the-lengths-in-millimeters-by-default
\makeatletter
\renewcommand*{\lay@value}[2]{%
  \strip@pt\dimexpr0.351459\dimexpr\csname#2\endcsname\relax\relax mm%
}
\makeatother


\begin{document}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas nec
lobortis justo. Praesent ut scelerisque risus, sit amet mollis erat.
Fusce at lacus at libero consequat consectetur.

Proin at vehicula ligula. Vivamus quis ligula id lacus aliquet
ultricies. Vivamus tristique, velit vestibulum tincidunt fermentum,
lacus sem euismod risus, ut volutpat augue dolor vitae est. Proin odio
nunc, sollicitudin quis nisi a, sodales efficitur quam. Phasellus ex
velit, porttitor vestibulum consectetur eu, maximus et nisi.

Nulla pharetra augue ex, quis scelerisque sem iaculis id. Aliquam in
tincidunt quam. Praesent ac laoreet elit. Aenean varius ullamcorper
dolor ac finibus. Proin est sapien, tempor nec mollis ut, ultricies et
ante. Maecenas hendrerit velit non augue rutrum, mollis pharetra nisl
auctor. Ut nisl mauris, porta ut nisi ut, elementum tristique nibh. 
\clearpage
\layout
\end{document}

and the resulting layout:

enter image description here

Now please compare the result above with this code

\documentclass{article}

\usepackage[a4paper]{geometry}
\usepackage{layout}
% from https://tex.stackexchange.com/questions/173244/to-display-the-lengths-in-millimeters-by-default
\makeatletter
\renewcommand*{\lay@value}[2]{%
  \strip@pt\dimexpr0.351459\dimexpr\csname#2\endcsname\relax\relax mm%
}
\makeatother


\begin{document}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas nec
lobortis justo. Praesent ut scelerisque risus, sit amet mollis erat.
Fusce at lacus at libero consequat consectetur.

Proin at vehicula ligula. Vivamus quis ligula id lacus aliquet
ultricies. Vivamus tristique, velit vestibulum tincidunt fermentum,
lacus sem euismod risus, ut volutpat augue dolor vitae est. Proin odio
nunc, sollicitudin quis nisi a, sodales efficitur quam. Phasellus ex
velit, porttitor vestibulum consectetur eu, maximus et nisi.

Nulla pharetra augue ex, quis scelerisque sem iaculis id. Aliquam in
tincidunt quam. Praesent ac laoreet elit. Aenean varius ullamcorper
dolor ac finibus. Proin est sapien, tempor nec mollis ut, ultricies et
ante. Maecenas hendrerit velit non augue rutrum, mollis pharetra nisl
auctor. Ut nisl mauris, porta ut nisi ut, elementum tristique nibh. 
\clearpage
\layout
\end{document} 

and its result ([a4paper] is option of package geometry):

enter image description here

You see the different length for \textheight and \textwidth? At last that means that geometry uses different standard margins than class article without geometry.

Now have please a look to this code, having option [a4paper] only placed as class option for article:

\documentclass[a4paper]{article}

\usepackage{geometry}
\usepackage{layout}
% from https://tex.stackexchange.com/questions/173244/to-display-the-lengths-in-millimeters-by-default
\makeatletter
\renewcommand*{\lay@value}[2]{%
  \strip@pt\dimexpr0.351459\dimexpr\csname#2\endcsname\relax\relax mm%
}
\makeatother


\begin{document}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas nec
lobortis justo. Praesent ut scelerisque risus, sit amet mollis erat.
Fusce at lacus at libero consequat consectetur.

Proin at vehicula ligula. Vivamus quis ligula id lacus aliquet
ultricies. Vivamus tristique, velit vestibulum tincidunt fermentum,
lacus sem euismod risus, ut volutpat augue dolor vitae est. Proin odio
nunc, sollicitudin quis nisi a, sodales efficitur quam. Phasellus ex
velit, porttitor vestibulum consectetur eu, maximus et nisi.

Nulla pharetra augue ex, quis scelerisque sem iaculis id. Aliquam in
tincidunt quam. Praesent ac laoreet elit. Aenean varius ullamcorper
dolor ac finibus. Proin est sapien, tempor nec mollis ut, ultricies et
ante. Maecenas hendrerit velit non augue rutrum, mollis pharetra nisl
auctor. Ut nisl mauris, porta ut nisi ut, elementum tristique nibh. 
\clearpage
\layout
\end{document}

and its result. You see it is the same result in length we have after using option [a4paper] only with geometry:

enter image description here

So the conclusion is to use option a4paper as class option, because all other packages get noticed about this option, if it is related to them ...

Class article uses other standard margins than geometry, that's the reason for the differences you get.

1

The outputs are different because geometry updates the layout (stock margins) in addition to the page size. In contrast, loading a document class like article with a4paper only changes the paper dimensions. See Default margins for geometry package.

Here's the only changes imposed by \documentclass[a4paper]{article}:

\DeclareOption{a4paper}
   {\setlength\paperheight {297mm}%
    \setlength\paperwidth  {210mm}}

I prefer to load any geometry-related settings with the package since that's what you're loading it for. That is, using the following sequence:

\usepackage{geometry}
\geometry{
  % <geometry settings>
}

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.