Wrapping text around a phone number, part 2



I asked around a month ago in this group about how to wrap text around a phone number in the upper right corner of each entry and I got a lot of very helpful suggestions, particularly from Patrick McPhee and Scott Pakin. It's taken me a few weeks to study he replies and figure out what I've been able to, but I'll admit that I'm getting lost in the incricacies of how TeX breaks up lines.

I was able to get pretty close to what I needed, but I'm still having trouble with a couple of the details.

To summarize, what I was looking for was a way to set up directory entries with the phone number on the right side of the first line, and if the address and additional information don't all fit on the first line then they print on an additional line (or lines) underneath. I put an image of some of the format that I'm trying to match up on the web at http://www.tomstrong.org/test.png (sorry it's kind of blurry, but it should be clear enough to see how the lines break)

The problems I'm having are:

1) I can't get the 2nd (and later) lines to print under the phone number, at least not beyond the length of the indentation on the left. (I'd like it to indent about 2ex from both the left and right edges of the column)

2) I'm having a lot of trouble with vertical spacing. I could only get the phone number and the rest of the first line to line up by adjusting the parameter to vsplit (I'm not sure why 5pt worked, but that's the length that worked), also I have too much space after the first line and not enough before it. (I'd like too have the text within each entry set a bit tighter than usual and a little extra space between entries)

3) What I'm doing to adjust to the lengths of the phone numbers is pretty clumsy, but it works. Does anyone have a cleaner way to get the length right so that there's about 2ex of space (minimum, more if TeX needs the space) between the phone number and the rest of the material?

Thanks for at least reading this far, any help would be appreciated.


Here's a minimal version of the LaTeX file - it's kind of long, but anything less loses one part of the formatting or another, so I also put it up on the web at http://www.tomstrong.org/test.tex
The PDF output of it (as it is) is at http://www.tomstrong.org/test.pdf


% test framework to see how a block of text is typeset

\documentclass{book}

\usepackage{geometry}
\geometry{twoside, paperwidth=5.25in, paperheight=8.25in, inner=0.5in,
  outer=0.25in}

\usepackage{multicol}
\setlength\columnseprule{.4pt}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% The beginning of the main directory entry formatting routine -
% starting with some extra pieces that it needs
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% limit of text for line 1 - will be set later based on the length of
% the phone number
\newskip\lineonelimit

% width of a line in the directory
\newskip\linewidth
\linewidth=2.25in

% \nameaddr is used (and redefined) inside \makeentry as a macro to hold
% the name and address to ensure that the formatting is consistent \newcommand{\nameaddr}{}


% \makeentry is the master printing routine to display directory entries
% Args:
%  1 - Name (last, first)
%  2 - Phone number as it should be printed
%  3 - length of the phone number string
%  4 - everything else to be printed (address, etc.)
\newcommand{\makeentry}[4]{%
  % set the name and address macro up
  \renewcommand{\nameaddr}{{\bf #1} #4}%
  %
  % adjust the length of the first line based on the length of the
  % phone number - these constants will need to be adjusted if the font
  % or size changes.  There's probably a better way to do this involving
  % setting the phone number in a temporary box and subtracting its width
  % from the line limit, but that's something else I don't understand well
  % enough to implement yet
  \ifnum #3=0% No phone number
    \lineonelimit=2.05in%
  \else%
    \ifnum #3=6% Extension only (8-1234)
      \lineonelimit=1.85in%
    \else%
      \ifnum #3=8% exchange and extension (123-4567)
        \lineonelimit=1.75in%
      \else%
        \ifnum #3=12% area code through extension (123-456-7890)
          \lineonelimit=1.55in%
        \else% something is wrong, or I'm doing something strange
          \lineonelimit=99in%
        \fi%
      \fi%
    \fi%
  \fi%
  %
  % figure out how much material we have - set the name and in a box to
  % see how much horizontal space it takes up and if that will fit before
  % the phone number
  \setbox0\hbox{\nameaddr}%
  \ifdim\wd0<\lineonelimit% less than a line, so put it inline
    \hbox to \linewidth{\nameaddr\dotfill #2}%
  \else % more than a line, so let TeX set a paragraph
    % I don't really understand what's going on in this part - it's
    % mostly what I got from Patrick McPhee on comp.text.tex
    \setbox0\vtop{\hsize=\lineonelimit\noindent\nameaddr}%
    \setbox2\vsplit0 to 5pt%
    % put the first line of the paragraph next to the leaders
    \hbox to \linewidth{\box2\dotfill #2}%
    % and indent the remaining lines
    \hbox to \linewidth{\hskip 2ex\box0\hss}%
  \fi%
  \par%
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% End of the directory formatting routine
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}%
  \begin{multicols}{2}%
    \fontsize{7}{7}\selectfont
    \makeentry{Test Phone, Area Code}{456-123-4567}{12}{A A A A A A A A
    A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A
    A A A A A A A A A }
    \makeentry{Test Phone, Exchange}{234-5678}{8}{A A A A A A A A A A A
    A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A
    A A A A A A }
    \makeentry{Test Phone, Extension}{8-2323}{6}{A A A A A A A A A A A
    A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A
    A A A A A A }
    \makeentry{Test Phone, No Phone}{}{0}{A A A A A A A A A A A A A A A
    A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A
    A A }
    \makeentry{Test Phone, Area Code}{456-123-4567}{12}{A A A A A A A A
    A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A
    A A A A A A A A A }
  \newpage
  \end{multicols}
\end{document}

% EOF

--
 Tom Strong <strong@xxxxxxxxxxxx>
 http://www.tomstrong.org/
.



Relevant Pages

  • Created my own format on first page, want text to continue same. .
    ... I pasted text without formatting into a document. ... page of the text, one entry at a time, using my own formatting. ... Word to adjust the format. ... Is the problem Word XP, ...
    (microsoft.public.word.docmanagement)
  • Re: using custom paragraph borders to separate items in a long list
    ... > type' without having to worry about the formatting. ... > insert a new entry anywhere in the list, ... Each paragraph has a single carriage return at the end, ... I've created a custom style to apply all the formatting. ...
    (microsoft.public.mac.office.word)
  • Re: Change Colors With 5 Different Conditions
    ... Afraid I don't follow all the latest, where did textboxes suddenly come ... > How do I adjust the code to look only in H ... > The D entry sets up the condition for the H entry. ... Goto done will break out ...
    (microsoft.public.excel.programming)
  • Re: Multiple Level Index
    ... puts a separate line for each Reports Switchboard. ... Field codes: XE (Index Entry) field ... do not use hidden text formatting to keep sensitive ...
    (microsoft.public.word.pagelayout)
  • Re: Multiple Level Index
    ... Microsoft Word MVP ... still puts a separate line for each Reports Switchboard. ... Field codes: XE (Index Entry) field ... do not use hidden text formatting to keep sensitive ...
    (microsoft.public.word.pagelayout)