制作贴纸的包裹吗?

制作贴纸的包裹吗?

我想制作信封贴纸。每张贴纸都包含有关信件收件人的数据。我希望能够以某种文本格式 (CSV) 保存这些数据,然后 LaTeX 会将其格式化并打印,在一页上打印多个贴纸。有没有类似这样的软件包?还有其他有效的方法吗?

答案1

环境实验室包装也许是标签本身的最佳选择。结合数据工具这可能非常强大。我已经为UK-TUG 页面:总结一下,LaTeX 文件是

\documentclass[12pt,a4paper]{letter}
\usepackage[T1]{fontenc}
\usepackage[english,UKenglish]{babel}
\usepackage{lmodern}
\usepackage{datatool}
\usepackage[nocapaddress]{envlab}
\DTLloaddb{mailing-list}{example.csv}
\SetLabel 
  {63.5mm}  % width
  {38.1mm}  % height
  {15.15mm} % top margin
  {7.75mm}  % left margin
  {2mm}     % inter-label gap
  {3}       % columns
  {7}       % rows
\makelabels % Tell envlab to make labels in the document.
\makeatletter % We need to access some internal commands
\newcommand*{\IfDataT}[1]{% Create a macro taking one argument
  \ifx#1\empty
    \expandafter\@gobble % Empty input: ignore the next thing
  \else
    \ifx#1\DTLstringnull
      \expandafter\expandafter\expandafter
        \@gobble % NULL input: ignore the next thing
    \else
      \expandafter\expandafter\expandafter
        \@firstofone % Use the next thing unchanged
    \fi
  \fi
} 
\newcommand*{\IfDataTF}[1]{% Create a macro taking one argument
  \ifx#1\empty
    \expandafter\@secondoftwo % Empty value: use the False branch
  \else
    \ifx#1\DTLstringnull
      \expandafter\expandafter\expandafter
        \@secondoftwo % NULL value: use the False branch
    \else
      \expandafter\expandafter\expandafter
        \@firstoftwo % A real value: use the True branch
    \fi
  \fi
} 
\makeatother

\begin{document}

\startlabels
\DTLforeach{mailing-list}{%
  \title=Title,%
  \firstname=Firstname,%
  \lastname=Surname,%
  \addressI=AddressI,%
  \addressII=AddressII,%
  \addressIII=AddressIII,%
  \town=Town,%
  \postcode=Postcode,%
  \country=Country%
}{%
  \mlabel{}{%
    \title\IfDataT\title{~}\firstname\unskip\ \lastname\\
    \addressI \\ 
    \addressII \IfDataT\addressII\\
    \addressIII \IfDataT\addressIII\\
    \IfDataTF\country{%
      \postcode \IfDataT\postcode{~}\town\\
      \country
    }{%
      \town \\
      \postcode \\        
    }%
  }%
} %
\end{document}

使用如下数据库

Title,Firstname,Surname,AddressI,AddressII,AddressIII,Town,Postcode,Country,Email
Miss,Alison,Smith,1 The Street,,,SomeTown,AB1 2XY,,[email protected]
Mr,Ben,Jones,2 The Close,SmallVillage,,OtherTown,AB2 4XY,,[email protected]
Mr,Chris,Brown,Housename,The Main Street,OddVillage,BigTown,AB3 6XY,,[email protected]
Dr,From,Abroad,456 Foreign Stra{\ss}e,Place-en-Conti\'nent,,Townii,2341R,NotInUK,[email protected]

我在这里的基础之上添加的代码用于“漂亮地打印”地址:您可能不需要全部代码。

相关内容