# How to print the date in newlfm

I have set up my letter with the \usepackage{newlfm} and am very happy with it but are struggling with one minor detail. I want to print some information within the header, but can't seem to find a way to print the date that is defined by \dateset{}. The following code works without problems:

\documentclass[stdletter]{newlfm}
%%To-address data%%
\nameto{Jane Doe}
\addrto{123 Belch Street\\Belcherville\\USA}
\namefrom{John Doe}
\addrfrom{321 Belch Street\\Belcherville\\USA}
%%Letter setup%%
\dateset{\today}
\Lheader{To:~\printnameto}%
\Cheader{\today}%

\begin{document}

%%Greeting
\closeline{Yours faithfully}
\greetto{Dear Sir or Madam}

%%Letter
\begin{newlfm}

TEXT

\end{newlfm}
\end{document}


But when I redefine \dateset{}, the date in the header is not correct anymore.

\documentclass[stdletter]{newlfm}
%%To-address data%%
\nameto{Jane Doe}
\addrto{123 Belch Street\\Belcherville\\USA}
\namefrom{John Doe}
\addrfrom{321 Belch Street\\Belcherville\\USA}
%%Letter setup%%
\dateset{5 January 2011}
\Lheader{To:~\printnameto}%
\Cheader{\today}%

\begin{document}

%%Greeting
\closeline{Yours faithfully}
\greetto{Dear Sir or Madam}

%%Letter
\begin{newlfm}

TEXT

\end{newlfm}
\end{document}


The problem is, that there is a command \printnameto to print the content of the \nameto variable (which I used in \Lheader{}), but there seems to be no command to print the content of \dateset (which I would need for \Cheader{}). I know that I could change \Cheader{} manually, but in the end I want to setup the header in the letrinfo.tex file so I would appreciate to have a print method for that variable so that I do not have to change this file permanently.

## 1 Answer

\dateset stores its contents in a macro called \@xdate, which you can use in the following way:

\documentclass[stdletter]{newlfm}
%%To-address data%%
\nameto{Jane Doe}
\addrto{123 Belch Street\\Belcherville\\USA}
\namefrom{John Doe}
\addrfrom{321 Belch Street\\Belcherville\\USA}
%%Letter setup%%
\dateset{5 January 2011}
\Lheader{To:~\printnameto}%
\makeatletter
\Cheader{\@xdate}%
\makeatother
\begin{document}

%%Greeting
\closeline{Yours faithfully}
\greetto{Dear Sir or Madam}

%%Letter
\begin{newlfm}

TEXT

\end{newlfm}
\end{document}


For a reference in terms of the use of @ in macros, see What do \makeatletter and \makeatother do?

I have always been a proponent against using the letter (or other, including newlfm) class. It's restrictive in that you tend to perform so many settings in the preamble and then have to fiddle with adjusting things to suit your needs in the main document body. In light of that, here's an article implementation that matches your newlfm document:

\documentclass{article}

% Page layout content
\usepackage[margin=1in,vmargin=0.75in]{geometry}

% Header content
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}% Clear header/footer
\fancyhead[L]{To: Jane Doe}
\fancyhead[C]{5 January 2011}
\renewcommand{\headrulewidth}{1pt}
\renewcommand{\footrulewidth}{1pt}

% Document body settings
\setlength{\parindent}{0pt}

\begin{document}

\vspace*{2cm}

\hfill
5 January 2011

\bigskip

\hfill
\begin{tabular}{@{}l@{}}
321 Belch Street \\
Belcherville \\
USA
\end{tabular}

\bigskip

\begin{tabular}{@{}l@{}}
Jane Doe \\
123 Belcher Street \\
Belcherville \\
USA
\end{tabular}

\bigskip

Dear Sir or Madam

\bigskip

TEXT

\bigskip

\hfill
\begin{tabular}{@{}l@{}}
Yours faithfully \\[5\normalbaselineskip]
John Doe
\end{tabular}

\end{document}


Of course this could be extended to include content in macros for general use throughout the document (similar to \addrto, \addrfrom and \dateset). However, for now, I'm only showing the alternative.

Specifically for \dateset one could use isodate or datetime2 to manage the dates (perhaps change \today and use it throughout the document).