BusinessCard

From Wiki
Jump to navigation Jump to search

< Sample documents

As an example of using ConTeXt for something more DTP-like, let us consider business cards. The code below is what I actually did for our hobby cattery.

I used Zweckform No. 32011 business cards with smooth edges (i.e., precut). If you print on plain thick paper and cut yourself, I suggest using a nonzero distance in the vertical direction as well.

In any case, my first step was to define the cards in the size given by the paper template (which is the usual size of business cards around here anyway) and to define the layer I am going to place material on:

  \definepapersize[BC][width=85mm,height=54mm]
  \definelayer[blocks][width=85mm,height=54mm]

Getting ten of these cards onto an A4 sheet at the proper place is easy:

  \setuppapersize[BC][A4]
  \setuplayout[nx=2,ny=5,dx=1cm,dy=0pt]
  \setuplayout[location=middle,width=fit,height=fit]
  \setuppagenumbering[location=,state=stop] 

I used Palatino and Zapfino for these cards. Since my Zapfino installation is only very rudimentary yet, I had to load the map file generated by texfont manually:

  \usetypescript[palatino][texnansi]
  \setupbodyfont[palatino]
  %
  \loadmapfile[texnansi-apple-zapfino]
  \definefontsynonym[Zapfino][texnansi-Zapfino][encoding=texnansi]
  \definefont[ZapfinoMedium][Zapfino at 13pt]
  \definefont[ZapfinoBig][Zapfino at 15pt]

While designing the cards, the following is very useful:

 \showframe[edge]

To make ConTeXt use color and actually use the layer defined above, I invoked these commands:

  \setupcolors
   [state=start]
  
  \setupbackgrounds[page][background=blocks]

Inside the actual body ...

 \starttext

... each card is inside a \startstandardmakeup ... \stopstandardmakeup block. Each such block creates a single page, which by thesettings above is repeated ten times, filling one sheet of paper.

  \startstandardmakeup
    \setlayer[blocks][preset=rightbottom]{%
      \externalfigure[g-wurf][height=4.7cm]}
    \setlayer[blocks][preset=middletop,voffset=1mm]%
             {\ZapfinoMedium Title}
    \startbuffer
      \vbox{%
      \startlines
      Some Names
      of Some Cats
      \vskip-3pt\tfx smaller
      \vskip-5pt text
      \stoplines}
    \stopbuffer
    \setlayer[blocks][voffset=1.5cm,hoffset=2mm]{\getbuffer}
    \startbuffer
      \vbox{%
         Name and\hfill\break
         Address
      }%
    \stopbuffer
    \setlayer[blocks][preset=leftbottom,offset=1.5mm,hoffset=0.5mm]{\getbuffer}
    \setlayer[blocks][preset=rightbottom,offset=1.5mm]{www.samtfeld.de}
  \stopstandardmakeup

The precise placement probably doesn't make much sense since you don't see the image I used for the background. However, reading it should not provide difficulties: All offsets are inwards, so when using preset=leftbottom, hoffset is to the right and voffset is upwards. offset, when used, is added to both of these.

There may be a better way than the \startlines ... \stoplines I used, but I just found it to work.

The next card is going to use a flat color in the background. I just asked photoshop to tell me the color used at the border of the included image and divided all the numbers by 255.

  \definecolor[bgnd][r=0.98,g=0.95,b=0.89]
  \setupbackgrounds[paper][background=color,backgroundcolor=bgnd]
  %
  \startstandardmakeup
    \setlayer[blocks][preset=rightbottom]{%
      \externalfigure[homer][height=4cm]}
    \setlayer[blocks][preset=middletop,voffset=2mm]%
             {\vbox{\centerline{\ZapfinoBig vom samtenen Felde}%
               \centerline{BKH in lilac und blau}}}
    \startbuffer
      \vbox{%
      \startlines
        Petra Fries
        Christopher
        \vskip-2pt~~Creutzig
        Address and
        phone number
      \stoplines\unskip\vskip-\prevdepth}
    \stopbuffer
    \setlayer[blocks][preset=leftbottom,offset=1.5mm]{\getbuffer}
    \setlayer[blocks][preset=rightbottom,offset=1.5mm]{\tfx www.samtfeld.de}
  \stopstandardmakeup

Note that here I wanted two blocks aligned vertically at their base lines, so I had to use \unskip\vskip-\prevdepth after the \stoplines command -- \unskip removed the empty line/vertical space introduced by \stoplines, while \vskip-\prevdepth made the baseline of the last line of the text the new bottom line of the whole block.

To undo the paper coloring, invoke

  \setupbackgrounds[paper][background=none]

One more card I'd like to show, because here I used an image over the whole card, clipped from a larger image and “bleeding” to the left and the right. This bleeding is a good idea to avoid little white stripes at the border and is also the reason why I suggest a nonnegative distance between cards if you've got the choice. Also note the \startalignment[left]: In this context, “left” means “ragged on the left side.”

  \startstandardmakeup
    \setlayer[blocks][corner=bottom,location={top,right},hoffset=-1.5mm]%
             {\clip[width=94mm,height=54mm,
                 hoffset=17mm,voffset=16mm]%
               {\externalfigure[caillean][height=7cm]}}
    \setlayer[blocks][preset=topleft,voffset=2mm,hoffset=1.5mm]%
             {\ZapfinoBig vom samtenen Felde}%
    \setlayer[blocks][preset=righttop,voffset=9.5mm,offset=3mm]%
             {\tfx Hobbyzucht Britisch Kurzhaar}
    \startbuffer
      \startalignment[left]
      \vbox{%
      \startlines
        Petra Fries
        Christopher~~
        \vskip-3pt Creutzig
        Address and
        phone number
      \stoplines\unskip\vskip-\prevdepth}
    \stopalignment
    \stopbuffer
    \setlayer[blocks][preset=rightbottom,offset=1.5mm]{\getbuffer}
    \setlayer[blocks][preset=leftbottom,offset=1.5mm]{\tfx www.samtfeld.de}
  \stopstandardmakeup
  %
  \stoptext