I am using a custom LaTeX document class for my thesis which is derived from the report class. I'd like to set the default size of the font to 12pt, and still have the option to change it (to 10pt) via the \documentclass command. How can I do it?
- 185
-
4Have a look at Difference between \LoadClass and \LoadClassWithOptions. – Stefan Kottwitz Jan 12 '12 at 16:19
-
The link above does not mention default options. – user1145885 Jan 12 '12 at 17:10
2 Answers
12pt is the default. The demo class is baz.cls
\RequirePackage{filecontents}
\begin{filecontents}{baz.cls}
\def\@@ptsize{12pt}
\DeclareOption{10pt}{\def\@@ptsize{10pt}}
\DeclareOption{11pt}{\def\@@ptsize{11pt}}
\DeclareOption{12pt}{\def\@@ptsize{12pt}}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{report}}
\ProcessOptions\relax
\LoadClass[letterpaper,oneside,onecolumn,final,openany,\@@ptsize]{report}
\end{filecontents}
\documentclass
%[10pt]
%[11pt]
{baz}
\usepackage{lipsum}
\begin{document}
\lipsum
\end{document}
If your modified documentclass file does not involve a \LoadClass call to LaTeX's report.cls file, it likely contains the following instruction shortly before the \ProcessOptions statement:
\ExecuteOptions{letterpaper,10pt,oneside,onecolumn,final,openany}
Change 10pt to 12pt in this instruction, save the documentclass file under a new name, and load this newly-modified documentclass file from now on. The default font size will now be 12pt, but this can be overridden by specifying 10pt -- or, for that matter, 11pt -- as an option. Of course, specifying the 12pt option will now simply duplicate the default behavior of this document class.
Addendum: If the modified class file you're working with executes a \LoadClass call to the report.cls LaTeX document class, you may want to try modifying \LoadClass{report} to \LoadClassWithOptions[12pt]{report}.
- 506,678
-
that is a command in the original class and one should do all modifications not int the original class! See Stefans comment ... – Jan 12 '12 at 16:32
-
@Herbert: Thanks for this. I would definitely never suggest modifying an original class file. However, the OP's question seemed to indicate that he/she is working with a modified (hacked?!) version of the
reportdocument class which -- in all likelihood -- does not perform either a\LoadClassor a\LoadClassWithOptionscall toreport.cls. However, just in case that this assumption is incorrect, I'll modify my answer to make clear that the OP should save his/her further-customized documentclass file name under a new name. – Mico Jan 12 '12 at 16:36 -
\ExecuteOptions does not seem to work! I have put it in my cls file with 12pt option, but it still takes the default value as 10pt. Of course, changing the option in the latex document works. BTW, the option declarations in my cls file appear after the \LoadClass command -- is that a problem? – user1145885 Jan 12 '12 at 16:46
-
@Mico: I am not modifying the report.cls file. I am using \LoadClass to load report.cls. – user1145885 Jan 12 '12 at 16:50
-
OK, I see that the modified class file you have doesn't conform to my initial assumptions. See my modified answer for an alternative method. – Mico Jan 12 '12 at 16:52
-
It might be helpful if you posted the actual code you use -- I seem to be laboring under incorrect assumptions about the structure of your modified documentclass file. :-( – Mico Jan 12 '12 at 16:57
-
@Mico: As I mentioned before, \ExecuteOptions have no effect! Does it matter where I put the commaand -- before or after the \LoadClass command? – user1145885 Jan 12 '12 at 16:58
-
@Mico: \LoadClassWithOptions[12pt]{report} does not compile. \LoadClass[12pt]{report} works, but it does not accept the option from main file.
Here is the structure of my code:
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{iiscthes}
– user1145885 Jan 12 '12 at 17:10\LoadClassWithOptions{report}
...
\ExecuteOptions{12pt}
\ProcessOptions\relax -
\LoadClassWithOptions{report}is the correct code! Everything is declared in the link from Stefan! – Jan 12 '12 at 17:10 -
@user1145885: I'm afraid that without seeing the code you're actually working with, it appears that I'm merely traipsing about in the dark. – Mico Jan 12 '12 at 17:19
-
@Mico: How can I send you the code? I pasted the relevant parts above, the the entire file is quite large! – user1145885 Jan 12 '12 at 17:25
-
@Herbert: It does not solve my problem -- changing the default behavior of the report class and still accepting options from the main latex file. – user1145885 Jan 12 '12 at 17:26
-
@user1145885: create a minimal template of your file and post it into your question, then we'll see. – Jan 12 '12 at 17:32
-
-
-