[Tex/LaTex] Changing Font Size globally via package

fontsizepackage-writing

I'd like to write a package that performs the following tasks (it's essentially reformatting the document to make it suitable for being printed 2-pages-side-by-side on a printer):
– adjust the margins to make them smaller
– adjust the global fontsize of the document

I know how to do the first (adjusting margins), but am stumped on how to adjust the second. What I'd like is to have the same effect as specifying

\documentclass[12pt]{article}

at the beginning of the document. But I'd like to achieve this effect by calling a package.

I've looked at the question How to change font size mid-document?, but could not make it work, by trying

\input{size12.clo} 

either in the pre-amble or in the main body of the document).

I'd like accomplish all of this without wrapping my document in any extra environments, etc.

I've also tried using the \fontsize command, to no effect (you can see my attempt in the bare bones package below).

Here are the MWE. First, the main document

\documentclass{article}

\usepackage{lipsum} % For filler text

\usepackage{double-duplex} % This is the package I'd like to use to alter the size---the target of my question here.

\begin{document}

\lipsum[1-3]
\end{document}

And then the package, which I've called double-duplex.sty

\ProvidesPackage{double-duplex}

\fontsize{12pt}{12pt}\selectfont

Best Answer

Here's one solution: if you are using the default article class at 10 pt (default), you can copy the relevant parts of size12.clo into your double-duplex.sty and change everything to a \renewcommand:

\documentclass{article}
\usepackage{filecontents}
\begin{filecontents*}{double-duplex.sty}
\ProvidesPackage{double-duplex}
% REnewed from size12.clo
\renewcommand\normalsize{%
   \@setfontsize\normalsize\@xiipt{14.5}%
   \abovedisplayskip 12\p@ \@plus3\p@ \@minus7\p@
   \abovedisplayshortskip \z@ \@plus3\p@
   \belowdisplayshortskip 6.5\p@ \@plus3.5\p@ \@minus3\p@
   \belowdisplayskip \abovedisplayskip
   \let\@listi\@listI}
\normalsize
\renewcommand\small{%
  \@setfontsize\small\@xipt{13.6}%
  \abovedisplayskip 11\p@ \@plus3\p@ \@minus6\p@
  \abovedisplayshortskip \z@ \@plus3\p@ 
  \belowdisplayshortskip 6.5\p@ \@plus3.5\p@ \@minus3\p@ 
  \def\@listi{\leftmargin\leftmargini 
              \topsep 9\p@ \@plus3\p@ \@minus5\p@
              \parsep 4.5\p@ \@plus2\p@ \@minus\p@ 
              \itemsep \parsep}%
  \belowdisplayskip \abovedisplayskip }

\renewcommand\footnotesize{%
  \@setfontsize\footnotesize\@xpt\@xiipt 
  \abovedisplayskip 10\p@ \@plus2\p@ \@minus5\p@ 
  \abovedisplayshortskip \z@ \@plus3\p@
  \belowdisplayshortskip 6\p@ \@plus3\p@ \@minus3\p@
  \def\@listi{\leftmargin\leftmargini 
              \topsep 6\p@ \@plus2\p@ \@minus2\p@
              \parsep 3\p@ \@plus2\p@ \@minus\p@ 
              \itemsep \parsep}%
  \belowdisplayskip \abovedisplayskip }
\renewcommand\scriptsize{\@setfontsize\scriptsize\@viiipt{9.5}}
\renewcommand\tiny{\@setfontsize\tiny\@vipt\@viipt}
\renewcommand\large{\@setfontsize\large\@xivpt{18}}
\renewcommand\Large{\@setfontsize\Large\@xviipt{22}}
\renewcommand\LARGE{\@setfontsize\LARGE\@xxpt{25}}
\renewcommand\huge{\@setfontsize\huge\@xxvpt{30}}
\end{filecontents*}
\usepackage[T1]{fontenc}
\usepackage{lipsum} % For filler text

%\usepackage{double-duplex} 

\begin{document}

\section{A Section}
\lipsum*[1-3]%
\footnote{\lipsum[4]}

\end{document}

Uncomment \usepackage{double-duplex} to 'switch' to 12 pt.

The following, however, would be my choice:

\newif\ifxiipt
% \xiipttrue
\ifxiipt
  \documentclass[12pt]{article}
\else
  \documentclass{article}
\fi

\usepackage[T1]{fontenc}
\usepackage{geometry}
\ifxiipt
  \geometry{<smaller margin settings>}
\else
  \geometry{<normal margin settings>}
\fi
\usepackage{lipsum} % For filler text

\begin{document}

\section{A Section}
\lipsum*[1-3]%
\footnote{\lipsum[4]}
\end{document}

To effect the same changes, simply uncomment the \xiipttrue. (The reason I prefer this solution is that it will probably make it easier to do different things for the bigger-font-smaller-margins version or the normal version beside just changing the margins or the font size.)

Related Question