如何将 tikz 元素合并到 latex 标签中,而不会让 (xe)latex 明显挂起

如何将 tikz 元素合并到 latex 标签中,而不会让 (xe)latex 明显挂起

我对 TeX 还很陌生,看过精彩的葡萄酒标签范例我想看看我能想出什么来酿造一些可以装瓶的自酿啤酒。

我有一些 Avery 标签(MD4001,每张纸有 4 个标签,每个标签 90 x 120 毫米)。

我(最终)想要做的是使用这些标签来制作定制的瓶子标签的 4 联打印件。Tikz 和用于邮寄标签的 LaTex 包装看起来正是这样。

问题是,当我尝试\usepackage{labels}与 tikz 结合时,xelatex 会话挂起,需要中断(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.

生成此示例如下。如果我做了一些愚蠢的事情,有人可以告诉我吗?

% 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}  

答案1

您可以通过将图片保存在框中并提前定义颜色来避免此问题。

\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}

相关内容