| 1 |
% ====================================================================== |
| 2 |
% scraddr-en.tex |
| 3 |
% Copyright (c) Markus Kohm, 2001-2022 |
| 4 |
% |
| 5 |
% This file is part of the LaTeX2e KOMA-Script bundle. |
| 6 |
% |
| 7 |
% This work may be distributed and/or modified under the conditions of |
| 8 |
% the LaTeX Project Public License, version 1.3c of the license. |
| 9 |
% The latest version of this license is in |
| 10 |
% http://www.latex-project.org/lppl.txt |
| 11 |
% and version 1.3c or later is part of all distributions of LaTeX |
| 12 |
% version 2005/12/01 or later and of this work. |
| 13 |
% |
| 14 |
% This work has the LPPL maintenance status "author-maintained". |
| 15 |
% |
| 16 |
% The Current Maintainer and author of this work is Markus Kohm. |
| 17 |
% |
| 18 |
% This work consists of all files listed in MANIFEST.md. |
| 19 |
% ====================================================================== |
| 20 |
% |
| 21 |
% Chapter about scraddr of the KOMA-Script guide |
| 22 |
% Maintained by Jens-Uwe Morawski (with help from Markus Kohm) |
| 23 |
% |
| 24 |
% ====================================================================== |
| 25 |
|
| 26 |
\KOMAProvidesFile{scraddr-en.tex} |
| 27 |
[$Date: 2022-06-05 12:40:11 +0200 (So, 05. Jun 2022) $ |
| 28 |
KOMA-Script guide (chapter: scraddr)] |
| 29 |
\translator{Jens-Uwe Morawski\and Gernot Hassenpflug\and Markus Kohm\and Karl |
| 30 |
Hagen} |
| 31 |
|
| 32 |
\chapter{Accessing Address Files with \Package{scraddr}}% |
| 33 |
\labelbase{scraddr}% |
| 34 |
\BeginIndexGroup |
| 35 |
\BeginIndex{Package}{scraddr} |
| 36 |
|
| 37 |
The \Package{scraddr} package is a small extension to \KOMAScript{}'s letter |
| 38 |
class and letter package. Its goal is to make access to the data in address |
| 39 |
files easier and more flexible. |
| 40 |
|
| 41 |
\section{Overview}\seclabel{overview} |
| 42 |
Basically, the package provides a new loading mechanism for address files |
| 43 |
consisting of \DescRef{\LabelBase.cmd.adrentry} and the newer |
| 44 |
\DescRef{\LabelBase.cmd.addrentry} format entries, as described in |
| 45 |
\autoref{cha:scrlttr2} starting on \DescPageRef{scrlttr2.cmd.adrentry}. |
| 46 |
|
| 47 |
\begin{Declaration} |
| 48 |
\Macro{InputAddressFile}\Parameter{file name} |
| 49 |
\end{Declaration}% |
| 50 |
The \Macro{InputAddressFile} command is the main command of \Package{scraddr}. |
| 51 |
It reads the content of the address file\Index{address>file} given as its |
| 52 |
parameter. If the file is not found, an error message is issued. |
| 53 |
|
| 54 |
For each entry in this address file, the command generates a set of |
| 55 |
macros to access the data. For large address files, this will require |
| 56 |
a lot of \TeX{} memory. |
| 57 |
% |
| 58 |
\EndIndexGroup |
| 59 |
|
| 60 |
\begin{Declaration}% |
| 61 |
\Macro{adrentry}\Parameter{Lastname}\Parameter{Firstname}% |
| 62 |
\Parameter{Address}\Parameter{Phone}\Parameter{F1}\Parameter{F2}% |
| 63 |
\Parameter{Comment}\Parameter{Key}% |
| 64 |
% |
| 65 |
\Macro{addrentry}\Parameter{Lastname}\Parameter{Firstname}% |
| 66 |
\Parameter{Address}\Parameter{Phone}\Parameter{F1}\Parameter{F2}% |
| 67 |
\Parameter{F3}\Parameter{F4}\Parameter{Key}% |
| 68 |
% |
| 69 |
\Macro{adrchar}\Parameter{initial}% |
| 70 |
\Macro{addrchar}\Parameter{initial}% |
| 71 |
\end{Declaration}% |
| 72 |
The structure of the address entries in the address file was discussed in |
| 73 |
detail in \autoref{sec:scrlttr2.addressFile}, starting on |
| 74 |
\DescPageRef{scrlttr2.cmd.adrentry}. The subdivision of the address file with |
| 75 |
the help of \Macro{adrchar} or \Macro{addrchar}, also discussed there, has no |
| 76 |
meaning for \Package{scraddr} and is simply ignored by the package.% |
| 77 |
\EndIndexGroup |
| 78 |
|
| 79 |
\begin{Declaration} |
| 80 |
\Macro{Name}\Parameter{key}% |
| 81 |
\Macro{FirstName}\Parameter{key}% |
| 82 |
\Macro{LastName}\Parameter{key}% |
| 83 |
\Macro{Address}\Parameter{key}% |
| 84 |
\Macro{Telephone}\Parameter{key}% |
| 85 |
\Macro{FreeI}\Parameter{key}% |
| 86 |
\Macro{FreeII}\Parameter{key}% |
| 87 |
\Macro{Comment}\Parameter{key}% |
| 88 |
\Macro{FreeIII}\Parameter{key}% |
| 89 |
\Macro{FreeIV}\Parameter{key} |
| 90 |
\end{Declaration}% |
| 91 |
These commands give access to data of your address file. The last parameter, |
| 92 |
that is, parameter 8 for the \DescRef{\LabelBase.cmd.adrentry} entry and |
| 93 |
parameter 9 for the \DescRef{\LabelBase.cmd.addrentry} entry, is the |
| 94 |
identifier of an entry, thus the \PName{key} has to be unique and non-empty. |
| 95 |
To guarantee safe functioning, you should use only ASCII letters in the |
| 96 |
\PName{key}. |
| 97 |
|
| 98 |
Furthermore, if the file contains more than one entry with the same |
| 99 |
\PName{key} name, the last occurrence will be used.% |
| 100 |
% |
| 101 |
\EndIndexGroup |
| 102 |
|
| 103 |
|
| 104 |
\section{Usage}\seclabel{usage} |
| 105 |
\BeginIndexGroup |
| 106 |
\BeginIndex[indexother]{Cmd}{addrentry}% |
| 107 |
\BeginIndex[indexother]{Cmd}{adrentry}% |
| 108 |
To use the package, we need a valid address file. For example, the file |
| 109 |
\File{lotr.adr} contains the following entries: |
| 110 |
\begin{lstcode} |
| 111 |
\addrentry{Baggins}{Frodo}% |
| 112 |
{The Hill\\ Bag End/Hobbiton in the Shire}{}% |
| 113 |
{Bilbo Baggins}{pipe-weed}% |
| 114 |
{the Ring-bearer}{Bilbo's heir}{FRODO} |
| 115 |
\adrentry{Gamgee}{Samwise}% |
| 116 |
{3 Bagshot Row\\Hobbiton in the Shire}{}% |
| 117 |
{Rosie Cotton}{taters}% |
| 118 |
{the Ring-bearer's faithful servant}{SAM} |
| 119 |
\adrentry{Bombadil}{Tom}% |
| 120 |
{The Old Forest}{}% |
| 121 |
{Goldberry}{trill queer songs}% |
| 122 |
{The Master of Wood, Water and Hill}{TOM} |
| 123 |
\end{lstcode} |
| 124 |
|
| 125 |
The fourth parameter, the telephone number, has been left blank, since there |
| 126 |
are no phones in Middle Earth. And as you can see, blank fields are possible. |
| 127 |
On the other hand, you cannot simply omit an argument altogether. |
| 128 |
|
| 129 |
\BeginIndexGroup |
| 130 |
\BeginIndex[indexother]{Cmd}{InputAddressFile} |
| 131 |
With the \Macro{InputAddressFile} command described above, we read the address |
| 132 |
file into our letter document: |
| 133 |
\begin{lstcode} |
| 134 |
\InputAddressFile{lotr} |
| 135 |
\end{lstcode} |
| 136 |
\EndIndexGroup |
| 137 |
|
| 138 |
\BeginIndexGroup |
| 139 |
\BeginIndex[indexother]{Cmd}{Name}% |
| 140 |
\BeginIndex[indexother]{Cmd}{Address}% |
| 141 |
\BeginIndex[indexother]{Cmd}{FirstName}% |
| 142 |
\BeginIndex[indexother]{Cmd}{LastName}% |
| 143 |
\BeginIndex[indexother]{Cmd}{FreeI}% |
| 144 |
\BeginIndex[indexother]{Cmd}{FreeII}% |
| 145 |
\BeginIndex[indexother]{Cmd}{FreeIII}% |
| 146 |
\BeginIndex[indexother]{Cmd}{FreeIV}% |
| 147 |
\BeginIndex[indexother]{Cmd}{Comment}% |
| 148 |
With the help of the commands introduced in this chapter we can now write a |
| 149 |
letter to old \textsc{Tom Bombadil}, in which we ask him if he can remember |
| 150 |
two companions from olden times. |
| 151 |
\begin{lstcode} |
| 152 |
\begin{letter}{\Name{TOM}\\\Address{TOM}} |
| 153 |
\opening{Dear \FirstName{TOM} \LastName{TOM},} |
| 154 |
|
| 155 |
Or \FreeIII{TOM}, as your beloved \FreeI{TOM} calls you. Do |
| 156 |
you still remember Mr \LastName{FRODO}, or more precisely |
| 157 |
\Name{FRODO}, since there was also Mr \FreeI{FRODO}. He was |
| 158 |
\Comment{FRODO} in the Third Age and \FreeIV{FRODO}. \Name{SAM}, |
| 159 |
\Comment{SAM}, accompanied him. |
| 160 |
|
| 161 |
Their passions were very worldly. \FirstName{FRODO} enjoyed |
| 162 |
smoking \FreeII{FRODO}. His companion appreciated a good meal |
| 163 |
with \FreeII{SAM}. |
| 164 |
|
| 165 |
Do you remember? Certainly Mithrandir has told you much |
| 166 |
about their deeds and adventures. |
| 167 |
\closing{``O spring-time and summer-time |
| 168 |
and spring again after!\\ |
| 169 |
O wind on the waterfall, |
| 170 |
and the leaves' laughter!''} |
| 171 |
\end{letter} |
| 172 |
\end{lstcode} |
| 173 |
You can also produce the combination of \Macro{FirstName}\Parameter{key} and |
| 174 |
\Macro{LastName}\Parameter{key} used in the \DescRef{scrlttr2.cmd.opening} of |
| 175 |
this letter with \Macro{Name}\PParameter{key}. |
| 176 |
|
| 177 |
You can use the fifth and sixth parameters of the |
| 178 |
\DescRef{\LabelBase.cmd.adrentry} or \DescRef{\LabelBase.cmd.adrentry} for any |
| 179 |
purpose you wish. You can access them with the \Macro{FreeI} and |
| 180 |
\Macro{FreeII} commands. In this example, the fifth parameter contains the |
| 181 |
name of the most important person in the life of the person in the entry. The |
| 182 |
sixth contains the person's favourite thing. The seventh parameter is a |
| 183 |
comment or in general also a free parameter. You can access it with the |
| 184 |
\Macro{Comment} or \Macro{FreeIII} commands. \Macro{FreeIV} is only valid for |
| 185 |
\DescRef{\LabelBase.cmd.addrentry} entries. For |
| 186 |
\DescRef{\LabelBase.cmd.adrentry} entries, it results in an error. You can |
| 187 |
find more details in the next section. |
| 188 |
% |
| 189 |
\EndIndexGroup |
| 190 |
\EndIndexGroup |
| 191 |
|
| 192 |
|
| 193 |
\section{Package Warning Options} |
| 194 |
|
| 195 |
As mentioned above, you cannot use the \Macro{FreeIV} command with |
| 196 |
\DescRef{\LabelBase.cmd.adrentry} entries. However, you can configure how |
| 197 |
\Package{scraddr} reacts in such a situation by package options. |
| 198 |
Note\textnote{Attention!} that this package does not support the extended |
| 199 |
options interface with \DescRef{maincls.cmd.KOMAoptions} and |
| 200 |
\DescRef{maincls.cmd.KOMAoption}. You should therefore specify the options |
| 201 |
either as global options in \DescRef{maincls.cmd.documentclass} or as local |
| 202 |
options in \DescRef{maincls.cmd.usepackage} |
| 203 |
|
| 204 |
|
| 205 |
\begin{Declaration} |
| 206 |
\Option{adrFreeIVempty}% |
| 207 |
\Option{adrFreeIVshow}% |
| 208 |
\Option{adrFreeIVwarn}% |
| 209 |
\Option{adrFreeIVstop}% |
| 210 |
\end{Declaration}% |
| 211 |
These four options let you choose from four different reactions, ranging |
| 212 |
from \emph{ignore} to \emph{abort}, if \Macro{FreeIV} is used |
| 213 |
within an \DescRef{\LabelBase.cmd.adrentry} entry. |
| 214 |
|
| 215 |
\begin{labeling}[~--]{\Option{adrFreeIVempty}} |
| 216 |
\item[\Option{adrFreeIVempty}] |
| 217 |
the command \Macro{FreeIV} will be ignored |
| 218 |
\item[\Option{adrFreeIVshow}] |
| 219 |
the warning ``(entry FreeIV undefined at \PName{key})'' will be |
| 220 |
written in the text |
| 221 |
\item[\Option{adrFreeIVwarn}] |
| 222 |
a warning is written in the logfile |
| 223 |
\item[\Option{adrFreeIVstop}] |
| 224 |
the \LaTeX{} run will abort with an error message |
| 225 |
\end{labeling} |
| 226 |
The default setting is \Option{adrFreeIVshow}.% |
| 227 |
\EndIndexGroup |
| 228 |
% |
| 229 |
\EndIndexGroup |
| 230 |
|
| 231 |
\endinput |
| 232 |
|
| 233 |
%%% Local Variables: |
| 234 |
%%% mode: latex |
| 235 |
%%% TeX-master: "scrguide-en.tex" |
| 236 |
%%% coding: utf-8 |
| 237 |
%%% ispell-local-dictionary: "en_GB" |
| 238 |
%%% eval: (flyspell-mode 1) |
| 239 |
%%% End: |