Da ich immer wieder gefragt werde, wie man KOMA-Script materiell unterstützen oder man mir eine Freude machen kann, habe ich dazu eine Erklärung verfasst. Darin geht es um Hardware, Geld, Windows-Lizenzen und den Eintrag in die Sponsorenliste.
Wurde es möglich, die Pakete envlab mit KOMA-script befürworten,
die hat das Makro \mlabel{} nötig. Wenn ja, wäre es besser seien, einen envlab.lco machen, zum Beispiel wie labelbasic.lco und settleford600label.lco?
Would it be possible for KOMA-Script scrlttr2 to support the latex package envlab (envelopes + labels) which needs the macro \mlabel{}{} defined? If so, which would be the better solution, adding the envlab instructions to KOMA-Script, or adding an lco file (like labelbasic.lco and settleford600label.lco)? Currently envlab only works with the latex letter class:
(/usr/local/share/texmf/tex/latex/koma-script/DIN.lco)
(/usr/share/texmf/tex/latex/envlab.sty
! Package envlab Error: Envlab is used outside of
(envlab) a letter-compatible documentclass.
? h
You are trying to use Envelopes & Labels
package, but your documentclass does not
understand address formatting commands.
Try standard document class letter
I don't know how difficult it would be to add such support, or the best approach. The basic letter class leaves much to be desired, particularly its handling of margins, headers and footers. The only way I can properly position a company letterhead is to use either the textblock or picture environments to position the letterhead. By contrast the scrlttr2 class handles headers and footers properly. I have a form letter which uses the letter class and the textmerg package to pull in fields from a database (name, address, account balances, etc) and outputs a multipage pdf containing all the form letters (one for each record) followed by envelopes for each letter. I realize the scrlttr2 class can produce a backaddress that appears in an envelope window, but in my case I already have pre-printed #10 business envelopes with no window.
Maybe only an individual parameter set for the labels you are using or for the envelops is needed in addition to labelbasic.lco. If the usage of envlab is a "must be", it may be possible to add \mlabel definition and usage by a lco (see examples like sections.lco or PP.lco how to add new functionality to scrlttr2 using lco). Maybe something like (example is not tested!)
\ProvidesFile{mlabel.lco}[2009/07/09 v0.1-prealpha unsupported lco maybe full of errors and mistakes but without any sense]\AtEndLetter{\if@filesw
\begingroup\let\\=\relax\let\protect\@unexpandable@protect
\usekomavar[\edef\toname]{toname}%\usekomavar[\edef\toaddress]{toaddress}%\usekomavar[\edef\returnaddress]{backaddress}%\immediate\write\@auxout{%\string\@mlabel{\returnaddress}{\toname\\\toaddress}%}%\endgroup\fi}\let\@mlabel\@gobbletwo
Disclaimer: I do not know envlab and have no full but minimal example in how to use it and how usage with scrlttr2 should work. So I do not know, if the lco example above may be a solution or part of a solution or would be nonsense!
BTW: There are two new lcos for US letters at the brand new KOMA-Script release 3.04. It would be nice to get some feedback about them, so they may become stable versions (currently they are only betas).
I looked over the envlab package and it needs \makelabels and \mlabel to already be defined. The envlab package then defines sizes for standard envelopes and letters. It also defines new commands to define your own envelope and label sizes, or modify the size and placement of the boxes containing the addresses. And it also has some options to alter formatting of envelopes/labels, e.g. print barcodes and choose machine-readable font for addressee.
I tried copying the \makelabel code from the letter class:
\ProvidesFile{mlabel.lco}% [2009/07/09 unsupported LCO-file]\newcommand*{\makelabels}{\AtBeginDocument{% \let\@startlabels\startlabels\let\@mlabel\mlabel\if@filesw
\immediate\write\@mainaux{\string\@startlabels}\fi}% At the end of the document we need to write \clearpage to the .aux file.\AtEndDocument{% \if@filesw\immediate\write\@mainaux{\string\clearpage}\fi}
}% \makelabels is allowed only before the \begin{document} command.\@onlypreamble\makelabels% Use \AtEndLetter hook from scrlttr2 instead of \stopletter ?\AtEndLetter{%{\stopletter\@@par\pagebreak\@@par
\if@filesw
\begingroup\let\\=\relax\let\protect\@unexpandable@protect
%\usekomavar[\edef\toname]{toname}%%\usekomavar[\edef\toaddress]{toaddress}%%\usekomavar[\edef\returnaddress]{backaddress}%\immediate\write\@auxout{\string\@mlabel{}{\toname\\\toaddress}}\endgroup\fi%} }\long\def\@processto#1{%\@xproc #1\\@@@% \ifx\toaddress\@empty\else\@yproc #1@@@% \fi}\long\def\@xproc #1\\#2@@@{\def\toname{#1}\def\toaddress{#2}}\long\def\@yproc #1\\#2@@@{\def\toaddress{#2}}% apparently \stopletter is already defined by scrlttr2% \newcommand*{\stopletter}{}\newcommand*{\returnaddress}{}\newcommand*{\address}[1]{\def\fromaddress{#1}}\newcount\labelcount\newcommand*{\startlabels}{\labelcount\z@
\pagestyle{empty}% \let\@texttop\relax\topmargin -50\p@
\headsep\z@
ddsidemargin -35\p@
\evensidemargin -35\p@
\textheight 10in
\@colht\textheight\@colroom\textheight\vsize\textheight\textwidth 550\p@
\columnsep 26\p@
\ifcase\@ptsize\relax\normalsize\or\small\or\footnotesize\fi\baselineskip\z@
\lineskip\z@
\boxmaxdepth\z@
\parindent\z@
\twocolumn\relax}\let\@startlabels=\relax\newcommand*{\mlabel}[2]{%\parbox[b][2in][c]{262\p@}{\strut\ignorespaces #2}%}\let\@mlabel=\@gobbletwo\endinput
but scrlttr2 complained:
! Package scrlfile Error: \newpage at \BeforeClosingMainAux.
See the scrlfile package documentation for explanation.
Type H <return> for immediate help.
...
l.14 \@startlabels
? h
You should never use \newpage or \clear(double)page or other output material at
the
argument of \BeforeClosingMainAux!
If you'll continue, the \newpage will be ignored to avoid corruption of
every prior use of \BeforeClosingMainAux.
Apparently, scrlttr2 writes to the aux file:
\relax\ifx\hyper@anchor\@undefined\global\let\oldcontentsline\contentsline\gdef\contentsline#1#2#3#4{\oldcontentsline{#1}{#2}{#3}}\global\let\oldnewlabel\newlabel\gdef\newlabel#1#2{\newlabelxx{#1}#2}\gdef\newlabelxx#1#2#3#4#5#6{\oldnewlabel{#1}{{#2}{#3}}}\AtEndDocument{\let\contentsline\oldcontentsline\let\newlabel\oldnewlabel}\else\global\let\hyper@last\relax\fi\@startlabels\@mlabel{}{Thomas Jefferson\\{Monticello, 931 Thomas Jefferson Pkwy}\\{Charlottesville, VA 22902-7148}}\@mlabel{}{Ben Franklin\\{Franklin Court}\\{Philadelphia, PA 19103}}\@mlabel{}{Abraham Lincoln\\ {Knob Creek Farm}\\ {Hodgenville, KY 42748} }\clearpage
BTW, here is a minimul, full working example of using envlab with letter class:
\documentclass[12pt]{letter}\usepackage[centerenvelopes,businessenvelope]{envlab}% OPTIONS: % businessenvelope, executiveenvelope, bookletenvelope, personalenvelope,% c6envelope, c65envelope, c5envelope, dlenvelope % noprintbarcodes nocapaddress noprintreturnaddress % % LENGTHS: % \EnvelopeWidth ~Height ~TopMargin ~LeftMargin % \FromAddress ~TopMargin ~LeftMargin ~Height ~Width % \ToAddress ~TopMargin ~LeftMargin ~Height ~Width \setlength{\FromAddressTopMargin}{0.25in}\setlength{\FromAddressLeftMargin}{0.25in}\makelabels% make labels/envelopes \address{Joe Casanova\\1 Lambda Street\\Anyplace, NY 12345}\signature{Joe}\begin{document}\begin{letter}{%
Mary McKeen\\2 Alpha Street\\Otherplace, NY 12346}\opening{Dear Mary:}
I love only you
\closing{With love,}\end{letter}\begin{letter}{%
Lisa O'Hara\\2 Beta Street\\Anotherplace, NY 12347}\opening{Dear Lisa:}
I love only you
\closing{With love,}\end{letter}\end{document}
P.S.
I will try out the US letter lcos,
UScommercial9DW.lco and UScommercial9.lco,
and give my feedback.
But I haven't yet figured out how to put the return address in
\mlabel{FROM}{TO}:
\ProvidesFile{mlabel.lco}% [2009/07/09 unsupported LCO-file]\newcommand*{\makelabels}{\AtBeginDocument{% \let\@startlabels\startlabels\let\@mlabel\mlabel\if@filesw
\immediate\write\@mainaux{\string\@startlabels}\fi}% At the end of the document we need to write \clearpage to the .aux file.\AtEndDocument{% \if@filesw\immediate\write\@mainaux{\string\clearpage}\fi}
}% \makelabels is allowed only before the \begin{document} command.\@onlypreamble\makelabels\AtEndLetter{%{\stopletter%\@@par\pagebreak\@@par\if@filesw
\begingroup\let\\=\relax\let\protect\@unexpandable@protect
%\usekomavar[\edef\toname]{toname}%%\usekomavar[\edef\toaddress]{toaddress}%%\usekomavar[\edef\returnaddress]{backaddress}%\usekomavar[\edef\FromName]{fromname}% \usekomavar[\edef\FromAddress]{fromaddress}% \immediate\write\@auxout{\string\@mlabel{\FromName\\\FromAddress}{\toname\\\toaddress}}\endgroup\fi%} }\long\def\@processto#1{%\@xproc #1\\@@@% \ifx\toaddress\@empty\else\@yproc #1@@@% \fi}\long\def\@xproc #1\\#2@@@{\def\toname{#1}\def\toaddress{#2}}\long\def\@yproc #1\\#2@@@{\def\toaddress{#2}}%\newcommand*{\stopletter}{}\newcommand*{\returnaddress}{}%\newcommand*{\address}[1]{\def\fromaddress{#1}}\newcount\labelcount\newcommand*{\startlabels}{\labelcount\z@
\pagestyle{empty}% \let\@texttop\relax\topmargin -50\p@
\headsep\z@
ddsidemargin -35\p@
\evensidemargin -35\p@
\textheight 10in
\@colht\textheight\@colroom\textheight\vsize\textheight\textwidth 550\p@
\columnsep 26\p@
\ifcase\@ptsize\relax\normalsize\or\small\or\footnotesize\fi\baselineskip\z@
\lineskip\z@
\boxmaxdepth\z@
\parindent\z@
\twocolumn\relax}\let\@startlabels=\relax\newcommand*{\mlabel}[2]{%\parbox[b][2in][c]{262\p@}{\strut\ignorespaces #2}%}\let\@mlabel=\@gobbletwo\endinput
The above mlabel.lco yields following errors:
! LaTeX Error: Missing \begin{document}.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.16 \@mlabel{{B
en Franklin\\{Franklin Court}\\{Philadelphia, PA 19103}}}
? h
You're in trouble here. Try typing <return> to proceed.
If that doesn't work, type X <return> to quit.
! Use of \FromName doesn't match its definition.
<write> \string\@mlabel{\FromName\\\FromAddress}{\toname\\\toaddress}
Runaway text?
\@mlabel{ {Thomas Jefferson\\ {Monticello, 931 Thomas Jefferson Pkwy}\ETC.
! Forbidden control sequence found while scanning text of \write.
The command \@processto which I pulled from the letter class,
extracts \toname and \toaddress from \begin{letter}{to\\str\\address}
correctly so that the envelopes get printed with the correct address information. Unfortunately, I just realized that the addressee information on the letter is now gone. I also just now noticed that the barcodes are missing on the envelopes. I'm not sure what I need to change to the \@processto macro to get it to work correctly with scrlttr2:
Thanks for all the information. I need some time for reading, testing etc. now.
Only one thing: Changing \@processto in such a way will damage scrlttr2, because scrlttr2 uses its own \@processto to set up variables toname and toaddress.
If there's a namespace conflict between the letter and scrlttr2 classes, maybe I can just append the entire envlab.sty to my envlab.lco, and change the names of the variables therein, (\toname, \toaddress, \fromname, \fromaddress), to eliminate the conflict?
The envlab.sty looks fairly simple, just defining standard ISO paper sizes and defining some functions to print parbox'es with sender and adressee info.
Thanks very, very much. Works perfectly!
It also works perfectly with the textmerg package.
One last question though:
If I change the color of my letterhead to e.g. MyBlue, then my envelopes get printed in the same color MyBlue.
It's no big deal, but is it possible to reset the color?
I'm somewhat confused on how \addtokomafont{komavar} and \setkomafont{komavar} work. Changing the color of elements in the letterhead also changes the color of the body of the letter. So I put in my body code to change color back to black:
% setup elements of standard letterhead\setkomavar{fromname}{\COMPANY}\setkomavar{fromaddress}{Main Street\\Anytown, USState zipcode}\setkomavar{fromphone}{123-456-7890}\setkomavar{fromfax}{012-345-6789}\setkomavar{fromurl}{www.somecompany.com}\setkomavar{signature}{}\setkomavar{title}{Notice}\definecolor{MyBlue}{rgb}{0.16470589 0.05882353 0.60784316}\color{MyBlue}\addtokomafont{fromname}{\Large\sc\color{MyBlue}}\setkomafont{fromaddress}{\normalsize\sc\color{MyBlue}}\addtokomafont{title}{\color{black}}\Fields{\FULL\STREET\CSZ\SEC\LOT\TAXMAP}\Merge{fields.data}{\begin{letter}{%\\{\FULL}\\{\STREET}\\{\CSZ}}\newcommand{\RE}{{\normalfont\bfseries\color{black} Section {\SEC}, Lot {\LOT}\\ Tax Map No.\{\TAXMAP}}}\setkomavar{subject}{}\color{black}\opening{\RE}
BODY
\closing{\Signature}\end{letter}
}%end merge
If you are using non robust macros at moving arguments, you should protect them from breaking. So you may try \protect\textsuperscript instead of \textsuperscript. See also usage of non robust macros in the argument of, e.g., \section, \footnote, \caption etc.
I hate to bother you again, but I was wondering if it is possible to change the papersize of the envelopes.
The current way sets the pagesize to, e.g. letter, for both the letters and the envelopes. This worked perfectly fine with my old printer, since in order to print an envelope, one only needs to know how far from the top of the page and how far from the {left, middle, right} of the page to print the parbox. The actual width and height of the paper media is irrelevant.
However, my new Xerox Phaser 8860 has sensors in the multipaper tray, which detect the size of the actual media, and it refuses to print unless the size of the pdf matches the size of the media. With Acroread9, I can print my (8.5x11-in letters+envelopes) pdf on #10 envelopes (4.125x9.5-in) only if I select "Autocenter" which then centers a virtual #10 envelope on real 8.5x11in paper, and changes the positioning of the labels. With okular, it is impossible to print a letter-size envelope on #10 media. (I've tried all permutations of "PageSize", "MediaSize" and "PageRegion" and only succeed in scaling 8.5x11 down to 4.125x9.5 with itsy-bitsy print)
The only way I can print an envelope with the Phaser is to set the size of the pdf to the size of the envelope:
Since KOMA-Script 3.00 you may change paper size in the document using typearea functionality. I've done so at mlabel.lco's \startlabels (remark: envlab.sty overwrites this definition!):
\paperwidth 8.5in % change the witdh of the paper\paperheight 11in % change the height of the paper\activateareas% activate all changes and take care of option pagesize
If you're using option pagesize (or pagesize=auto or pagesize=automedia) the new page size will also be written to the PDF by \activateareas. I've shown this at mlabeltest.(tex|pdf). Against specification of UScommercial9, I've used default paper size A4, so mlabel.lco changes the paper size for the label page (= second page at the pdf).
See options paper and DIV and commands \recalctypearea and \activateareas at the manual of the current KOMA-Script release, at least version 3.03a. Chapter 2 of the english guide should already be the same like the german one, but \activateareas may only be found at the expert part of the german manual, scrguide, section 13.1. Sorry, but there's currently only one translator and doing all the changes for the current manual is a lot of work.
Since envlab is an old package, that was not changed for 12 years, it does not know such pdfTeX features (like changing \pdfpagewidth and \pdfpageheight at runtime). Maybe you should write a feature request to the package maintainer. Even geometry does not support this, but you may try changing it by typearea like I've done at mlabel.lco.
Reading through the documentation for envlab, I found the hook \AtBeginLabelPage. So I used this hook together with your papersize commands (\paperwidth, \paperheight, \activateareas) to set both the pdf papersize and the envlab papersize to #10 envelope. And it finally works!
%% redwood-mlabeltestx.tex% Copyright (c) redwood, 2009%% This is a modified version of: % mlabeltestx.tex % Copyright (c) Markus Kohm, 2009 % % This file may be and/or modified under the % conditions of the LaTeX Project Public License, either version 1.3c % of this license or (at your option) any later version. % The latest version of this license is in % http://www.latex-project.org/lppl.txt % and version 1.3c or later is part of all distributions of LaTeX % version 2005/12/01 or later. %% NOTE: While this file is `Derived Work' of mlabeltestx.tex % distribution is only allowed together with a unmodified copy% of mlabeltestx.tex. See <http://www.komascript.de/mlabel.lco>% for more information about mlabeltestx.tex.%\documentclass[UScommercial9,pagesize,mlabel]{scrlttr2}[2009/07/07]\usepackage[english]{babel}\usepackage{blindtext}\setkomavar{fromname}{John Doe}\setkomavar{fromaddress}{1 Lambda Street\\Anyplace, NY 12345}\usepackage[dvipsnames,svgnames,x11names]{xcolor}\usepackage[centerenvelopes,businessenvelope]{envlab}\AtBeginLabelPage{%\color{Blue} % Switch pdf papersize to #10 envelope\paperwidth 4.125in
\paperheight 9.5in
\activateareas% Defaults Envelope Sizes & Offsets from paper edges\setlength{\EnvelopeWidth}{9.5in}\setlength{\EnvelopeHeight}{4.125in}\setlength{\EnvelopeTopMargin}{0in}% Distance between leading edge of paper and envelope\setlength{\EnvelopeLeftMargin}{0in}% Distance between left edge of paper and envelope % envlab lengths\setlength{\FromAddressTopMargin}{0.25in}% Default .5in\setlength{\FromAddressLeftMargin}{0.25in}% Default .5in\setlength{\FromAddressHeight}{.33\EnvelopeHeight}\setlength{\FromAddressWidth}{.5\EnvelopeWidth}\setlength{\ToAddressTopMargin}{.5in}\setlength{\ToAddressLeftMargin}{.5in}\setlength{\ToAddressWidth}{3.5in}%Default 3in%\SetEnvelope{topmargin}{width}{height}%\SetEnvelope{.5in}{4.125in}{9.5in} }\makelabels%\paperwidth 8.5in \paperheight 11in \activateareas\begin{document}\begin{letter}{Jane Doe\\2 Alpha Street\\Otherplace, NY 12346}\opening{Dear Jane,}\blindtext\blindtext\closing{With love}\end{letter}\end{document}
BTW, scrlttr2 + envlab + mlabel.lco works with lyx,
Lyx-1.5.7 is very fussy about the formatting of its preamble. The "Document->LaTeXPreamble" editor hangs when parsing the preamble if lines in the preamble begin with % or space. The workaround is to \input the preamble as straight latex code.
# cat preamble.tex
%% preamble.tex% Copyright (c) redwood% % This file was derived from of: % mlabeltestx.tex % Copyright (c) Markus Kohm, 2009 % % This file may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.3c % of this license or (at your option) any later version. % The latest version of this license is in % http://www.latex-project.org/lppl.txt % and version 1.3c or later is part of all distributions of LaTeX % version 2005/12/01 or later. % % NOTE: While this file is `Derived Work' of mlabeltestx.tex % distribution is only allowed together with a unmodified copy% of mlabeltestx.tex. See <http://www.komascript.de/mlabel.lco>% for more information about mlabeltestx.tex.%%\documentclass[UScommercial9,pagesize,mlabel]{scrlttr2}[2009/07/07] %\usepackage[english]{babel} \LoadLetterOption{./mlabel}\usepackage{blindtext}\usepackage[dvipsnames,svgnames,x11names]{xcolor}\usepackage[centerenvelopes,businessenvelope]{envlab}\AtBeginLabelPage{%\geometry{papersize={4.125in,9.5in}, total={4.125in,9.5in}}%\color{Blue} % Swith pdf papersize to #10 envelope\paperwidth 4.125in
\paperheight 9.5in
\activateareas% Defaults\setlength{\EnvelopeWidth}{9.5in}\setlength{\EnvelopeHeight}{4.125in}\setlength{\EnvelopeTopMargin}{0in}% Distance between leading edge of paper and envelope\setlength{\EnvelopeLeftMargin}{0in}% Distance between left edge of paper and envelope %\setlength{\FromAddressTopMargin}{0.25in}% Default .5in\setlength{\FromAddressLeftMargin}{0.25in}% Default .5in\setlength{\FromAddressHeight}{.33\EnvelopeHeight}\setlength{\FromAddressWidth}{.5\EnvelopeWidth}\setlength{\ToAddressTopMargin}{.5in}\setlength{\ToAddressLeftMargin}{.5in}\setlength{\ToAddressWidth}{3.5in}%Default 3in%\SetEnvelope{topmargin}{width}{height}%\SetEnvelope{.5in}{4.125in}{9.5in}}\makelabels%\paperwidth 8.5in \paperheight 11in \activateareas
# cat minimal.lyx
#LyX 1.5.7 created this file. For more info see http://www.lyx.org/
\lyxformat 276
\begin_document
\begin_header
\textclass scrlttr2
\begin_preamble
\input{preamble.tex}\setkomavar{fromname}{John Doe}\setkomavar{fromaddress}{1 Lambda Street\\Anyplace, NY 12345}\end_preamble
\options dvipsnames, svgnames, x11names, USCommercial9, pagesize
\language english
\inputencoding auto
\font_roman default
\font_sans default
\font_typewriter default
\font_default_family default
\font_sc false
\font_osf false
\font_sf_scale 100
\font_tt_scale 100
\graphics default
\paperfontsize default
\spacing single
\papersize default
\use_geometry false
\use_amsmath 1
\use_esint 1
\cite_engine basic
\use_bibtopic false
\paperorientation portrait
\secnumdepth 3
\tocdepth 3
\paragraph_separation indent
\defskip medskip
\quotes_language english
\papercolumns 1
\papersides 1
\paperpagestyle default
\tracking_changes false
\output_changes false
\author ""
\author ""
\end_header
\begin_body
\begin_layout Standard
\begin_inset ERT
status collapsed
\begin_layout Standard
\backslash
begin{letter}{Jane Doe
\backslash\backslash
2 Alpha Street
\backslash\backslash
Otherplace, NY 12346}\end_layout
\end_inset
\end_layout
\begin_layout Standard
\begin_inset ERT
status open
\begin_layout Standard
\backslash
opening{Dear Jane,}\end_layout
\end_inset
\end_layout
\begin_layout Standard
\begin_inset ERT
status collapsed
\begin_layout Standard
\backslash
blindtext
\end_layout
\end_inset
\end_layout
\begin_layout Standard
\begin_inset ERT
status open
\begin_layout Standard
\backslash
closing{With Love,}\end_layout
\end_inset
\end_layout
\begin_layout Standard
\begin_inset ERT
status open
\begin_layout Standard
\backslash
end{letter}\end_layout
\end_inset
\end_layout
\end_body
\end_document
EDIT by Markus Kohm, 209-07-18 09:04: Copyright notes at the initial comments ob two of the files changed in respect to LPPL.
Also, in case others stumble upon this thread, it would probably make more sense to setup the envelopes just once using the hook \AtBeginLabels{} instead of the hook \AtBeginLabelPage{} which is inserted at the beginning of every envelope page.
Now if I could just figure out the postscript special command to automatically switch the printer from Tray2+lettersize to Tray1+envelope.
I've looked through the xrx8860.ppd to find the names of the Phaser options and have substituted those names into the three envlab psspecial examples, but so far the printer hasn't switched trays automatically.
Thanks for all your help. I just mailed 1000 letters+envelopes produced with scrlttr2 + envlab, and it all worked fine and looked great.
So I cannot help you with your tray-switching-problem.
I'm very impressed, that my little help resulted in 1000 letters+envelopes after a few days.
BTW: Only a few days ago an English publisher decided not to publish an English translation of the KOMA-Script-Buch, because they couldn't find enough English users ...
Do you prefer english?
I do not understand your question, the language is weird. Maybe you can try again in English?
Would it be possible for
Would it be possible for KOMA-Script scrlttr2 to support the latex package envlab (envelopes + labels) which needs the macro \mlabel{}{} defined? If so, which would be the better solution, adding the envlab instructions to KOMA-Script, or adding an lco file (like labelbasic.lco and settleford600label.lco)? Currently envlab only works with the latex letter class:
(/usr/local/share/texmf/tex/latex/koma-script/DIN.lco) (/usr/share/texmf/tex/latex/envlab.sty ! Package envlab Error: Envlab is used outside of (envlab) a letter-compatible documentclass. ? h You are trying to use Envelopes & Labels package, but your documentclass does not understand address formatting commands. Try standard document class letter
I don't know how difficult it would be to add such support, or the best approach. The basic letter class leaves much to be desired, particularly its handling of margins, headers and footers. The only way I can properly position a company letterhead is to use either the textblock or picture environments to position the letterhead. By contrast the scrlttr2 class handles headers and footers properly. I have a form letter which uses the letter class and the textmerg package to pull in fields from a database (name, address, account balances, etc) and outputs a multipage pdf containing all the form letters (one for each record) followed by envelopes for each letter. I realize the scrlttr2 class can produce a backaddress that appears in an envelope window, but in my case I already have pre-printed #10 business envelopes with no window.
Thanks for your response.
Why not something like labelbasic.lco + settleford600label.lco?
Maybe only an individual parameter set for the labels you are using or for the envelops is needed in addition to labelbasic.lco. If the usage of envlab is a "must be", it may be possible to add
\mlabel
definition and usage by a lco (see examples like sections.lco or PP.lco how to add new functionality to scrlttr2 using lco). Maybe something like (example is not tested!)Disclaimer: I do not know envlab and have no full but minimal example in how to use it and how usage with scrlttr2 should work. So I do not know, if the lco example above may be a solution or part of a solution or would be nonsense!
BTW: There are two new lcos for US letters at the brand new KOMA-Script release 3.04. It would be nice to get some feedback about them, so they may become stable versions (currently they are only betas).
Doesn't work
I looked over the envlab package and it needs \makelabels and \mlabel to already be defined. The envlab package then defines sizes for standard envelopes and letters. It also defines new commands to define your own envelope and label sizes, or modify the size and placement of the boxes containing the addresses. And it also has some options to alter formatting of envelopes/labels, e.g. print barcodes and choose machine-readable font for addressee.
I tried copying the \makelabel code from the letter class:
but scrlttr2 complained:
Apparently, scrlttr2 writes to the aux file:
BTW, here is a minimul, full working example of using envlab with letter class:
P.S.
I will try out the US letter lcos,
UScommercial9DW.lco and UScommercial9.lco,
and give my feedback.
Closer to working
Found the source of the error about
Need to comment out in mlabel.lco:
%\@@par\pagebreak\@@par
But I haven't yet figured out how to put the return address in
\mlabel{FROM}{TO}:
The above mlabel.lco yields following errors:
Without the returnaddress, envelopes print fine:
Can I extract just the text (no formatting) from the komavars fromname & fromaddress?
I can work around this by setting in my komatest.tex
and then in my lco
which works just fine.
But ideally, my lco should be able to figure out returnaddress from the komavars fromname and fromaddress.
Also maybe I should rename mlable.lco to envlab.lco
so that it's clear that the koma option envlab must be used with the envlab package:
\usepackage[koma options, envlab]{scrlttr2}
\usepackage[envlab options]{envlab}
\@processto
The command \@processto which I pulled from the letter class,
extracts \toname and \toaddress from \begin{letter}{to\\str\\address}
correctly so that the envelopes get printed with the correct address information. Unfortunately, I just realized that the addressee information on the letter is now gone. I also just now noticed that the barcodes are missing on the envelopes. I'm not sure what I need to change to the \@processto macro to get it to work correctly with scrlttr2:
Need some time
Thanks for all the information. I need some time for reading, testing etc. now.
Only one thing: Changing
\@processto
in such a way will damage scrlttr2, because scrlttr2 uses its own\@processto
to set up variables toname and toaddress.If there's a namespace
If there's a namespace conflict between the letter and scrlttr2 classes, maybe I can just append the entire envlab.sty to my envlab.lco, and change the names of the variables therein, (\toname, \toaddress, \fromname, \fromaddress), to eliminate the conflict?
The envlab.sty looks fairly simple, just defining standard ISO paper sizes and defining some functions to print parbox'es with sender and adressee info.
Thanks for taking a look.
mlabel.lco at "Dateien"
I've putted a new download for mlabel.lco to "Dateien".
Vielen Dank!
Thanks very, very much. Works perfectly!
It also works perfectly with the textmerg package.
One last question though:
If I change the color of my letterhead to e.g. MyBlue, then my envelopes get printed in the same color MyBlue.
It's no big deal, but is it possible to reset the color?
I'm somewhat confused on how \addtokomafont{komavar} and \setkomafont{komavar} work. Changing the color of elements in the letterhead also changes the color of the body of the letter. So I put in my body code to change color back to black:
Well, I found out I can at
Well, I found out I can at least change the color of the addressee on the envelope by adding
I did some more testing of
I did some more testing of scrlttr2 with mlabel.lco
and discovered that if I have, e.g.
then I get error:
So I then enclosed the addressee info in braces:
which fixed the error, but now barcodes are no longer printed on envelope.
Removing the braces around the address info, fixes the barcode printing problem:
So everything now works correctly with above code.
\textsuperscript is not robust
If you are using non robust macros at moving arguments, you should protect them from breaking. So you may try
\protect\textsuperscript
instead of\textsuperscript
. See also usage of non robust macros in the argument of, e.g.,\section
,\footnote
,\caption
etc.One more question
I hate to bother you again, but I was wondering if it is possible to change the papersize of the envelopes.
The current way sets the pagesize to, e.g. letter, for both the letters and the envelopes. This worked perfectly fine with my old printer, since in order to print an envelope, one only needs to know how far from the top of the page and how far from the {left, middle, right} of the page to print the parbox. The actual width and height of the paper media is irrelevant.
However, my new Xerox Phaser 8860 has sensors in the multipaper tray, which detect the size of the actual media, and it refuses to print unless the size of the pdf matches the size of the media. With Acroread9, I can print my (8.5x11-in letters+envelopes) pdf on #10 envelopes (4.125x9.5-in) only if I select "Autocenter" which then centers a virtual #10 envelope on real 8.5x11in paper, and changes the positioning of the labels. With okular, it is impossible to print a letter-size envelope on #10 media. (I've tried all permutations of "PageSize", "MediaSize" and "PageRegion" and only succeed in scaling 8.5x11 down to 4.125x9.5 with itsy-bitsy print)
The only way I can print an envelope with the Phaser is to set the size of the pdf to the size of the envelope:
So I was wondering if you know a way of switching the pdf papersize from letter to envelope when the latex switches from letters to makelabels?
For now, I've just gone ahead and created a template, "envelope_10.tex" and read in the \mlabels from a perl script.
Once again thanks!
Yes
Since KOMA-Script 3.00 you may change paper size in the document using typearea functionality. I've done so at mlabel.lco's
\startlabels
(remark: envlab.sty overwrites this definition!):If you're using option
pagesize
(orpagesize=auto
orpagesize=automedia
) the new page size will also be written to the PDF by\activateareas
. I've shown this at mlabeltest.(tex|pdf). Against specification of UScommercial9, I've used default paper size A4, so mlabel.lco changes the paper size for the label page (= second page at the pdf).See options
paper
andDIV
and commands\recalctypearea
and\activateareas
at the manual of the current KOMA-Script release, at least version 3.03a. Chapter 2 of the english guide should already be the same like the german one, but\activateareas
may only be found at the expert part of the german manual, scrguide, section 13.1. Sorry, but there's currently only one translator and doing all the changes for the current manual is a lot of work.Since envlab is an old package, that was not changed for 12 years, it does not know such pdfTeX features (like changing
\pdfpagewidth
and\pdfpageheight
at runtime). Maybe you should write a feature request to the package maintainer. Even geometry does not support this, but you may try changing it by typearea like I've done at mlabel.lco.Works with hook \AtBeginLabelPage
Reading through the documentation for envlab, I found the hook \AtBeginLabelPage. So I used this hook together with your papersize commands (\paperwidth, \paperheight, \activateareas) to set both the pdf papersize and the envlab papersize to #10 envelope. And it finally works!
BTW, scrlttr2 + envlab + mlabel.lco works with lyx,
Lyx-1.5.7 is very fussy about the formatting of its preamble. The "Document->LaTeXPreamble" editor hangs when parsing the preamble if lines in the preamble begin with % or space. The workaround is to \input the preamble as straight latex code.
# cat preamble.tex
# cat minimal.lyx
EDIT by Markus Kohm, 209-07-18 09:04: Copyright notes at the initial comments ob two of the files changed in respect to LPPL.
If you do not need to setup the margins on your own
You may try
instead of
So your preamble.tex should even work, if option
pagesize
was not set before.Thanks for the info.
Also, in case others stumble upon this thread, it would probably make more sense to setup the envelopes just once using the hook \AtBeginLabels{} instead of the hook \AtBeginLabelPage{} which is inserted at the beginning of every envelope page.
Now if I could just figure out the postscript special command to automatically switch the printer from Tray2+lettersize to Tray1+envelope.
I've looked through the xrx8860.ppd to find the names of the Phaser options and have substituted those names into the three envlab psspecial examples, but so far the printer hasn't switched trays automatically.
Thanks for all your help. I just mailed 1000 letters+envelopes produced with scrlttr2 + envlab, and it all worked fine and looked great.
I'm not a PostScript expert
So I cannot help you with your tray-switching-problem.
I'm very impressed, that my little help resulted in 1000 letters+envelopes after a few days.
BTW: Only a few days ago an English publisher decided not to publish an English translation of the KOMA-Script-Buch, because they couldn't find enough English users ...