| 1 |
% \iffalse^^A meta-comment |
| 2 |
% ====================================================================== |
| 3 |
% makelabels.dtx |
| 4 |
% Copyright (c) Markus Kohm, 2009-2021 |
| 5 |
% |
| 6 |
% This file is part of the LaTeX2e package `makelabels'. |
| 7 |
% |
| 8 |
% This work may be distributed and/or modified under the conditions of |
| 9 |
% the LaTeX Project Public License, version 1.3c of the license. |
| 10 |
% The latest version of this license is in |
| 11 |
% http://www.latex-project.org/lppl.txt |
| 12 |
% and version 1.3c or later is part of all distributions of LaTeX |
| 13 |
% version 2005/12/01 and of this work. |
| 14 |
% |
| 15 |
% This work has the LPPL maintenance status "author-maintained". |
| 16 |
% |
| 17 |
% The Current Maintainer and author of this work is Markus Kohm. |
| 18 |
% |
| 19 |
% This work consists of the files `makelabels.dtx' and `README.md'. |
| 20 |
% ====================================================================== |
| 21 |
% |
| 22 |
%<*dtx> |
| 23 |
\ifx\ProvidesFile\undefined\def\ProvidesFile#1[#2]{}\fi |
| 24 |
\ProvidesFile{makelabels.dtx} |
| 25 |
%</dtx> |
| 26 |
%<lco>\ProvidesFile{makelabels.lco} |
| 27 |
%<exmpl&simple>\ProvidesFile{makelabels-example.tex} |
| 28 |
%<exmpl&envlab>\ProvidesFile{makelabels-envlab-example.tex} |
| 29 |
[2021/08/14 v1.0 provide labels with scrlttr2 and scrletter] |
| 30 |
%<*dtx> |
| 31 |
\ifx\documentclass\undefined |
| 32 |
\input l3docstrip.tex |
| 33 |
\generate{% |
| 34 |
\usedir{tex/latex/makelabels} |
| 35 |
\file{makelabels.lco}{\from{makelabels.dtx}{lco}} |
| 36 |
\usedir{doc/latex/makelabels} |
| 37 |
\file{makelabels-example.tex}{\from{makelabels.dtx}{exmpl,simple}} |
| 38 |
\file{makelabels-envlab-example.tex}{\from{makelabels.dtx}{exmpl,envlab}} |
| 39 |
} |
| 40 |
\else |
| 41 |
\let\endbatchfile\relax |
| 42 |
\fi |
| 43 |
\endbatchfile |
| 44 |
\documentclass{l3doc} |
| 45 |
\usepackage{booktabs} |
| 46 |
\usepackage{scrlogo} |
| 47 |
\usepackage{graphicx} |
| 48 |
\GetFileInfo{makelabels.dtx} |
| 49 |
\begin{document} |
| 50 |
\title{Adding label functionality to |
| 51 |
\texorpdfstring{\file{scrlttr2}}{scrlttr2} and |
| 52 |
\texorpdfstring{\file{scrletter}}{scrletter} using |
| 53 |
\texorpdfstring{\file{makelabels.lco}}{makelabels.lco}} |
| 54 |
\date{\fileversion{} \filedate\footnote{For support and/or bug reports see |
| 55 |
\href{https://github.com/komascript/makelabels}{the project pages}.}} |
| 56 |
\author{Markus Kohm} |
| 57 |
\maketitle |
| 58 |
\begin{abstract} |
| 59 |
In opposite to the standard letter class, the \KOMAScript{} letter class |
| 60 |
\file{scrlttr2} and the \KOMAScript{} letter package \file{scrletter} do not |
| 61 |
provide generation of a label page using \cs[no-index]{makelabels}. But |
| 62 |
\KOMAScript{} provides the option to add new letter features using LCO |
| 63 |
files. \file{makelabels.lco} is such a LCO file. It provides |
| 64 |
\cs[no-index]{makelabels} similar to the standard letter class. The new |
| 65 |
\cs[no-index]{makelabels} has a yet very rudimentary configurability but |
| 66 |
much more than the standard letter class provides. However, it is also as |
| 67 |
much compatible as needed that packages like |
| 68 |
\href{https://www.ctan.org/pkg/enlab}{\file{envlab}} can be used. From |
| 69 |
version 1.0 \file{makelabels.lco} is implemented using |
| 70 |
\href{https://www.ctan.org/pkg/l3kernel}{\file{expl3}}. |
| 71 |
\end{abstract} |
| 72 |
\tableofcontents |
| 73 |
\DocInput{\filename} |
| 74 |
\end{document} |
| 75 |
%</dtx> |
| 76 |
% \fi^^A meta-comment |
| 77 |
% |
| 78 |
% \changes{v0.5}{2008/01/11}{First version released as \file{mlabel.lco} at |
| 79 |
% \url{https://komascript.de/mlabel.lco}} |
| 80 |
% \changes{v1.0}{2021/08/11}{Reimplementation using \file{expl3} syntax} |
| 81 |
% |
| 82 |
% \DoNotIndex{\@ifundefined,\@mainaux,\@onlypreamble,\@spaces,\@texttop} |
| 83 |
% \DoNotIndex{\activateareas,\AtEndLetter} |
| 84 |
% \DoNotIndex{\begin,\blindtext,\boxmaxdepth} |
| 85 |
% \DoNotIndex{\c_empty_tl,\c_max_dim,\c_one_int,\c_zero_dim} |
| 86 |
% \DoNotIndex{\clearpage,\closing,\columnsep} |
| 87 |
% \DoNotIndex{\cs:w,\cs_end:} |
| 88 |
% \DoNotIndex{\cs_if_exist:cTF,\cs_if_exist:NTF,\cs_new:Nn,\cs_new:Npn} |
| 89 |
% \DoNotIndex{\cs_new_nopar:Nn} |
| 90 |
% \DoNotIndex{\cs_set:Npn,\cs_set_eq:NN,\dim_new:N,\dim_set:Nn,\dim_set_eq:NN} |
| 91 |
% \DoNotIndex{\dim_sub:Nn,\documentclass} |
| 92 |
% \DoNotIndex{\else:,\end,\endinput,\evensidemargin} |
| 93 |
% \DoNotIndex{\exp_args:Nc,\ExplSyntaxOff,\ExplSyntaxOn} |
| 94 |
% \DoNotIndex{\fi,\fi:,\fontsize,\frame,\FromAddressLeftMargin} |
| 95 |
% \DoNotIndex{\FromAddressTopMargin} |
| 96 |
% \DoNotIndex{\GenericError,\group_begin:,\group_end:} |
| 97 |
% \DoNotIndex{\headheight,\headsep,\hook_gput_code:nnn} |
| 98 |
% \DoNotIndex{\if@atdocument,\if@filesw,\if@twocolumn} |
| 99 |
% \DoNotIndex{\if_cs_exist:N,\if_int_compare:w,\if_meaning:w} |
| 100 |
% \DoNotIndex{\IfBooleanTF,\IfFormatAtLeastTF,\IfValueTF,\ignorespaces} |
| 101 |
% \DoNotIndex{\int_incr:N,\int_new:N,\int_set:Nn,\int_set_eq:NN} |
| 102 |
% \DoNotIndex{\int_step_inline:nnn} |
| 103 |
% \DoNotIndex{\iow_char:N,\iow_now:Nn,\iow_now:Nx} |
| 104 |
% \DoNotIndex{\l_tmpa_tl,\lineskip,\LoadLetterOptions} |
| 105 |
% \DoNotIndex{\msg_error:nnn,\msg_fatal:nnn,\msg_new:nnn,\msg_warning:nnnn} |
| 106 |
% \DoNotIndex{\newcommand,\NewExpandableDocumentCommand} |
| 107 |
% \DoNotIndex{\oddsidemargin,\onecolumn,\opening} |
| 108 |
% \DoNotIndex{\pagestyle,\paperheight,\paperwidth,\par,\parbox} |
| 109 |
% \DoNotIndex{\prop_new:c,\prop_new:N,\prg_new_conditional:Nnn} |
| 110 |
% \DoNotIndex{\prg_return_false:,\prg_return_true:} |
| 111 |
% \DoNotIndex{\prop_get:cnNTF,\prop_get:NnNTF,\prop_new:N} |
| 112 |
% \DoNotIndex{\prop_set_from_keyval:cn,\prop_set_from_keyval:Nn} |
| 113 |
% \DoNotIndex{\providecommand} |
| 114 |
% \DoNotIndex{\raggedright,\relax,\selectfont,\setkomavar,\setlength} |
| 115 |
% \DoNotIndex{\skip_horizontal:N,\skip_vertical:N,\str_new:N,\str_set:Nn} |
| 116 |
% \DoNotIndex{\textheight,\textwidth,\token_to_str:N,\topmargin} |
| 117 |
% \DoNotIndex{\use:e,\use:n,\usepackage} |
| 118 |
% |
| 119 |
% \section{Installation} |
| 120 |
% |
| 121 |
% It is recommended to use the package installer of the \TeX{} |
| 122 |
% distribution. If you don't use a \TeX{} distribution with package installer, |
| 123 |
% that provides \file{makelabels.lco}, please see the advanced installation |
| 124 |
% information in the |
| 125 |
% \href{https://github.com/komascript/makelabels/blob/main/README.md}% |
| 126 |
% {\file{README.md}}. |
| 127 |
% |
| 128 |
% \section{Basic Usage} |
| 129 |
% |
| 130 |
% First of all please note, that \file{makelabels.lco} needs \LaTeX{} from |
| 131 |
% version 2020/10/01. It is recommended to use at least \LaTeX{} 2021/06/01, |
| 132 |
% because this is the \LaTeX{} version used for development of |
| 133 |
% \file{makelabels.lco}. Also \KOMAScript{} version 3.34 or newer is |
| 134 |
% recommended. If you would use an older \KOMAScript{} version you would do |
| 135 |
% this on your own risk. Please do not expect any support in this |
| 136 |
% case. |
| 137 |
% |
| 138 |
% To use the \file{makelabels.lco} you have to use either \KOMAScript{} |
| 139 |
% letter class \file{scrlttr2} or \file{scrletter} or the \KOMAScript{} |
| 140 |
% letter package \file{scrletter}. After loading the class resp. package you |
| 141 |
% have to load \file{makelabels.lco} using: |
| 142 |
% \begin{verbatim} |
| 143 |
% \LoadLetterOption{makelabels} |
| 144 |
% \end{verbatim} |
| 145 |
% in your document preamble. Note: This LCO cannot be loaded after |
| 146 |
% |\begin{document}|. |
| 147 |
% |
| 148 |
% Loading the LCO file already activates generation of label information |
| 149 |
% inside the \file{aux}-file of your document. Nothing else. |
| 150 |
% |
| 151 |
% \DescribeMacro\makelabels |
| 152 |
% To activate the label generation you have to add |
| 153 |
% \begin{verbatim} |
| 154 |
% \makelabels |
| 155 |
% \end{verbatim} |
| 156 |
% to your document preamble after loading \file{makelabels.lco} (see |
| 157 |
% above). Now at the end of the document, after printing all letters |
| 158 |
% \file{makelabels} generates one or more additional sheets with address |
| 159 |
% labels. The default label sheet is of type Avery~5162. This is a label sheet |
| 160 |
% with seven rows and two columns of labels. It is compatible with several |
| 161 |
% other Avery label types. |
| 162 |
% |
| 163 |
% \DescribeMacro\selectlabeltype |
| 164 |
% If you need more than one label per letter or another label type you can use: |
| 165 |
% \begin{syntax} |
| 166 |
% \cs{selectlabeltype}\oarg{integer}\marg{string} |
| 167 |
% \end{syntax} |
| 168 |
% This selects \meta{integer} labels of type \meta{string} for each following |
| 169 |
% letter (inclusive the current letter, if used between |\begin{letter}| and |
| 170 |
% |\end{letter}|. See \autoref{tab:labeltypes} for the allowed \meta{string} |
| 171 |
% arguments and the corresponding label types. |
| 172 |
% |
| 173 |
% \begin{table} |
| 174 |
% \begin{minipage}{\linewidth} |
| 175 |
% \centering |
| 176 |
% \begin{tabular}{llr} |
| 177 |
% \toprule |
| 178 |
% \textbf{\meta{string}} & \multicolumn2l{\textbf{Specification}} \\ |
| 179 |
% & Measure & {Value} \\ |
| 180 |
% \midrule |
| 181 |
% \texttt{avery\_5162}\footnote{\url{https://www.avery.com/products/labels/5162}} |
| 182 |
% & sheet height & 11\,in\\ |
| 183 |
% & sheet width & 8.5\,in\\ |
| 184 |
% & sheet top margin & 0.845\,in\\ |
| 185 |
% & sheet bottom margin & 0.845\,in\\ |
| 186 |
% & sheet left margin & 0.167\,in\\ |
| 187 |
% & sheet right margin & 0.167\,in\\ |
| 188 |
% & label height & 1.330\,in\\ |
| 189 |
% & label width & 4\,in\\ |
| 190 |
% & horizontal distance & 0.166\,in\\ |
| 191 |
% & vertical distance & 0\,pt\\ |
| 192 |
% & label left margin & 5\,pt\\ |
| 193 |
% & label right margin & 5\,pt\\ |
| 194 |
% & label top margin & 0\,pt\\ |
| 195 |
% & label bottom margin & 0\,pt\\ |
| 196 |
% & rows & 7\hphantom{\,pt}\\ |
| 197 |
% & columns & 2\hphantom{\,pt}\\ |
| 198 |
% \bottomrule |
| 199 |
% \end{tabular} |
| 200 |
% \caption{Known Label Types} |
| 201 |
% \label{tab:labeltypes} |
| 202 |
% \end{minipage} |
| 203 |
% \end{table} |
| 204 |
% |
| 205 |
% \section{Advanced Usage} |
| 206 |
% |
| 207 |
% \DescribeMacro\makelabels_add_label_type:nn |
| 208 |
% Advanced users can add their own label sheet definitions. But currently |
| 209 |
% there is only an \file{expl3} interface for this. If you do not know |
| 210 |
% \file{expl3}, please stop reading. There is no support for this feature, |
| 211 |
% currently. |
| 212 |
% \begin{syntax} |
| 213 |
% \cs{makelabels_add_label_type:nn} \meta{string} |
| 214 |
% \{ |
| 215 |
% sheet height = \meta{dim_1}, |
| 216 |
% sheet width = \meta{dim_2}, |
| 217 |
% sheet top margin = \meta{dim_3}, |
| 218 |
% sheet bottom margin = \meta{dim_4}, |
| 219 |
% sheet left margin = \meta{dim_5}, |
| 220 |
% sheet right margin = \meta{dim_6}, |
| 221 |
% vertical distance = \meta{dim_7}, |
| 222 |
% horizontal distance = \meta{dim_8}, |
| 223 |
% label height = \meta{dim_9}, |
| 224 |
% label width = \meta{dim_{10}}, |
| 225 |
% label top margin = \meta{dim_{11}}, |
| 226 |
% label bottom margin = \meta{dim_{12}}, |
| 227 |
% rows = \meta{int_{1}}, |
| 228 |
% columns = \meta{int_{2}} |
| 229 |
% \} |
| 230 |
% \end{syntax} |
| 231 |
% Currently all \meta{dim_x}, which are not specified, will be 0\,pt and all |
| 232 |
% \meta{int_x}, which are not specified, will be 1. |
| 233 |
% |
| 234 |
% The names of the properties should be self-explaining. If not, don't use it! |
| 235 |
% |
| 236 |
% Note: You can participate in the development of \file{makelabels.lco} by |
| 237 |
% posting and explaining your own label specifications. |
| 238 |
% |
| 239 |
% \section{Simple Example} |
| 240 |
% \label{sec:simpleexample} |
| 241 |
% |
| 242 |
% A very simple example for using \file{makelabels.lco} would be: |
| 243 |
% \iffalse^^A meta-comment |
| 244 |
%<*exmpl&simple> |
| 245 |
% \fi |
| 246 |
% \begin{macrocode} |
| 247 |
\documentclass[paper=letter]{scrletter} |
| 248 |
\LoadLetterOptions{UScommercial9,makelabels} |
| 249 |
\usepackage[english]{babel} |
| 250 |
\usepackage{blindtext} |
| 251 |
\setkomavar{fromname}{John Doe} |
| 252 |
\setkomavar{fromaddress}{1 Lambda Street\\Anyplace, NY 12345} |
| 253 |
\makelabels |
| 254 |
\begin{document} |
| 255 |
\begin{letter}{Jane Doe\\2 Alpha Street\\Otherplace, NY 12346} |
| 256 |
\opening{Dear Jane,} |
| 257 |
\blindtext |
| 258 |
\closing{With love} |
| 259 |
\end{letter} |
| 260 |
\end{document} |
| 261 |
% \end{macrocode} |
| 262 |
% \iffalse^^A meta-comment |
| 263 |
%</exmpl&simple> |
| 264 |
% \fi |
| 265 |
% It would produce the two pages shown in \autoref{fig:example}. |
| 266 |
% |
| 267 |
% \begin{figure} |
| 268 |
% \centering |
| 269 |
% \begin{tabular}{|l|l|} |
| 270 |
% \hline |
| 271 |
% \includegraphics[page=1,width=.45\linewidth]{makelabels-example.pdf} & |
| 272 |
% \includegraphics[page=2,width=.45\linewidth]{makelabels-example.pdf} \\ |
| 273 |
% \hline |
| 274 |
% \end{tabular} |
| 275 |
% \caption{The letter and the label sheet of the simple example of |
| 276 |
% \protect\autoref{sec:simpleexample}.} |
| 277 |
% \label{fig:example} |
| 278 |
% \end{figure} |
| 279 |
% |
| 280 |
% If you like, you could add an additional |
| 281 |
% \begin{verbatim} |
| 282 |
% \selectlabeltype[14]{avery_5162} |
| 283 |
% \end{verbatim} |
| 284 |
% after |\begin{document}|. In this case, you would get a whole sheet of 14 |
| 285 |
% labels (7 rows by 2 columns). |
| 286 |
% |
| 287 |
% \section{Example using additional label packages} |
| 288 |
% \label{sec:envlabexample} |
| 289 |
% As already mentioned in the abstract you can use \file{makelabels.lco} |
| 290 |
% together with package \href{https://ctan.org/pkg/envlab}{\file{envlab}}. In |
| 291 |
% this case, it is important to load \file{makelabels.lco} before package |
| 292 |
% \file{envlab}: |
| 293 |
% \iffalse^^A meta-comment |
| 294 |
%<*exmpl&envlab> |
| 295 |
% \fi |
| 296 |
% \begin{macrocode} |
| 297 |
\documentclass[paper=letter]{scrletter} |
| 298 |
\LoadLetterOptions{UScommercial9,makelabels} |
| 299 |
\usepackage[english]{babel} |
| 300 |
\usepackage{blindtext} |
| 301 |
\setkomavar{fromname}{John Doe} |
| 302 |
\setkomavar{fromaddress}{1 Lambda Street\\Anyplace, NY 12345} |
| 303 |
|
| 304 |
\usepackage[centerenvelopes,businessenvelope]{envlab} |
| 305 |
\setlength{\FromAddressTopMargin}{0.25in} |
| 306 |
\setlength{\FromAddressLeftMargin}{0.25in} |
| 307 |
\makelabels |
| 308 |
|
| 309 |
\begin{document} |
| 310 |
|
| 311 |
\begin{letter}{Jane Doe\\2 Alpha Street\\Otherplace, NY 12346} |
| 312 |
\opening{Dear Jane,} |
| 313 |
\blindtext |
| 314 |
\closing{With love} |
| 315 |
\end{letter} |
| 316 |
\end{document} |
| 317 |
% \end{macrocode} |
| 318 |
% \iffalse^^A meta-comment |
| 319 |
%</exmpl&envlab> |
| 320 |
% \fi |
| 321 |
% It would produce the two pages shown in \autoref{fig:envlabexample}. |
| 322 |
% |
| 323 |
% \begin{figure} |
| 324 |
% \centering |
| 325 |
% \begin{tabular}{|l|l|} |
| 326 |
% \hline |
| 327 |
% \includegraphics[page=1,width=.45\linewidth]{makelabels-envlab-example.pdf} & |
| 328 |
% \includegraphics[page=2,width=.45\linewidth]{makelabels-envlab-example.pdf} \\ |
| 329 |
% \hline |
| 330 |
% \end{tabular} |
| 331 |
% \caption{The letter and the envelope sheet of the \protect\file{envlab} |
| 332 |
% example of \protect\autoref{sec:envlabexample}.} |
| 333 |
% \label{fig:envlabexample} |
| 334 |
% \end{figure} |
| 335 |
% |
| 336 |
% Please note: package \file{envlab} redefines macro |\@toaddressfont|, which |
| 337 |
% is also an internal macro of \file{scrlttr2} or \file{scrletter}. The |
| 338 |
% \KOMAScript{} classes resp. the \KOMAScript{} package uses this to store the |
| 339 |
% font of the recipient's address. So loading \file{envlab} will change the |
| 340 |
% font of the recipient's address. To avoid this you could use additional |
| 341 |
% preamble code: |
| 342 |
% \begin{verbatim} |
| 343 |
% \makeatletter |
| 344 |
% \AtBeginDocument{% |
| 345 |
% \immediate\write\@auxout{% |
| 346 |
% \string\def\string\@toaddressfont{% |
| 347 |
% \expandafter\detokenize\expandafter{\@toaddressfont}}}% |
| 348 |
% \setkomafont{toaddress}{}% set the recepient's address font |
| 349 |
% } |
| 350 |
% \makeatother |
| 351 |
% \end{verbatim} |
| 352 |
% This delays the \file{envlab}'s redefinition of |\@toaddressfont| until the |
| 353 |
% \emph{labels} are generated. |
| 354 |
% |
| 355 |
% \StopEventually{\PrintChanges\PrintIndex} |
| 356 |
% |
| 357 |
% \section{Implementation} |
| 358 |
% |
| 359 |
% \begin{macrocode} |
| 360 |
%<*lco> |
| 361 |
%<@@=makelabels> |
| 362 |
% \end{macrocode} |
| 363 |
% |
| 364 |
% \subsection*{Load time actions} |
| 365 |
% |
| 366 |
% We need at least \LaTeX{} 2020/10/01. |
| 367 |
% \begin{macrocode} |
| 368 |
\newcommand*{\makelabels@fatal@format@error}{% |
| 369 |
\GenericError{(makelabels)\@spaces\@spaces\@spaces\@spaces}% |
| 370 |
{Fatal makelabels.lco error: LaTeX too old.}% |
| 371 |
{See the makelabels.lco documentation for explanation.}% |
| 372 |
{At least LaTeX 2020/10/01 is needed}% |
| 373 |
\endinput |
| 374 |
} |
| 375 |
\@ifundefined{IfFormatAtLeastTF}{% |
| 376 |
\makelabels@fatal@format@error |
| 377 |
}{% |
| 378 |
\IfFormatAtLeastTF{2020/10/01}{}{\makelabels@fatal@format@error}% |
| 379 |
} |
| 380 |
% \end{macrocode} |
| 381 |
% |
| 382 |
% With this version of \LaTeX{}, we do not need to load \file{expl3} |
| 383 |
% explicitly but can just switch to the syntax. |
| 384 |
% \begin{macrocode} |
| 385 |
\ExplSyntaxOn |
| 386 |
% \end{macrocode} |
| 387 |
% |
| 388 |
% This LCO file can be used in the document preamble only. If we are already |
| 389 |
% have begun the document, this would be fatal. |
| 390 |
% \begin{macrocode} |
| 391 |
\msg_new:nnn { makelabels } { onlypreamble } |
| 392 |
{ Sorry,~but~`makelabels.lco'~can~be~used~in~the~document~preamble~only. } |
| 393 |
\if@atdocument |
| 394 |
\msg_fatal:nnn { makelabels } { onlypreamble } |
| 395 |
\fi |
| 396 |
% \end{macrocode} |
| 397 |
% |
| 398 |
% \begin{macro}{\makelabels_add_label_type:nn} |
| 399 |
% Labels have only a width and height. They are placed in a number of rows and |
| 400 |
% columns at a label sheet. The sheet has also a width and height. There is a |
| 401 |
% margin left of the first label, above the first label, right of the first |
| 402 |
% label and below the last label. And there may be a horizontal and a vertical |
| 403 |
% distance between the labels. See the definition of Avery 5162 labels for |
| 404 |
% all properties. |
| 405 |
% |
| 406 |
% Note: currently all properties have to be setup correctly. |
| 407 |
% \begin{macrocode} |
| 408 |
\cs_new_nopar:Nn \makelabels_add_label_type:nn |
| 409 |
{ |
| 410 |
\prop_new:c { g_@@_label_type_#1_prop } |
| 411 |
\prop_set_from_keyval:cn { g_@@_label_type_#1_prop } { #2 } |
| 412 |
} |
| 413 |
% \end{macrocode} |
| 414 |
% \end{macro} |
| 415 |
% |
| 416 |
% The first label type we define is \texttt{avery_5162}: |
| 417 |
% \begin{macrocode} |
| 418 |
\makelabels_add_label_type:nn { avery_5162 } |
| 419 |
{ |
| 420 |
sheet height = 11 in, |
| 421 |
sheet width = 8.5 in, |
| 422 |
sheet top margin = 0.845 in, |
| 423 |
sheet bottom margin = 0.845 in, |
| 424 |
sheet left margin = 0.167 in, |
| 425 |
sheet right margin = 0.167 in, |
| 426 |
label height = 1.330 in, |
| 427 |
label width = 4 in, |
| 428 |
horizontal distance = 0.166 in, |
| 429 |
vertical distance = 0 pt, |
| 430 |
label left margin = 5 pt, |
| 431 |
label right margin = 5 pt, |
| 432 |
label top margin = 0 pt, |
| 433 |
label bottom margin = 0 pt, |
| 434 |
rows = 7, |
| 435 |
columns = 2, |
| 436 |
} |
| 437 |
% \end{macrocode} |
| 438 |
% |
| 439 |
% We also have to take care that at the end of each letter the label is written |
| 440 |
% to the \file{aux}-file. |
| 441 |
% \begin{function}[EXP]{\@@_Ifkomavarempty} |
| 442 |
% To be able to write to the \file{aux}-file, we need an expandable verion |
| 443 |
% of \KOMAScript's \cs{Ifkomavarempty}. To make simple wrapping possible, we |
| 444 |
% define it as an internal document command. |
| 445 |
% \begin{macrocode} |
| 446 |
\NewExpandableDocumentCommand \@@_Ifkomavarempty { s m m m } |
| 447 |
{ |
| 448 |
\IfBooleanTF { #1 } |
| 449 |
{ |
| 450 |
\exp_args:Nc \@@_if_empty_var_or_name:NTF{scr@#2@name}{#3}{#4} |
| 451 |
} |
| 452 |
{ |
| 453 |
\exp_args:Nc \@@_if_empty_var_or_name:NTF{scr@#2@var}{#3}{#4} |
| 454 |
} |
| 455 |
} |
| 456 |
% \end{macrocode} |
| 457 |
% \end{function} |
| 458 |
% \begin{function}[pTF]{\@@_if_empty_var_or_name:N} |
| 459 |
% This is the real internal command. Now, the first argument is not the |
| 460 |
% variable any longer, but the macro storing the variable or name. |
| 461 |
% \begin{macrocode} |
| 462 |
\prg_new_conditional:Nnn \@@_if_empty_var_or_name:N { p, T, F, TF } |
| 463 |
{ |
| 464 |
\if_cs_exist:N #1 |
| 465 |
\if_meaning:w #1 \c_empty_tl |
| 466 |
\prg_return_true: \else: \prg_return_false: \fi: |
| 467 |
\else: |
| 468 |
\prg_return_false: |
| 469 |
\fi: |
| 470 |
} |
| 471 |
% \end{macrocode} |
| 472 |
% \end{function} |
| 473 |
% |
| 474 |
% \begin{function}[EXP]{\@@_usekomavar} |
| 475 |
% To be able to write to the \file{aux}-file, we need an expandable version |
| 476 |
% of \KOMAScript's \cs{usekomavar}. To make simple wrapping possible, we |
| 477 |
% define it as an internal document command. |
| 478 |
% \begin{macrocode} |
| 479 |
\NewExpandableDocumentCommand \@@_usekomavar { s o m } |
| 480 |
{ |
| 481 |
\IfValueTF{#2}{#2}{\use:e}{\cs:w scr@#3@\IfBooleanTF{#1}{name}{var}\cs_end:} |
| 482 |
} |
| 483 |
% \end{macrocode} |
| 484 |
% \end{function} |
| 485 |
% |
| 486 |
% Now, after defining new, expandable versions of most of the usually needed |
| 487 |
% not expandable \KOMAScript{} user command, we can write to the |
| 488 |
% \file{aux}-file at the end of every letter. Note, we have to write |
| 489 |
% immediately (using \cs[no-index]{iow_now:Nx}), to use the current definition |
| 490 |
% of the commands redefined in the local group. |
| 491 |
% \begin{macrocode} |
| 492 |
\AtEndLetter |
| 493 |
{ |
| 494 |
\if@filesw |
| 495 |
\group_begin: |
| 496 |
\cs_set:Npn \Ifkomavarempty { \@@_Ifkomavarempty } |
| 497 |
\cs_set:Npn \usekomavar { \@@_usekomavar } |
| 498 |
\iow_now:Nx \@mainaux |
| 499 |
{ |
| 500 |
\token_to_str:N \@mlabel |
| 501 |
\iow_char:N \{ \usekomavar{backaddress} \iow_char:N \} |
| 502 |
\iow_char:N \{ \usekomavar{toname} \iow_char:N \\ \iow_char:N \\ |
| 503 |
\usekomavar{toaddress} \iow_char:N \} |
| 504 |
} |
| 505 |
\group_end: |
| 506 |
\fi |
| 507 |
} |
| 508 |
% \end{macrocode} |
| 509 |
% |
| 510 |
% \subsection*{The preamble commands} |
| 511 |
% |
| 512 |
% \begin{macro}{\makelabels} |
| 513 |
% Preamble only command to activate the label generation via the |
| 514 |
% \file{aux}-file. |
| 515 |
% \begin{macrocode} |
| 516 |
\cs_new:Npn \makelabels |
| 517 |
{ |
| 518 |
\hook_gput_code:nnn { begindocument } { makelabels.lco } |
| 519 |
{ |
| 520 |
\cs_set_eq:NN \@startlabels \startlabels |
| 521 |
\cs_set_eq:NN \@mlabel \mlabel |
| 522 |
\cs_set_eq:NN \@mlabeltype \mlabeltype |
| 523 |
\if@filesw |
| 524 |
\iow_now:Nn \@mainaux { \@startlabels }% |
| 525 |
\fi |
| 526 |
} |
| 527 |
\hook_gput_code:nnn { enddocument / afterlastpage } { makelabels.lco } |
| 528 |
{ |
| 529 |
\if@filesw |
| 530 |
\iow_now:Nn \@mainaux { \clearpage } % |
| 531 |
\fi |
| 532 |
} |
| 533 |
} |
| 534 |
\@onlypreamble \makelabels |
| 535 |
% \end{macrocode} |
| 536 |
% \end{macro} |
| 537 |
% |
| 538 |
% \begin{macro}{\selectlabeltype} |
| 539 |
% Used in the document preamble or inside the document to select another label |
| 540 |
% type. |
| 541 |
% \begin{macrocode} |
| 542 |
\newcommand*{\selectlabeltype}[2][1]{ |
| 543 |
\cs_if_exist:cTF { g_@@_label_type_#2_prop } |
| 544 |
{ |
| 545 |
\if@filesw |
| 546 |
\iow_now:Nn \@mainaux |
| 547 |
{ |
| 548 |
\@mlabeltype { #1 } { #2 } |
| 549 |
} |
| 550 |
\fi |
| 551 |
} |
| 552 |
{ |
| 553 |
\msg_error:nnn { makelabels } { unkown label type } { #1 } |
| 554 |
} |
| 555 |
} |
| 556 |
% \end{macrocode} |
| 557 |
% \end{macro} |
| 558 |
% |
| 559 |
% \subsection*{The \file{aux}-file commands} |
| 560 |
% |
| 561 |
% \begin{macro}{\@startlabels} |
| 562 |
% \begin{macro}{\@mlabel} |
| 563 |
% \begin{macro}{\@mlabeltype} |
| 564 |
% All these are dummies until \cs{makelabels} has been used. |
| 565 |
% \begin{macrocode} |
| 566 |
\hook_gput_code:nnn { begindocument } { makelabels.lco } |
| 567 |
{ |
| 568 |
\if@filesw |
| 569 |
\iow_now:Nn \@mainaux { \providecommand* { \@startlabels } { } } |
| 570 |
\iow_now:Nn \@mainaux { \providecommand* { \@mlabel }[2] { } } |
| 571 |
\iow_now:Nn \@mainaux { \providecommand* { \@mlabeltype } [ 2 ] { } } |
| 572 |
\fi |
| 573 |
} |
| 574 |
% \end{macrocode} |
| 575 |
% \end{macro} |
| 576 |
% \end{macro} |
| 577 |
% \end{macro} |
| 578 |
% |
| 579 |
% \begin{macro}{\mlabeltype} |
| 580 |
% Select generating \#1 labels of type \#2. |
| 581 |
% \begin{macrocode} |
| 582 |
\int_new:N \g_@@_label_repeat_int |
| 583 |
\int_set_eq:NN \g_@@_label_repeat_int \c_one_int |
| 584 |
\str_new:N \g_@@_label_type_str |
| 585 |
\str_set:Nn \g_@@_label_type_str { avery_5162 } |
| 586 |
\cs_new:Npn \mlabeltype #1#2 |
| 587 |
{ |
| 588 |
\int_set:Nn \g_@@_label_repeat_int { #1 } |
| 589 |
\str_set:Nn \g_@@_label_type_str { #2 } |
| 590 |
} |
| 591 |
% \end{macrocode} |
| 592 |
% \end{macro} |
| 593 |
% |
| 594 |
% \begin{macro}{\startlabels} |
| 595 |
% Start a new label page. We have to setup several page layout parameter |
| 596 |
% depending on the current label type \cs{g_@@_label_type_str}. |
| 597 |
% \begin{macrocode} |
| 598 |
\cs_new:Npn \startlabels |
| 599 |
{ |
| 600 |
\clearpage |
| 601 |
\if@twocolumn \onecolumn \fi |
| 602 |
\pagestyle{empty} |
| 603 |
\cs_set_eq:NN \@texttop \relax |
| 604 |
\dim_set_eq:NN \headheight \c_zero_dim |
| 605 |
\dim_set_eq:NN \headsep \c_zero_dim |
| 606 |
\dim_set_eq:NN \lineskip \c_zero_dim |
| 607 |
\@@_prop_get_dim:nN { sheet height } \paperheight |
| 608 |
\@@_prop_get_dim:nN { sheet top margin } \topmargin |
| 609 |
\dim_sub:Nn \topmargin { 1in } |
| 610 |
\@@_prop_get_dim:nN { sheet width } \paperwidth |
| 611 |
\@@_prop_get_dim:nN { sheet left margin } \oddsidemargin |
| 612 |
\dim_sub:Nn \oddsidemargin { 1in } |
| 613 |
\dim_set_eq:NN \evensidemargin \oddsidemargin |
| 614 |
\@@_prop_get_int:nN { rows } \g_@@_rows_int |
| 615 |
\@@_prop_get_int:nN { columns } \g_@@_columns_int |
| 616 |
\@@_prop_get_dim:nN { label height } \g_@@_label_height_dim |
| 617 |
\@@_prop_get_dim:nN { label width } \g_@@_label_width_dim |
| 618 |
\@@_prop_get_dim:nN { vertical distance } \g_@@_vertical_skip_dim |
| 619 |
\@@_prop_get_dim:nN { horizontal distance } \columnsep |
| 620 |
\dim_set:Nn \textheight |
| 621 |
{ |
| 622 |
( \g_@@_label_height_dim + \g_@@_vertical_skip_dim ) * \g_@@_rows_int |
| 623 |
- \g_@@_vertical_skip_dim |
| 624 |
} |
| 625 |
\dim_set:Nn \textwidth |
| 626 |
{ |
| 627 |
( \g_@@_label_width_dim + \columnsep ) * \g_@@_columns_int |
| 628 |
- \columnsep |
| 629 |
} |
| 630 |
\@@_prop_get_dim:nN { label top margin } \g_@@_label_top_margin_dim |
| 631 |
\@@_prop_get_dim:nN { label bottom margin } \g_@@_label_bottom_margin_dim |
| 632 |
\@@_prop_get_dim:nN { label left margin } \g_@@_label_left_margin_dim |
| 633 |
\@@_prop_get_dim:nN { label right margin } \g_@@_label_right_margin_dim |
| 634 |
\activateareas |
| 635 |
\fontsize{10pt}{12pt}\selectfont |
| 636 |
\dim_set_eq:NN \boxmaxdepth \c_max_dim |
| 637 |
\int_set_eq:NN \g_@@_row_int \c_one_int |
| 638 |
\int_set_eq:NN \g_@@_column_int \c_one_int |
| 639 |
\dim_set:Nn \g_@@_label_height_effective_dim |
| 640 |
{ |
| 641 |
\g_@@_label_height_dim |
| 642 |
- \g_@@_label_top_margin_dim |
| 643 |
- \g_@@_label_bottom_margin_dim |
| 644 |
} |
| 645 |
\dim_set:Nn \g_@@_label_width_effective_dim |
| 646 |
{ |
| 647 |
\g_@@_label_width_dim |
| 648 |
- \g_@@_label_left_margin_dim |
| 649 |
- \g_@@_label_right_margin_dim |
| 650 |
} |
| 651 |
\raggedright |
| 652 |
} |
| 653 |
|
| 654 |
\int_new:N \g_@@_rows_int |
| 655 |
\int_new:N \g_@@_columns_int |
| 656 |
\int_new:N \g_@@_row_int |
| 657 |
\int_new:N \g_@@_column_int |
| 658 |
\dim_new:N \g_@@_label_height_dim |
| 659 |
\dim_new:N \g_@@_label_width_dim |
| 660 |
\dim_new:N \g_@@_label_top_margin_dim |
| 661 |
\dim_new:N \g_@@_label_bottom_margin_dim |
| 662 |
\dim_new:N \g_@@_label_left_margin_dim |
| 663 |
\dim_new:N \g_@@_label_right_margin_dim |
| 664 |
\dim_new:N \g_@@_label_height_effective_dim |
| 665 |
\dim_new:N \g_@@_label_width_effective_dim |
| 666 |
\dim_new:N \g_@@_vertical_skip_dim |
| 667 |
% \end{macrocode} |
| 668 |
% \end{macro} |
| 669 |
% |
| 670 |
% \begin{function}{\@@_prop_get_dim:nN,\@@_prop_get_int:nN} |
| 671 |
% \begin{syntax} |
| 672 |
% \cs{@@_prop_get_dim:nN} \Arg{property string} \Arg{dimension variable} |
| 673 |
% \cs{@@_prop_get_int:nN} \Arg{property string} \Arg{integer variable} |
| 674 |
% \end{syntax} |
| 675 |
% Get a property from the property list of the current label type |
| 676 |
% \cs{g_@@_label_type_str} and store it as a dimension resp. integer. Unkown |
| 677 |
% properties result in a warning message. Unkown dimenionss are assumed to be |
| 678 |
% zero, unkown integers are assumed to be one. |
| 679 |
% \begin{macrocode} |
| 680 |
\msg_new:nnn { makelabels } { undefined property } |
| 681 |
{ Property~`#1'~undefined~for~label~type~`\g_@@_label_type_str'.~ |
| 682 |
Value~#2~assumed. } |
| 683 |
|
| 684 |
\cs_new:Nn \@@_prop_get_dim:nN |
| 685 |
{ |
| 686 |
\prop_get:cnNTF { g_@@_label_type_ \g_@@_label_type_str _prop } { #1 } \l_tmpa_tl |
| 687 |
{ \dim_set:Nn #2 \l_tmpa_tl } |
| 688 |
{ |
| 689 |
\msg_warning:nnnn { makelabels } { undefined property } { #1 } { zero } |
| 690 |
\dim_set_eq:NN #2 \c_zero_dim |
| 691 |
} |
| 692 |
} |
| 693 |
|
| 694 |
\cs_new:Nn \@@_prop_get_int:nN |
| 695 |
{ |
| 696 |
\prop_get:cnNTF { g_@@_label_type_ \g_@@_label_type_str _prop } { #1 } \l_tmpa_tl |
| 697 |
{ \int_set:Nn #2 \l_tmpa_tl } |
| 698 |
{ |
| 699 |
\msg_warning:nnnn { makelabels } { undefined property } { #1 } { one } |
| 700 |
\int_set_eq:NN #2 \c_one_int |
| 701 |
} |
| 702 |
} |
| 703 |
% \end{macrocode} |
| 704 |
% \end{function} |
| 705 |
% |
| 706 |
% \begin{macro}{\@@_print_one_label:} |
| 707 |
% Currently we do not support different output routines for different label |
| 708 |
% types. So this command is always the same. |
| 709 |
% \begin{macrocode} |
| 710 |
\cs_new:Nn \@@_print_one_label:nn |
| 711 |
{ |
| 712 |
% \frame{ |
| 713 |
\parbox[b][\g_@@_label_height_dim]{\g_@@_label_width_dim}{ |
| 714 |
\skip_vertical:N \g_@@_label_top_margin_dim |
| 715 |
\skip_horizontal:N \g_@@_label_left_margin_dim |
| 716 |
\parbox[c][\g_@@_label_height_effective_dim]{\g_@@_label_width_effective_dim}{ |
| 717 |
\ignorespaces #2 |
| 718 |
} |
| 719 |
\skip_vertical:N \g_@@_label_bottom_margin_dim |
| 720 |
} |
| 721 |
% } |
| 722 |
\int_incr:N \g_@@_column_int |
| 723 |
\if_int_compare:w \g_@@_column_int > \g_@@_columns_int |
| 724 |
\par |
| 725 |
\skip_vertical:N \g_@@_vertical_skip_dim |
| 726 |
\int_set_eq:NN \g_@@_column_int \c_one_int |
| 727 |
\int_incr:N \g_@@_row_int |
| 728 |
\if_int_compare:w \g_@@_row_int > \g_@@_rows_int |
| 729 |
\clearpage |
| 730 |
\int_set_eq:NN \g_@@_row_int \c_one_int |
| 731 |
\fi: |
| 732 |
\else: |
| 733 |
\skip_horizontal:N \columnsep |
| 734 |
\fi: |
| 735 |
} |
| 736 |
% \end{macrocode} |
| 737 |
% \end{macro} |
| 738 |
% |
| 739 |
% \begin{macro}{\mlabel} |
| 740 |
% Output the configurated number of labels. |
| 741 |
% \begin{macrocode} |
| 742 |
\cs_new:Npn \mlabel #1#2 |
| 743 |
{ |
| 744 |
\int_step_inline:nnn { 1 } { \g_@@_label_repeat_int } |
| 745 |
{ |
| 746 |
\@@_print_one_label:nn { #1 } { #2 } |
| 747 |
} |
| 748 |
} |
| 749 |
% \end{macrocode} |
| 750 |
% \end{macro} |
| 751 |
% |
| 752 |
% We need to not forget to switch of \file{expl3} syntax, because this is not |
| 753 |
% a package but a LCO. |
| 754 |
% \begin{macrocode} |
| 755 |
\ExplSyntaxOff |
| 756 |
%</lco> |
| 757 |
% \end{macrocode} |
| 758 |
% \Finale |
| 759 |
% |
| 760 |
\endinput |
| 761 |
% |
| 762 |
% Local Variables: |
| 763 |
% mode: doctex |
| 764 |
% TeX-master: t |
| 765 |
% End: |