# LaTeX document without \documentclass

I need to create a really simple document template for other people to fill in and compile (e.g., they need to provide a name and email address). I could distribute it as a .cls file and a template .tex file, but I think it might be easier to just distribute it as a single file.

It appears that one can compile a document without a \documentclass without any warnings. For example, despite not having a \documentclass line, the following is a complete MWE:

\renewcommand\normalsize{\fontsize{10pt}{12pt}\selectfont}
\begin{document}
Hello world
\end{document}


Where the entire "class" is \renewcommand\normalsize{\fontsize{10pt}{12pt}\selectfont}. What are the drawbacks of defining the entire "class" within the .tex file and not using a \documentclass line?

EDIT

To add a little more about what I am doing. I created a custom class that was not based on any other class. I then took David Carlisle idea

and changed

\documentclass{myclass}


to

\documentclass{article}
\makeatletter
\makeatother


but this caused conflicts of things that were defined in both myclass and the article class. It probably would have been better to use the minimal class, but I realized that I didn't need the \documentclass{article} before I thought about the minimal class.

-
For one, inability to use \usepackage. –  cyberSingularity Jan 21 '13 at 14:49
I thought \documentclass was mandatory :P –  Willian Paixao Jan 21 '13 at 15:00
It might not be good LaTeX style, but Daniel's code actually works ;) –  Stephan Lukasczyk Jan 21 '13 at 15:01
Me too, which is why I asked. –  StrongBad Jan 21 '13 at 15:13
texdoc source2e and search for \normalsize is used to produce an error, so if you define it you can run a classless document. –  Yiannis Lazarides Jan 21 '13 at 15:15

If you look at minimal.cls you will see it does a bit more than just set the normal font size:

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{minimal}[2001/05/25 Standard LaTeX minimal class]

\renewcommand\normalsize{\fontsize{10pt}{12pt}\selectfont}

\setlength{\textwidth}{6.5in}
\setlength{\textheight}{8in}

\pagenumbering{arabic}  % but no page numbers are printed because:
\pagestyle{empty}       % this is actually already in the kernel


In particular things are likely to go very wrong if you don't set \textheight and \textwidth.

However there is no advantage to not using a real class such as article and many disadvantages.

If you just want to distribute a single template file and no class file use a format like

\documentclass{article}

\makeatletter

\makeatother

\begin{document}

\end{document}


Looking at the edited question, if your custom code does set up everything then you could just stick it at the top as you said, the problems with minimal then don't apply. Perhaps better though would be to use a form

\begin{filecontents}{myclass.cls}
\end{filecontents}
\documentclass{myclass}
\begin{document}
...
\end{document}


That way the file can easily be switched between assuming myclass is already installed and including it inline. Such ad-hoc distribution of local class and package files was one of the main motivations for adding filecontents to LaTeX2e.

-
No, I promise you, it isn't. minimal is the smallest class I could make that would let you test the new (at the time) package loading mechanism but if you use it for actual documents things will go wrong. Math isn't set up, font size commands are not set up, figures/tables are not set up, more or less anything that any package that you load expects has not been set up. –  David Carlisle Jan 21 '13 at 16:25
see edited answer. –  David Carlisle Jan 21 '13 at 16:57
If you look at mininmal.cls... Should be minimal. –  Faheem Mitha Jan 21 '13 at 17:33
@FaheemMitha thanks Werner fixed it. –  David Carlisle Jan 21 '13 at 18:41

I need to create a really simple document template for other people to fill in and compile.

I am not sure what you after, as to why the user needs to compile. The minimal check that LaTeX does to see if a class is defined is to produce an error if \normalsize has not been redefined see source2e, ltfntcmd.dtx.

If you really want to go minimalistic go pure TeX.

 J. Smith, myemail@goom.com
\bye

-

As I've tested some quite basic environments that came in my mind, there is pretty much no functionality at all. All environments and commands that are not included in plain TeX won't work. So you have no possibilities to produce tables or lists with LaTeX. If this works for your special purpose, it's fine.

As you've mentioned, there is not even an \usepackage available, one could not do very much. It's just up to you if the functionallity you get by this very reduced code is working.

Maybe you try some pretty small document classes like minimal or standalone. With your code it's just one extra line, to load it, but you earn much more functionallity

-
I thought macros like \renewcommand were part of LaTeX and not plain TeX? –  StrongBad Jan 21 '13 at 15:13
Daniel, you are right. But some plain TeX stuff works, if you try e.g. $\alpha$ ;-) –  Stephan Lukasczyk Jan 21 '13 at 15:18
@StephanLukasczyk That isn't plain TeX stuff, it is LaTeX stuff that has similar name/definition to the definition in plain. \alpha is defined in LaTeX by \DeclareMathSymbol{\alpha}{\mathord}{letters}{"0B} and in plain by \mathchardef\alpha="010B Actually with the default latex font setup these come to the same thing, but the actual sources of plain tex are not used at all in latex. –  David Carlisle Jan 21 '13 at 16:32
Thank you @DavidCarlisle, I didn't realize that yet, again I've learned something. –  Stephan Lukasczyk Jan 21 '13 at 22:24