Once again this is a bit more than what you are asking for, but this is an ideal situation where using keys can stream-line things very nicely (after an initial overhead of constructing them).
I take a four pronged approach here.
I define the keys I will use.
I define a macro for the user interface. In this case \myarticle
that takes one argument for the key-value pairs. This macro then calls another macro for handling the formatting.
I define an internal macro \my@article
that determines what code to execute. This is a bit of a middleman, but can be very nice for quickly reformatting, changing the order of presentation, or just debugging.
For each aspect of the final environment I define a macro to handle the formatting. Each of these macros follows the naming convention \jeroen@build@...
. There's one defined for the date, another for review, and a third for to do. These are the macros that you would redefine if you want to change the presentation of the content.
For the keys, I illustrate three different approaches:
- Use of
.initial
to use pgfkeys
internal mechanism for storing and recalling a key value.
- Use of
.store in
to store the value of the key in a user defined macro.
- Use of
.code
to execute some code when a particular key is called.
I feel .code
is the most interesting of these in the current context because, in the following MWE, it will allow the user to opt out of using a review list. Also, for front matter I do something similar: the key value is passed as for the other keys--as though it were a list--but its final formatting is just as a normal paragraph.
Here's the MWE:
\documentclass{article}
%%-------------------------------------------
%% packages you need for this to work
\usepackage{pgfkeys}
\usepackage{pgffor}
%%-------------------------------------------
%% package OP requested
\usepackage{enumitem}
%%-------------------------------------------
\makeatletter
%%-------------------------------------------
%% These next two macros are not entirely
%% necessary. I put them here to illustrate
%% further possibilities about how `pgfkeys`
%% can manage keys.
\def\jeroen@review@items{}
\def\jeroen@to@do@items{}
\newif\ifjeroen@review@
\newif\ifjeroen@front@matter@
%% define the keys
\pgfkeys{/jeroen/article/.cd,
date/.initial=,
front matter/.code=\jeroen@front@matter@code{#1},
review items/.code=\jeroen@review@code{#1},
to do items/.store in=\jeroen@to@do@items,
}
%% define the macro for user interface
\newcommand\myarticle[1]{%%
\bgroup
\pgfkeys{/jeroen/article/.cd,#1}%%
\build@my@article
\egroup
}
\def\jeroen@front@matter@code#1{%%
\jeroen@front@matter@true
\def\jeroen@front@matter@content{#1}}
\def\jeroen@review@code#1{%%
\jeroen@review@true
\def\jeroen@review@items{#1}}
%% an internal macro for initially handling
%% and formatting the content.
\def\build@my@article{%%
\jeroen@build@date
\jeroen@build@front@matter
\jeroen@build@review
\jeroen@build@to@do
}
%% macro for formatting the "date"
%% If you want to change how the "date" is presented
%% this is the code you should tweak.
\def\jeroen@build@date{%%
\section*{\pgfkeysvalueof{/jeroen/article/date}}}
%% macro for formatting the "front matter"
%% If you want to change how the "front matter" is
%% presented this is the code you should tweak.
\def\jeroen@build@front@matter{%%
\ifjeroen@front@matter@
\foreach \mystuff in \jeroen@front@matter@content
{\mystuff\space}%%
\vspace{2ex}\par
\fi
}
%% macro for working with the list of "review" items
%% This is the code you should tweak to change how
%% the "review" is formatted.
\def\jeroen@build@review{%%
\ifjeroen@review@
\noindent
\textbf{Review:}
\begin{enumerate}%%
\foreach \reviewitem in \jeroen@review@items
{%%
\item \reviewitem
}%%
\end{enumerate}
\fi
}
%% macro for working iwth the list of "to do" items
%% This is the code you should tweak to change how
%% the "to do" is formatted.
\def\jeroen@build@to@do{%%
\noindent
\textbf{To do:}
\begin{itemize}
\foreach \todoitem in \jeroen@to@do@items
{%%
\item \todoitem
}%%
\end{itemize}
}
\makeatother
\begin{document}
\myarticle{
date={November 29, 2013},
review items={
{turkey},
{stuffing},
{yams}
},
to do items={
{apples},
{pears},
{peaches},
{ice cream}}
}
\myarticle{
date={November 30, 2013},
front matter={
{The quick brown fox jumped over the lazy dog.},
{Pack my box with five dozen liquor jugs.}},
to do items={
{carrots},
{celery},
{parsnips},
{ice cream!!}}
}
\end{document}
I should note a couple things:
- The brackets in
date={November 30, 2013}
are necessary to prevent pgfkeys
from thinking the comma in the date is the separator for the keys.
- The other keys should be formatted as:
{ {item 1} , {item 2} , {item 3} , ...}
Granted, this is a lot of initial work to do. But in the end it provides with a great deal of latitude for how you finally format the content.
\todo
macro splitting it in the middle. One question: where is the title in your example?\section*
part. I don't know whether this is a good way to define a title, but it works for now. Anyway, the title is always a date.