%%% This template provides a starting point for DIN5008 compliant letters.
%%% It is based on the KOMA-Script class 'scrlttr2' and uses its built-in DIN5008 letter class option (lco) files.
%%% The template contains (almost) all options and settings available for typesetting a DIN5008 letter, and comprehensive comments shall help you understand their effects.
%%% The provided example letters are not particularly pretty, but designed to explain as many features as possible.
%%% It is up to you to make your letter look awesome.
%%% That said, please note that DIN5008 is not completely strict and you may deviate from the standard.
%%% I hope you will find this helpful!
%%% This template has been tested with TeX Live version 2022 and all popular compiler engines (i.e. LaTeX, pdfLaTeX, LuaLaTeX and XeLaTeX).
%%% This template is subject to the Unlicense:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This is free and unencumbered software released into the public domain. %
% %
% Anyone is free to copy, modify, publish, use, compile, sell, or %
% distribute this software, either in source code form or as a compiled %
% binary, for any purpose, commercial or non-commercial, and by any %
% means. %
% %
% In jurisdictions that recognize copyright laws, the author or authors %
% of this software dedicate any and all copyright interest in the %
% software to the public domain. We make this dedication for the benefit %
% of the public at large and to the detriment of our heirs and %
% successors. We intend this dedication to be an overt act of %
% relinquishment in perpetuity of all present and future rights to this %
% software under copyright law. %
% %
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, %
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF %
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. %
% IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR %
% OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, %
% ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR %
% OTHER DEALINGS IN THE SOFTWARE. %
% %
% For more information, please refer to <https://unlicense.org> %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass[
version=last, % use latest KOMA version
fontsize=11pt, % normal font size
paper=a4, % paper size
DIN5008A, % letter class option (lco) file provided by KOMA-Script (DIN5008B provides a larger header area on the first page than DIN5008A does, thus placing address field, the text area etc. further down)
ngerman,english, % supported languages (passed to packages like babel, isodate and blindtext; use command '\selectlanguage{<language>}' to switch between languages)
]{scrlttr2}
%%%%%%%%%%%%%%%%%%
% early packages %
%%%%%%%%%%%%%%%%%%
\usepackage{silence} % silence warnings
\WarningFilter{todonotes}{The length marginparwidth is less than}
\usepackage{iftex} % identify LaTeX engine (e.g. pdfLaTeX, LuaLaTeX or XeLaTeX)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% language and font settings %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\ifluatex\else\ifxetex\else
\usepackage[utf8]{inputenc} % only use with non-UTF8 based engines
\fi\fi
\usepackage[T1]{fontenc} % select font encoding
\usepackage{babel} % use command '\selectlanguage{<language>}' to select a language
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% general packages and settings %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{lipsum} % provides latin dummy text (preferred by many authors)
\usepackage{blindtext} % provides language-specific dummy text (better than lipsum, imho, as it reproduces language-specific characteristics)
\usepackage{hyperref} % links and document properties
\hypersetup{
hidelinks, % do not highlight links
}
\usepackage[iso]{isodate} % ISO format for dates
\usepackage{todonotes} % todo notes and missing figures
\usepackage{fontawesome} % icon set (fontawesome5 conflicts with KOMA option 'symbolicnames=fontawesome')
\usepackage{makecell} % text alignment and multi-line cells in tables
%%%%%%%%%%%%%%%%%%%
% custom commands %
%%%%%%%%%%%%%%%%%%%
%%% page numbering according to DIN5008
\providecaptionname{american,australian,british,canadian,english,newzealand,UKenglish,ukenglish,USenglish,usenglish}\dinpagemark{Page \thepage\ of \letterlastpage}
\providecaptionname{german,ngerman,austrian,naustrian,swissgerman,nswissgerman}\dinpagemark{Seite \thepage\ von \letterlastpage}
\renewcommand{\pagemark}{\usekomafont{pagenumber}\dinpagemark}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% KOMA-Script options and variables %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% KOMA-Script options specific to the scrlttr2 class
%%% For detailed information about these options and their available settings, please refer to the KOMA-Script documentation.
\KOMAoptions{
foldmarks=HmPv, % fold marks
firsthead=true, % header on first page
fromalign=right, % placement and alignment of sender information
fromrule=aftername, % whether and how to print a rule in sender information
symbolicnames=marvosym, % whether and which symbols to use for sender information
fromphone=true, % print sender phone number
frommobilephone=true, % print sender mobile phone number
fromfax=false, % print sender fax number
fromemail=true, % print sender e-mail address
fromurl=false, % print sender URL
fromlogo=false, % show sender logo
addrfield=true, % whether and how to print the address field
backaddress=underlined, % whether and how to print the return address
priority=false, % whether and how to print priority information
locfield=wide, % location field width
numericaldate=false, % prefer numerical date
refline=dateright, % how the reference line is laid out
subject=left, % positioning and alignment of the subject text
subject=untitled, % whether a subject title precedes the subject text
enlargefirstpage=false, % whether the first page is large (large = less area for footer)
firstfoot=true, % print footer on first page
parskip=half, % paragraph spacing
headsepline=true, % print rule below header on subsequent pages
footsepline=false, % print rule above footer on subsequent pages
pagenumber=footright, % position of page number (subsequent pages only)
}
%%% custom variables and lengths
%%% You can set values right here or later.
\newkomavar{fromaddressseparator}\setkomavar{fromaddressseparator}{,~} % separator for sender address lines
%%% (pseudo-)lengths
%%% All lengths are already defined by DIN5008 letter class option (lco) file but may be modified as desired.
%%% For more information about scrlttr2 lengths, please refer to the KOMA-Script documentation.
\setplength{firstheadhpos}{\useplength{toaddrhpos}} % align header left with address field
\setplength{firstheadwidth}{\dimexpr \paperwidth-\useplength{firstheadhpos}-20mm} % align header right with location field
%%% addressee
%%% (the KOMA variables 'toname' and 'toaddress' are derived from the mandatory argument to the letter environment)
\setkomavar{addresseeimage}{\missingfigure[figwidth=80mm,figheight=27.3mm]{addressee image}}
\setkomavar{toname}{\lipsum[1]} % These have no effect, because
\setkomavar{toaddress}{\lipsum[2]} % they will be overwritten anyway.
%%% return address
\setkomavar{backaddress}{Return Name\\address line 1\\address line 2\\address line 3}
%%% address postage print impression
%%% (only relevant if KOMA option 'addrfield=PP')
\setkomavar{fromzipcode}{ZIP code}
\setkomavar{PPcode}{P.P. code}
\setkomavar{PPdatamatrix}{\usekomafont{PPdata}P.P. data matrix}
%%% sender
\setkomavar{fromname}{Sender Name}
\setkomavar{fromaddress}{sender address line 1\usekomavar{fromaddressseparator}sender address line 2\usekomavar{fromaddressseparator}sender address line 3}
\setkomavar{fromphone}{\href{tel:sender-phone}{sender phone}}
\setkomavar{frommobilephone}{\href{tel:sender-mobile-phone}{sender mobile phone}}
\setkomavar{fromfax}{\href{fax:sender-fax}{sender fax}}
\setkomavar{fromemail}{\href{mailto:sender@email}{sender email}}
\setkomavar{fromurl}{\href{https://www.sender.url}{sender URL}}
\setkomavar{fromlogo}{\missingfigure[figwidth=60mm,figheight=40mm]{sender logo}}
\setkomavar{frombank}{sender bank}
\setkomavar{signature}{\usekomavar{fromname}}
%%% place and date
\setkomavar{place}{place}
\setkomavar{date}{\today}
%%% custom location/information area (to the right of the address field)
%%% You may design this area as you like, but it must not be wider than 75mm (according to DIN5008).
%%% (should not be used in combination with KOMA option 'fromalign=location...')
% \setkomavar{location}{\hfill\usekomavar{fromlogo}}
%%% reference information
%%% (filling any of these activates reference line)
\setkomavar{yourref}{your reference}
\setkomavar{yourmail}{mail}
\setkomavar{myref}{my reference}
\setkomavar{customer}{customer}
\setkomavar{invoice}{invoice}
%%% first page header and footer
%%% You may design these as you like.
%%% (if KOMA option 'fromalign' is 'left', 'center' or 'right', but you define the 'firsthead' variable, the default header is replaced by 'firsthead')
% \setkomavar{firsthead}{
% \centering
% first header
% }
\setkomavar{firstfoot}{
\centering
first footer
}
%%% headers and footers on subsequent pages
\pagestyle{headings}
%%% title and subject
% \setkomavar{title}{title} % rarely used
\setkomavar{subject}{subject}
%%% separators and description texts
%%% Modify separators and description texts if desired.
%%% (if KOMA option 'symbolicnames' is activated (e.g. 'true'), explicit separator definitions will override symbolic representations)
% \setkomavar{fromaddressseparator}{,~}
% \setkomavar{backaddressseparator}{,~}
% \setkomavar{zipcodeseparator}{\,--\,}
% \setkomavar{phoneseparator}[\phonename]{:~}
% \setkomavar{mobilephoneseparator}[\mobilephonename]{\usekomavar{phoneseparator}}
% \setkomavar{faxseparator}[\faxname]{:~}
% \setkomavar{emailseparator}[\emailname]{:~}
% \setkomavar{urlseparator}[\wwwname]{:~}
% \setkomavar{placeseparator}{,~}
% \setkomavar{ccseparator}[\ccname]{:~}
% \setkomavar{enclseparator}[\enclname]{:~}
% \setkomavar{subjectseparator}[\subjectname]{:~}
%%%%%%%%%%%%%%%%
% the document %
%%%%%%%%%%%%%%%%
\begin{document}
% you may add some settings here
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% plain English example letter %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% letter specific settings
\selectlanguage{english} % letter is written in English
\removereffields % deactivate reference line
%%% the letter
\begin{letter}{
%%% the KOMA variables 'toname' and 'toaddress' are derived from these lines
Addressee Name\\
addressee address line 1\\
addressee address line 2\\
addressee address line 3
}
%%% opening
\opening{salutation}
%%% body content
\Blindtext[7][1]
%%% closing
\closing{concluding text}
%%% postscript
\ps postscript text
%%% enclosures
\encl{enclosure 1\\enclosure 2}
%%% distribution list
\cc{distribution list}
\end{letter}
% you may add some settings here
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% customized German example letter %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% letter specific settings
\KOMAoptions{% modify some KOMA options
addrfield=PP, % add postage print impression
priority=a-priority, % make this letter an A priority
subject=titled, % prefix subject with a subject title
enlargefirstpage=true, % make the first page larger (less area for footer)
}
\selectlanguage{ngerman} % letter is written in German
\setkomavar{fromaddressseparator}{\\} % make sender address lines actual separate lines
\setkomavar{signature}{% signable/signed signature field
\rule{50mm}{0.4pt}\\
\hspace{1em}\usekomavar{fromname}\\
% \vspace{-4\baselineskip} % adjust depending on your signature image (see next line)
\hspace{10mm} % include signature image like '\includegraphics[width=30mm]{signature.png}' (preferably with transparent background)
}
\setkomavar{location}{% custom location/information area
\hfill%
\usekomafont{fromaddress}%
\begin{tabular}{cl}
\ifkomavarempty{fromname}{}{\faUser & \usekomavar{fromname}\\}
\ifkomavarempty{fromaddress}{}{\faHome & \makecell[l]{\usekomavar{fromaddress}}\\}
\ifkomavarempty{fromphone}{}{\faPhone & \usekomavar{fromphone}\\}
\ifkomavarempty{frommobilephone}{}{\faMobile & \usekomavar{frommobilephone}\\}
\ifkomavarempty{fromfax}{}{\faFax & \usekomavar{fromfax}\\}
\ifkomavarempty{fromemail}{}{\faEnvelopeO & \usekomavar{fromemail}\\}
\ifkomavarempty{fromurl}{}{\faGlobe & \usekomavar{fromurl}\\}
\ifkomavarempty{place}{}{\faMapMarker & \usekomavar{place}\\}
\end{tabular}
}
\defaultreffields % activate reference line
\setkomavar{firsthead}{% custom first header (deactivates default/generated header)
\centering
first header
}
\setkomavar{backaddressseparator}{\textperiodcentered} % separate back address entries by a centered dot
%%% the letter
\begin{letter}{
%%% the KOMA variables 'toname' and 'toaddress' are derived from these lines
Name Empfänger\\
Adresszeile 1\\
Adresszeile 2\\
Adresszeile 3
}
%%% opening
\opening{Anrede}
%%% body content
\Blindtext[6][1]
%%% closing
\closing{Grußformel}
%%% postscript
\ps Postskriptum
%%% enclosures
\encl{Anlage 1\\Anlage 2}
%%% distribution list
\cc{Verteilerliste}
\end{letter}
% you may add further letters here
\end{document}