CSS

Thursday, December 15, 2011

LaTeX Macros for Personal Notes

So last time, I discussed the notion of personal mathematical notes (as opposed to expository mathematical notes) and would like to discuss some LaTeX macros which enable writing personal notes.

The basic scheme is to write in "chunks" (to borrow a term from literate programming). We've all seen examples of this, Bagchi and Wells refer to it as "labeled style" in their paper Varieties of Mathematical Prose

But each "chunk" is a self-contained concept, example, discussion, etc.

For a good example of this writing style, see On Euler's Footsteps.

LaTeX Code

I am taking CWEB's style. So, the code listing I have is as follows:

% chunk.sty
\ProvidesPackage{chunk}[2011/12/15 Cunking commands for personal notes]
\makeatletter

\@ifundefined{@addpunct}{
  \def\@addpunct#1{\ifnum\spacefactor>\@m \else#1\fi}
  }{}

\newcounter{chunk@ctr}

\newcommand\M{\medbreak\noindent%
  \refstepcounter{chunk@ctr}%
  \textbf{\thechunk@ctr\@addpunct{.}}\quad\ignorespaces}

% deprecated macro:
% \newcommand\N[1]{\M\textbf{#1\@addpunct{.}}\quad\ignorespaces}

% superior implementation:

\def\N{\@ifstar
        \NStar%
        \NNoStar%
}
\def\NStar#1{\medbreak\noindent\textbf{#1\@addpunct{.}\quad}\ignorespaces}
\def\NNoStar#1{\M\textbf{#1\@addpunct{.}\quad}\ignorespaces}

% permits writing \N*{Un-numbered chunk} for a chunk
% without a numeric label!

\makeatother
% end of cunk.sty

Note that it is completely self-contained code, and you do not need amsgen package. If you already loaded it, then no worries!

Each chunk is numbered. We use \M for unlabeled chunks, and \N{My favorite chunk!} for labeled chunks (which is labeled "My favorite chunk!").

So lets write up some example usage:

\documentclass{article}
\usepackage{chunk} % make it in the same directory
% or put it in ~/texmf/tex/latex/ and run "sudo texhash"
\title{Example Notes}
\author{Alex Nelson}
\date{\today}
\begin{document}
\maketitle

\N{Introduction}
Today we will solve all the problems in the universe. 

\M Lorem ipsum dolor sit amet, consectetur adipisicing elit, 
sed do eiusmod tempor incididunt ut labore et dolore magna 
aliqua. Ut enim ad minim veniam, quis nostrud exercitation 
ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis 
aute irure dolor in reprehenderit in voluptate velit esse 
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat 
cupidatat non proident, sunt in culpa qui officia deserunt 
mollit anim id est laborum.

\N{Conclusion?} Nobel Prize please!

\end{document}

As far as bugs, I don't think there are any...it's too minimalistic!

To Do

The chunk counter is rather minimalistic, and doesn't count within any section. This has to be changed by hand if the user wants to use these macros and number chunks within each chapter...

In the time honored tradition of mathematicians, this exercise is left for the reader!

No comments:

Post a Comment