Problems with printing envelopes.
Rolf Turner <[email protected]> Tue, 11 Nov 2025 06:39:10 +0000
| Newsgroups | gmane.comp.tex.texhax |
|---|---|
| Message-ID | <20251111193901.6e63acab@new-hp> |
i have been trying for some time to print "business size" envelopes on
my Canon printer from my laptop (which runs Ubuntu 24.04). Note that
the business size envelopes that I use are 113 mm x 225 mm.
Initially I tried to use the envlab package, but it printed the main
address in a very ugly small caps style (intended for optical character
recognition). I could find no way to satisfactorily adjust this.
I sought help on the StackExchange forum. A very kind person wrote a
*.tex document to achieve the desired effect. However their effort
remained flawed.
I found the syntax of the StackExchange site to be impossible to
understand and after a number of attempts to communicate the
difficulties that I was having, I gave up. So I am asking here on
texhax instead.
The essential problem is that the left hand margin (this is actually
the *top* margin after the document has been rotated 90 degrees
clockwise so as to align the envelope correctly with the printer) is
too large. The envelopes come out with a left hand margin
of (at least) 35 mm. whereas I would like it to be 12 mm.
In the document that my helpful interlocutor provided, the margins seem
to be controlled by the quantities "return hoffset" and "return
voffset". (See the attached file "demo.tex".)
Setting "return voffset=12mm" works just fine. It gives a distance of
12 mm. between the upper edge of the envelope and the top of the return
address. As desired.
However setting "return hoffset=12mm" produces a distance between
the left hand edge of the envelope and the return address which is much
too large. Even if this quantity is set to 0mm or 0pt, the distance is
still too large.
I tried setting it to a negative value, but this had the effect of
cutting off a segment of the return address. The part of the return
address that actually appeared was still 35 mm. from the left hand edge
of the envelope.
It seems that a "hard" left hand margin of 35 mm. is imposed and my
understanding of the LaTeX code provided is inadequate for me to see
how to change this.
Can someone, cleverer and more knowledgeable than I, point me in the
right direction? I have attached the LaTeX code (that I cannot
properly understand), demo.tex, and the resulting demo.pdf file.
The document in demo.pdf has been rotated 90 degrees clockwise by my
pdf viewer so that it is all ready to be printed onto paper/hard copy.
Eternally grateful for any enlightenment that anyone can provide.
cheers,
Rolf Turner
--
Honorary Academic
Department of Statistics
University of Auckland
Stats. Dep't. (secretaries) phone:
+64-9-373-7599 ext. 89622
Home phone: +64-9-480-4619
demo.tex
(text/x-tex, 2 KB)
\documentclass[12pt,multi,]{standalone}
% 113 mm., x 225.0 mm
\DeclareKeys[envelopes]{%
envelope width .dim_set:N = \envelopewidth,
envelope height .dim_set:N = \envelopeheight,
return hoffset .dim_set:N = \returnhoffset,
return voffset .dim_set:N = \returnvoffset,
address vpos .tl_set:N = \addressvpos,
return address .store = \returnaddress,
return font .store = \returnfont,
address font .store = \addressfont,
envelope height .initial:n = 113mm,
envelope width .initial:n = 225mm,
return hoffset .initial:n = 12mm,
return voffset .initial:n = 12mm,
address vpos .initial:n = {(2\envelopeheight/3)-\ht\tobox},
return font .initial:n = \large\rmfamily,
address font .initial:n = \Large\rmfamily,
return address .initial:n = {%
Rolf Turner\\
50 Park Hill Road\\
Birkenhead 0626\\
New Zealand%
},
}
\newbox\frombox
\newbox\tobox
\NewDocumentEnvironment {envelope} {m+b}
{%
\parindent=0pt
\SetKeys[envelopes]{#1}%
\paperwidth=\envelopewidth
\paperheight=\envelopeheight
\setbox\frombox=\hbox{%
\begin{minipage}{\dimeval{\envelopewidth-40mm}}
\returnfont
\begin{tabular}{@{}l@{}}
\returnaddress
\end{tabular}%
\par
\end{minipage}%
}%
\setbox\tobox=\hbox{%
\begin{minipage}{\envelopewidth}
\centering
\mbox{%
\addressfont
\begin{tabular}{@{}l@{}}
#2
\end{tabular}%
}%
\par
\end{minipage}%
}%
\begin{picture}(\envelopewidth,\envelopeheight)
\put (\returnhoffset,\dimeval{\envelopeheight-\returnvoffset-\ht\frombox}) {%
\box\frombox
}%
\put (0pt,\dimeval{\addressvpos}) {%
\box\tobox
}%
\end{picture}%
}{}
\NewDocumentCommand \NewEnvelope {O{}+m} {%
\begin{envelope}{#1}
#2
\end{envelope}%
}
\standaloneenv{envelope}
\begin{document}
\NewEnvelope[%
return hoffset=0mm,
return voffset=12mm,
]{%
Commonwealth Superannuation Scheme\\
GPO Box 2252, Canberra, ACT 2601\\
Australia
}
\end{document}
demo.pdf
(application/pdf, 27.2 KB) - not displayed