About
Shop
LaTeX
Software
Books
Gallery
News
Contact
Blog
Settings

Exercise 9: Writing a Letter using the newlfm class (Solution)

This is a solution to Exercise 9. You need the sample files people.csv and country-codes.csv. Alternatively, if you want to use data from the samples SQL database, remember to use datatooltk to import the data to a .dbtex file and load it using \DTLloaddbtex as described in Loading Data From a .dbtex File.

\documentclass[stdletter]{newlfm}

\usepackage[british]{babel}
\usepackage{datatool}

\DTLloaddb{people}{people.csv}
\DTLloaddb{countries}{country-codes.csv}

\newlfmP{orderfromtodate,sigcenter,addrfromphone,addrfromemail}

\newcommand*{\Id}{2}% customer id

\xDTLassignfirstmatch{people}{id}{\Id}{%
  \Surname=surname,%
  \Forenames=forenames,%
  \Title=title,%
  \AddressI=address1,%
  \AddressII=address2,%
  \Town=town,%
  \County=county,%
  \Postcode=postcode,%
  \CountryCode=country%
}
\xDTLassignfirstmatch{countries}{code}{\CountryCode}{\CountryName=name}

\nameto{\DTLifnullorempty{\Title}{}{\Title\ }\Forenames\ \Surname}
\addrto{%
\AddressI\\
\DTLifnullorempty{\AddressII}{}{\AddressII\\}\Town\\
\DTLifnullorempty{\County}{}{\County\\}\Postcode\\\CountryName
}

\namefrom{Mr Big Head}
\addrfrom{University of Somewhere\\Some City\\AB3 4YZ}
\emailfrom{big.head@somewhere.ac.uk}
\phonefrom{0123456789}

\regarding{A sample letter}

\begin{document}

\greetto{Dear \DTLifnullorempty{\Title}{\Forenames}{\Title} \Surname}
\closeline{Yours sincerely}

\cclist{Prof Important Person\\Dr Bor Ing}

\encllist{Photocopy of something interesting\\
   Photocopy of something rather dull}

\psitem{this is a postscript}

\begin{newlfm}
  This is an imaginary letter.

  This is the second paragraph of the letter.
\end{newlfm}

\end{document}

Download newlfm.tex or newlfm.pdf.

© 2015 Dickimaw Books. "Dickimaw", "Dickimaw Books" and the Dickimaw parrot logo are trademarks. The Dickimaw parrot was painted by Magdalene Pritchett.

Terms of Use Privacy Policy Cookies Site Map FAQs