Declaring document-wide font size outside of the document class command

I have a document, where I want two versions: one versions 10pt size and another version, 2 page to a side 12pt. So I currently have:

\documentclass[10pt,a4paper,oneside,openany,article]{memoir}
\newif\ifprintver
%\printvertrue

\ifprintver
\usepackage{pgfpages}
\pgfpagesuselayout{2 on 1}[a4paper,border shrink=1mm,landscape]
\fi


But I have to change the font size by hand. What can I put inside my \if that would change the font size document wide?

-

You can define your printver boolean before \documentclass and then use \documentclass inside an \ifprintver conditional:

\newif\ifprintver
%\printvertrue

\ifprintver
\documentclass[12pt,a4paper,oneside,openany,article]{memoir}
\else
\documentclass[10pt,a4paper,oneside,openany,article]{memoir}
\fi

% ... other code

\ifprintver
\usepackage{pgfpages}
\pgfpagesuselayout{2 on 1}[a4paper,border shrink=1mm,landscape]
\fi

\usepackage{lipsum}

\begin{document}

\lipsum[1-100]

\end{document}

-
Nice solution, but you should swap 10pt and 12pt in your code example. –  lockstep Jan 22 '11 at 23:58
@lockstep: thanks for noticing, I've made the change. –  Philippe Goutet Jan 23 '11 at 8:59
I'm beginning to learn that "the first line in your .tex file must be a document class" is a LIE!!!! Thanks for this. –  Seamus Jan 23 '11 at 12:07

The KOMA-Script-classes feature the macro \changefontsizes which allows you to change the main font size mid-document. This macro is also part of the scrextend package, which can (or at least it seems so) be made compatible with the memoir class.

\documentclass[10pt,a4paper,oneside,openany,article]{memoir}

\makeatletter
\let\@textsubscript\relax
\let\setfootnoterule\relax
\let\multiplefootnotemarker\relax
\makeatother

\usepackage{scrextend}

\newif\ifprintver
\printvertrue

\ifprintver
\usepackage{pgfpages}
\pgfpagesuselayout{2 on 1}[a4paper,border shrink=1mm,landscape]
\changefontsizes{12}
\fi

\usepackage{blindtext}

\begin{document}

\blindtext

\end{document}

-
Should be noted, that the correct way to do this is \KOMAoption{fontsize}{12pt}. changefontsizes is for calculating relative sizes like footnotesize for non-standard base sizes. Meaning the calculated values overwrite the default/standard values. But changing the fontsize means recalculating the type block. memoir has its own commands to deal with that. –  Johannes_B Jan 17 at 11:17

use a variable for the font size setting, e.g.

\documentclass[\FontSize, a4paper]{article}


and then run pdflatex with

pdflatex '\def\FontSize{12pt}\input{<your_file>.tex}'


now you can simply change the fontsize

-
You could also use pdflatex '\PassOptionsToClass{12pt}{article}\input{<your file>.tex}' –  Martin Scharrer Jan 30 '11 at 19:59

I am not sure if it is a good idea, just to set the font-size. There are more subtle differences, such as setting equation number sizing etc. What LaTeX does when processing the options is that it imports a file with the sizing and other related definitions with the extension .clo. You can try this:

\input{size12.clo}


For each class LaTeX uses slightly different conventions, for example in the book class, it uses bk10.clo.

-
The .clo files use \newcommand, so you have to undefine all of the sizing commands before this works. –  Will Robertson Jan 23 '11 at 0:45