Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm looking at the first, 'letter class' example in LaTeX/Letters - Wikibooks, open books for an open world. What I'd like to do is to use a \newcommand - say, \insertbox - which would be inserted somewhere in the \adress statement, e.g.:

...
\address{\insertbox{}21 Bridge Street \\ Smallville \\ Dunwich DU3 4WE}
...

... and in the definition of \insertbox, have four lines of text (say, 21 Bridge Street \\ Smallville \\ extra line \\ Dunwich DU3 4WE), which will have width of, say, 2.5 cm; positioned to the left of the address lines, and the first line of the (left) box text is aligned to the first line of the address text.

What would be the recommended way to do this?

PS: For reference, I'm hotlinking the page image of the example below:

example letter page

EDIT: The position of the box with red outline is what I'd like to achieve:

letter_example

The text in there is pointless (I just quickly copy pasted a portion of the image in gimp) - but that is what should be specified through the \insertbox command.

share|improve this question
1  
For me the positioning and contents of \insertbox is not exactly clear. Would you be able to produce an image that exactly displays its intent (even if it is in MS Word) and post it? The example image, as it seems, has nothing to do with \insertbox, hence this question. –  Werner Sep 27 '11 at 17:45
    
Thanks for the comment, @Werner - just edited the post and added an image, hope it's clearer now.. Cheers! –  sdaau Sep 27 '11 at 18:08

2 Answers 2

up vote 5 down vote accepted

This might be what you're after:

...
\newcommand{\insertbox}[1]{%
  \llap{\smash{\parbox[t]{2.5cm}{#1}}}%
}
...
\address{\insertbox{hello world \\ some text \\ more text}%
  21 Bridge Street \\ Smallville \\ Dunwich DU3 4WE}

\llap allows for a zero-width box left overlap, while \smash ensures that you can have a line-break that does not influence the line breaking in the remainder of the \address command. Otherwise Smallville would be pushed down with each \\ in \insertbox. Finally, a \parbox[t]{2.5cm} provides a 2.5cm wide (paragraph/left-aligned) box, aligned at the top [t].

enter image description here

share|improve this answer
    
Many thanks for your answer, @Werner - that is exactly what I was looking for; many thanks for the explanation as well!! Cheers! –  sdaau Sep 28 '11 at 6:37

Here a solution based on my adjustbox package. I also added the red border itself. Simply remove the cfbox=red key and the xcolor package if you don't want it.

My \insertbox has an argument to specify the width.

\documentclass{letter}
\usepackage{hyperref}
\usepackage{adjustbox}
\usepackage{xcolor}
\signature{Joe Bloggs}

\newcommand\insertbox[1]{%
    \adjustbox{minipage=[t]{#1},cfbox=red,set height=0pt,set depth=0pt,lap=-\width-10pt}%
}

\address{\insertbox{7.75em}{That said, allow end of providing only if you agree and post it back}21 Bridge Street \\ Smallville \\ Dunwich DU3 4WE}
\begin{document}

\begin{letter}{Director \\ Doe \& Co \\ 35 Anthony Road
\\ Newport \\ Ipswich IP3 5RT}
\opening{Dear Sir or Madam:}

I am writing to you on behalf of the Wikipedia project (http://www.wikipedia.org/),
an endeavour to build a fully-fledged multilingual encyclopaedia in an entirely
open manner, to ask for permission to use your copyrighted material.

% The \ldots command produces dots in a way that will not upset
% the typesetting of the document.
\ldots 

That said, allow me to reiterate that your material will be used to the noble end of
providing a free collection of knowledge for everyone; naturally enough, only if you
agree. If that is the case, could you kindly fill in the attached form and post it
back to me? We shall greatly appreciate it.

Thank you for your time and consideration.

I look forward to your reply.

\closing{Yours Faithfully,}

\ps{P.S. You can find the full text of GFDL license at
\url{http://www.gnu.org/copyleft/fdl.html}.}
\encl{Copyright permission form}

\end{letter}

\end{document}

Result

Technically this isn't much different as Werner's answer, just using adjustbox as wrapper to the different modifications.

share|improve this answer
    
Many, many thanks for that answer, @Martin Scharrer - I have accepted @Werner's answer, as it has the "plain LaTex" explanation - but I guess, I myself, am going to try the adjustbox package... :) Cheers! –  sdaau Sep 28 '11 at 6:39
    
PS: to use adjustbox in Texlive, execute: tlmgr install adjustbox collectbox –  sdaau Sep 28 '11 at 6:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.