# Setting fonts in preamble

I would like to know, how should I configure so that my latex configuration will set as follow:

• For sections and sub-sections, the font is san-serif.
• For contents, the font is Computer Modern and Latin Modern

I'm specifically interested in configuring like one article in this link regarding the fonts used.

How to set it in my preamble, so that I don't need to configure it over and over.

-

For standard document classes (e.g. article), use titlesec package or sectsty pacakage:

\documentclass{article}
\usepackage[sf,bf]{titlesec}
\usepackage{lmodern}

\begin{document}
\section{Test}
Blah bla.
\end{document}


or

\documentclass{article}
\usepackage{sectsty}
\allsectionsfont{\sffamily}
\usepackage{lmodern}

\begin{document}
\section{Test}
Blah bla.
\end{document}

-
\documentclass{scrartcl}
\usepackage[T1]{fontenc}
\usepackage{lmodern}

\begin{document}
\section{Blub}
text text text

\end{document}


Read the documentation of the class (scrguide) to learn how to change the settings.

-

If you really want no configuration in the document class then you can define your own class. The following is based n Ulrike's solution. Save it in a file called myclass.cls.

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{myclass}[2012/02/14 Shah's Class]

\DeclareOption*{%
\PassOptionsToClass{scrartcl}{\CurrentOption}%
}
\ProcessOptions\relax

\RequirePackage[T1]{fontenc}
\RequirePackage{lmodern}



Now you can use it as follows:

\documentclass{myclass}

\begin{document}
Hello world.
\end{document}


any options passed to myclass will be forwarded to the scrartcl class.

-

Have a look on the titlesec package. There are many opportunities for a change of the headline's layout.

-