3

I am very new to TeX, and having seen the fantastic wine label examples I thought I would see what I could come up with for some homebrew which is ready to bottle.

I've got some Avery labels (MD4001, 4 labels to a sheet, each label 90 x 120mm).

What I (eventually) want to do is use these labels to produce 4-up prints of customised bottle labels. Tikz and the LaTex package for mailing labels looked like just the thing.

The problem is that when I try to combine \usepackage{labels} with tikz, the xelatex session hangs, requiring a break (CTRL-C):

*************************************************
* LaTeX warning: "xparse/redefine-command"
* 
* Redefining document command \oldstylenums with arg. spec. 'm' on line 128.
*************************************************
) (/usr/local/texlive/2014/texmf-dist/tex/latex/fontspec/fontspec-xetex.sty
(/usr/local/texlive/2014/texmf-dist/tex/latex/base/fontenc.sty
(/usr/local/texlive/2014/texmf-dist/tex/latex/euenc/eu1enc.def)
(/usr/local/texlive/2014/texmf-dist/tex/latex/euenc/eu1lmr.fd))
(/usr/local/texlive/2014/texmf-dist/tex/xelatex/xunicode/xunicode.sty
(/usr/local/texlive/2014/texmf-dist/tex/latex/tipa/t3enc.def
(/usr/local/texlive/2014/texmf-dist/tex/latex/euenc/eu1lmss.fd)))
(/usr/local/texlive/2014/texmf-dist/tex/latex/fontspec/fontspec.cfg)))
(/usr/local/texlive/2014/texmf-dist/tex/latex/xltxtra/xltxtra.sty
(/usr/local/texlive/2014/texmf-dist/tex/generic/oberdiek/ifluatex.sty)
(/usr/local/texlive/2014/texmf-dist/tex/latex/realscripts/realscripts.sty
*************************************************
* LaTeX warning: "xparse/redefine-command"
* 
* Redefining document command \textsubscript with arg. spec. 's' on line 25.
*************************************************
*************************************************
* LaTeX warning: "xparse/redefine-command"
* 
* Redefining document command \textsuperscript with arg. spec. 's' on line 28.
*************************************************
) (/usr/local/texlive/2014/texmf-dist/tex/latex/metalogo/metalogo.sty))
(./Example.aux) (/usr/local/texlive/2014/texmf-dist/tex/latex/tipa/t3cmr.fd)
*geometry* driver: auto-detecting
*geometry* detected driver: xetex
ABD: EveryShipout initializing macros
To print info, put `\LabelInfotrue' in the preamble
^C! Interruption.
\tikz@path@overlay #1->\let \tikz@signal@path 
                                              =\tikz@signal@path \pgfutil@if...
l.45 ]

? x
No pages of output.
Transcript written on Example.log.

The example to produce this was as follows. Can someone enlighten me if I have managed to do something stupid?:

% XeLaTeX can use any Mac OS X font. See the setromanfont command below.
% Input to XeLaTeX is full Unicode, so Unicode characters can be typed directly into the source.

% The next lines tell TeXShop to typeset with xelatex, and to open and save the source with Unicode encoding.

%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode

\documentclass[12pt]{article}
\usepackage{geometry}                % See geometry.pdf to learn the layout options. There are lots.
\geometry{a4paper}                   % ... or a4paper or a5paper or ... 
\geometry{landscape}                % Activate for for rotated page geometry
%\usepackage[parfill]{parskip}    % Activate to begin paragraphs with an empty line rather than an indent
\usepackage{graphicx}
\usepackage{amssymb}
\usepackage{labels}
\numberoflabels=4
\LabelCols=2
\LabelRows=2
\LeftBorder=5mm
\RightBorder=5mm
\TopBorder=5mm
\BottomBorder=5mm
\usepackage{tikz}
\usepackage{pgfornament}

% Will Robertson's fontspec.sty can be used to simplify font choices.
% To experiment, open /Applications/Font Book to examine the fonts provided on Mac OS X,
% and change "Hoefler Text" to any of these choices.

\usepackage{fontspec,xltxtra,xunicode}
\defaultfontfeatures{Mapping=tex-text}
\setromanfont[Mapping=tex-text]{Hoefler Text}
\setsansfont[Scale=MatchLowercase,Mapping=tex-text]{Gill Sans}
\setmonofont[Scale=MatchLowercase]{Andale Mono}

\begin{document}

\begin{labels}
\begin{tikzpicture}
\node[
  text width=10mm,
  text height=10mm,
  fill={RGB}{248,240,201}
]
  (rect) {};
\end{tikzpicture}
John E. Smith
\TeX{}nician
3.14159265 Knuth Avenue
Anytown
Anyshire
H8W 0RD
Untied Kingdom
\end{labels}

\end{document}  
Bill
  • 33

1 Answers1

2

You can avoid the issue by saving the picture in a box and, also, by defining the colour ahead of time.

\documentclass[12pt,a4paper,landscape]{article}
\usepackage{geometry}
\usepackage{labels}
\numberoflabels=4
\LabelCols=2
\LabelRows=2
\LeftBorder=5mm
\RightBorder=5mm
\TopBorder=5mm
\BottomBorder=5mm
\usepackage{tikz}

\usepackage{fontspec}
\defaultfontfeatures{Mapping=tex-text}
\setromanfont[Mapping=tex-text]{Hoefler Text}
\setsansfont[Scale=MatchLowercase,Mapping=tex-text]{Gill Sans}
\setmonofont[Scale=MatchLowercase]{Andale Mono}

\LabelInfotrue

\begin{document}

  \definecolor{mycol}{RGB}{248,240,201}
  \newsavebox{\mypic}
  \sbox{\mypic}{%
    \begin{tikzpicture}
      \node[
      text width=10mm,
      text height=10mm,
        fill=mycol,
      ]
      (rect) {};
    \end{tikzpicture}
  }

  \begin{labels}
    \usebox{\mypic}
    John E. Smith
    \TeX{}nician
    3.14159265 Knuth Avenue
    Anytown
    Anyshire
    H8W 0RD
    Untied Kingdom
  \end{labels}

\end{document}
cfr
  • 198,882
  • Thank you so much! Having looked up \savebox et. al. I am trying to work out why the fix works (or to put it another way, work out what was semantically wrong with the toy example I submitted). At first I wondered whether I had unwittingly asked TeX to create 4 identical nodes, but there's no identifying name, so I can't see why there would be a clash... I am left with a vague hunch that failing to use \savebox results in some kind of absolute position information for the node, whereas we need to have the tikz commands processed, but defer placement until we're ready to layout each label? – Bill Sep 10 '14 at 21:37
  • @Bill To be honest, I don't know what the cause of the problem is. If you want to know, I suggest asking a new question and linking to this one. There are lots of people on the site who will be able to explain it. I'm just not one of them ;(. I knew how to fix it because I've got a standard file I use with labels which is set up in a similar way (though it doesn't use TiKZ). But I don't remember why I set it up that way... – cfr Sep 10 '14 at 21:57