3

The code for the .tex file:

\documentclass[12pt]{sletter}

%% to use image
\usepackage{tabularx}


\usepackage{array}
\begin{document}
\begin{letter}{....}
\opening{Dear Sir or Madam: }

...

\closing{Regards,}
\end{letter}

\end{document}

The code for sletter:

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{sletter}

%pass-in of letter.cls
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{letter}}
\ProcessOptions
\LoadClass[]{letter} %%changed for letter sized paper

%set margins/text
%\usepackage[letterpaper,twoside,inner=0pt,outer=0pt]{geometry}
\setlength{\textheight}{215mm}
\setlength{\textwidth}{160mm}
\setlength{\oddsidemargin}{0pt}
\setlength{\topmargin}{-20pt}
\setlength{\headsep}{35pt}
\setlength{\textwidth}{160mm}
\setlength{\evensidemargin}{0pt}
\setlength{\headheight}{12pt}

%hack


%from <http://stackoverflow.com/questions/877597/how-do-you-change-the-document-font-in-latex>, to access SYS fonts
\usepackage[xetex]{graphicx}
\usepackage{fontspec,xunicode}
\defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
\setmainfont[Scale=0.95]{Times New Roman}
%\setmonofont{Lucida Sans Typewriter}
  • You really don't need the letter class (or any modifications of it) for writing elementary letters. article can mimic it just as well, and then you're free to do what you want, rather than conform to the specification of letter. – Werner Feb 4 '14 at 2:41
3

Since sletter internally uses the letter document class, you can redefine the \opening and \closing commands as defined in letter.cls. Add the following lines to sletter.cls:

\renewcommand*{\opening}[1]{\ifx\@empty\fromaddress
  \thispagestyle{firstpage}%
    {\@date\par}%
  \else  % home address
    \thispagestyle{empty}%
    {\begin{tabular}{@{}l@{}}\ignorespaces
      \fromaddress \\*[2\parskip]%
      \@date \end{tabular}\par}%
  \fi
  \vspace{2\parskip}%
  {\raggedright \toname \\ \toaddress \par}%
  \vspace{2\parskip}%
  #1\par\nobreak}
\renewcommand{\closing}[1]{\par\nobreak\vspace{\parskip}%
  \stopbreaks
  \noindent
  \parbox{\indentedwidth}{\raggedright
       \ignorespaces #1\\[6\medskipamount]%
       \ifx\@empty\fromsig
           \fromname
       \else \fromsig \fi\strut}%
   \par}

Here's the new file sletter.cls:

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{sletter}

%pass-in of letter.cls
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{letter}}
\ProcessOptions
\LoadClass[]{letter} %%changed for letter sized paper

%set margins/text
%\usepackage[letterpaper,twoside,inner=0pt,outer=0pt]{geometry}
\setlength{\textheight}{215mm}
\setlength{\textwidth}{160mm}
\setlength{\oddsidemargin}{0pt}
\setlength{\topmargin}{-20pt}
\setlength{\headsep}{35pt}
\setlength{\textwidth}{160mm}
\setlength{\evensidemargin}{0pt}
\setlength{\headheight}{12pt}

%hack


%from <http://stackoverflow.com/questions/877597/how-do-you-change-the-document-font-in-latex>, to access SYS fonts
\usepackage[xetex]{graphicx}
\usepackage{fontspec,xunicode}
\defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
\setmainfont[Scale=0.95]{Times New Roman}
%\setmonofont{Lucida Sans Typewriter}

\renewcommand*{\opening}[1]{\ifx\@empty\fromaddress
  \thispagestyle{firstpage}%
    {\@date\par}%
  \else  % home address
    \thispagestyle{empty}%
    {\begin{tabular}{@{}l@{}}\ignorespaces
      \fromaddress \\*[2\parskip]%
      \@date \end{tabular}\par}%
  \fi
  \vspace{2\parskip}%
  {\raggedright \toname \\ \toaddress \par}%
  \vspace{2\parskip}%
  #1\par\nobreak}
\renewcommand{\closing}[1]{\par\nobreak\vspace{\parskip}%
  \stopbreaks
  \noindent
  \parbox{\indentedwidth}{\raggedright
       \ignorespaces #1\\[6\medskipamount]%
       \ifx\@empty\fromsig
           \fromname
       \else \fromsig \fi\strut}%
   \par}

And with this .tex file:

\documentclass[12pt]{sletter}

\signature{Joe Bloggs}
\address{21 Bridge Street \\ Smallville \\ Dunwich DU3 4WE}

\begin{document}

\begin{letter}{Director \\ Doe \& Co \\ 35 Anthony Road
\\ Newport \\ Ipswich IP3 5RT}
\opening{Dear Sir or Madam:}

I am writing to you on behalf of the Wikipedia project (http://www.wikipedia.org/),
an endeavour to build a fully-fledged multilingual encyclopaedia in an entirely
open manner, to ask for permission to use your copyrighted material.

That said, allow me to reiterate that your material will be used to the noble end of
providing a free collection of knowledge for everyone; naturally enough, only if you
agree. If that is the case, could you kindly fill in the attached form and post it
back to me? We shall greatly appreciate it.

Thank you for your time and consideration.

I look forward to your reply.

\closing{Yours Faithfully,}

\ps{P.S. You can find the full text of GFDL license elsewhere}
\encl{Copyright permission form}

\end{letter}

\end{document}

You get:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.