LaTeX example – creating a lecture note

Tuesday, April 15th, 2008
Advertisement

Subscribe.
Enter your email:

This LaTeX example will create an automatic exercises numbering as well as the problems in each exercise. It is useful for creating lecture notes.

Example

\documentclass[a4paper,12pt]{book}

\newcounter{exercisenum}[section]
\renewcommand{\theexercisenum}{\arabic{exercisenum}}
\newenvironment{exercise}
{
\stepcounter{exercisenum}

\vspace{1pc}\par\noindent\textbf{Exercise \thesection.\theexercisenum}\par
\begin{flushleft}
}
{
\end{flushleft}
}

\newcounter{problemnum}[exercisenum]
\renewcommand{\theproblemnum}{\arabic{problemnum}}
\newcommand{\problem}
{
\stepcounter{problemnum}
\theproblemnum.
}

\newcounter{secondproblemnum}[problemnum]
\renewcommand{\thesecondproblemnum}{\alph{secondproblemnum}}
\newcommand{\secondproblem}
{
\stepcounter{secondproblemnum}
\thesecondproblemnum)
}

\begin{document}

\chapter{Introduction}

\section{Function}

\begin{exercise}

\begin{tabular}{lll}
\multicolumn{3}{l}{Solve for $x$.} \\
\problem $x + 3 = 4$ & \problem $x + 3 = 4$ & \problem $x + 3 = 4$ \\
\multicolumn{3}{l}{
   \problem \secondproblem $x + 11 = 0$
   \secondproblem $x + 11 = 0$
   \secondproblem $x + 11 = 0$
} \\
\problem $x + 3 = 4$ & \problem $x + 3 = 4$ & \problem $x + 3 = 4$ \\
\problem $x + 3 = 4$ & \problem $x + 3 = 4$ & \problem $x + 3 = 4$ \\
\end{tabular}

\end{exercise}

\begin{exercise}

\problem
Cras egestas rhoncus mi. Donec sed orci rhoncus risus consequat
posuere. Maecenas ut lorem at neque imperdiet varius. Mauris imperdiet
arcu a eros. Proin elementum elementum nibh.

\problem Lorem ipsum dolor sit amet, consectetuer adipiscing elit. In eget magna.

\end{exercise}

\end{document}

The output will be as below


If you are new here, you might want to subscribe to the RSS feed or newsletter.

Enter your email address:

Creates the exact copy of your hard disk and allows you to instantly restore the entire machine.
New Acronis True Image Home 2010 is the most reliable and easy in use backup solution. Now with online backup option!
15% Discount Code: FMAATIH2010

What else?

Like this article? Share it

 Digg  del.icio.us  TwitThis  Facebook  Reddit  StumbleUpon

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>