3

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
Bernhard
  • 1,248
  • \fontsize{sizea}{sizeb}\selectfont as quick and dirty solution –  Feb 19 '14 at 16:11
  • Tried that, both inside and outside the preamble. No joy. Is there more to using this solution than just including, say, \fontsize{10pt}{12pt}\selectfont in the preamble? – Bernhard Feb 19 '14 at 16:19
  • You could store that command in your sty file, by loading it, the command will be applied. Another rather unsatisfactory way would be to redefine \normalsize –  Feb 19 '14 at 16:33
  • Even by putting the \fontsize etc. command into my package, I don't get the desired result. I think it MWE time, I've edited my original question to include it. – Bernhard Feb 19 '14 at 16:46
  • Yeah, had the arguments backwards. Sorry about that, edited it in the main post seconds later, but you were too quick for me. – Bernhard Feb 19 '14 at 17:03
  • @jon The quick-and-dirty solution using \AtBeginDocument{\fontsize etc. does a fairly good job, but at least on my configuration (pdflatex, texlive 2011) it only adjusts regular text. Text that is enclosed in {\large ...} is unaltered. It'd be great to have a solution without that limitation – Bernhard Feb 19 '14 at 17:18
  • In that case, I'd do it differently: \newif\ifprinttwoside \printtwosidetrue \ifprinttwoside \documentclass{article} \else \documentclass[12pt]{article} \fi (note: default is \printtwosidefalse). If you like, you can pass the \newif\ifprinttwoside \printtwosidetrue as part of the call to latex. – jon Feb 19 '14 at 18:19
  • @jon: your solution just now looks like it assumes that I invoke the twoside option at some point---I don't really want to do that. I just want to have the regular options for the class call in the magnified version (except, of course, for the larger font). – Bernhard Feb 19 '14 at 23:42
  • Why don't you use a custom class with an option duplex which you can switch as required. Your class can then load article with the relevant options depending on the options you pass. – cfr Feb 20 '14 at 03:49

1 Answers1

1

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.)

jon
  • 22,325