如何打印地址

如何打印地址

我有一份地址列表。我该如何打印这些地址,以便可以打印出来并粘贴到信封上?我的意思是,我希望每页每行都有三个地址,每列都有八个地址,就像这样

firstname1 surname1   firstname2 surname2   firstname3 surname3
streetaddress1        streetaddress2        streetaddress3
zip1 city1            zip2 city2            zip3 city3

firstname4 surname4   firstname5 surname5   firstname6 surname6
streetaddress4        streetaddress5        streetaddress6
zip4 city4            zip5 city5            zip6 city6

...

firstname22 surname22 firstname23 surname23 firstname24 surname24
streetaddress22       streetaddress23       streetaddress24
zip22 city22          zip23 city23          zip24 city24

最终的页面将从左到右填充,如下所示:

firstname25 surname25 firstname26 surname26 firstname27 surname27
streetaddress25       streetaddress26       streetaddress27
zip25 city25          zip26 city26          zip2 city27

firstname28 surname28
streetaddress28
zip28 city28

答案1

您可以使用minipage并适当调整其大小,我使用pgffor包只是为了创建一个简单的循环来演示该技术。

如果将文件存储在 CSV 文件中,如下所示:

Stephen P Jobs, 1 Infinite Loop, Cupertino, CA 95014
Tim Cook, 1 Infinite Loop, Cupertino, CA 95014
Larry Page, 1600 Amphitheatre Pkwy, Mountain View, CA 94043
Sergey Brin, 1600 Amphitheatre Pkwy, Mountain View, CA 94043
Erich Schmidt, 1600 Amphitheatre Pkwy, Mountain View, CA 94043

然后你可以使用包裹datatool读入 CSV 文件。结果如下:

在此处输入图片描述

笔记:

  • 包裹filecontents 用于设置要为此测试用例读取的文件。实际用例中不需要它。

代码:演示

\documentclass{article}
\usepackage{pgffor} 

\newcommand*{\NewAddress}[1]{%
\noindent
\begin{minipage}[t][0.12\textheight]{0.33\linewidth}
\begin{tabular}{@{}l@{}}
    #1
\end{tabular}%
\end{minipage} % <-- Need space here
}

\begin{document}
\foreach \x in {1,...,128} {%
    \NewAddress{%
        firstname1 surname1 \\
        streetaddress1 \\
        zip1 city1  \\
    }%
}
\end{document}

代码:使用 CSV 文件:

\documentclass{article}
\usepackage{pgffor} 
\usepackage{datatool}
\usepackage{times}

\usepackage{filecontents}% <-- Commented out to prevent overwriting address.csv
\begin{filecontents*}{address.csv}
    Stephen P Jobs, 1 Infinite Loop, Cupertino, CA 95014
    Tim Cook, 1 Infinite Loop, Cupertino, CA 95014
    Larry Page, 1600 Amphitheatre Pkwy, Mountain View, CA 94043
    Sergey Brin, 1600 Amphitheatre Pkwy, Mountain View, CA 94043
    Erich Schmidt, 1600 Amphitheatre Pkwy, Mountain View, CA 94043
    Stephen P Jobs, 1 Infinite Loop, Cupertino, CA 95014
    Tim Cook, 1 Infinite Loop, Cupertino, CA 95014
    Larry Page, 1600 Amphitheatre Pkwy, Mountain View, CA 94043
    Sergey Brin, 1600 Amphitheatre Pkwy, Mountain View, CA 94043
    Erich Schmidt, 1600 Amphitheatre Pkwy, Mountain View, CA 94043
    Stephen P Jobs, 1 Infinite Loop, Cupertino, CA 95014
    Tim Cook, 1 Infinite Loop, Cupertino, CA 95014
    Larry Page, 1600 Amphitheatre Pkwy, Mountain View, CA 94043
    Sergey Brin, 1600 Amphitheatre Pkwy, Mountain View, CA 94043
    Erich Schmidt, 1600 Amphitheatre Pkwy, Mountain View, CA 94043
    Stephen P Jobs, 1 Infinite Loop, Cupertino, CA 95014
    Tim Cook, 1 Infinite Loop, Cupertino, CA 95014
    Larry Page, 1600 Amphitheatre Pkwy, Mountain View, CA 94043
    Sergey Brin, 1600 Amphitheatre Pkwy, Mountain View, CA 94043
    Erich Schmidt, 1600 Amphitheatre Pkwy, Mountain View, CA 94043
    Stephen P Jobs, 1 Infinite Loop, Cupertino, CA 95014
    Tim Cook, 1 Infinite Loop, Cupertino, CA 95014
    Larry Page, 1600 Amphitheatre Pkwy, Mountain View, CA 94043
    Sergey Brin, 1600 Amphitheatre Pkwy, Mountain View, CA 94043
    Erich Schmidt, 1600 Amphitheatre Pkwy, Mountain View, CA 94043
    Stephen P Jobs, 1 Infinite Loop, Cupertino, CA 95014
    Tim Cook, 1 Infinite Loop, Cupertino, CA 95014
    Larry Page, 1600 Amphitheatre Pkwy, Mountain View, CA 94043
    Sergey Brin, 1600 Amphitheatre Pkwy, Mountain View, CA 94043
    Erich Schmidt, 1600 Amphitheatre Pkwy, Mountain View, CA 94043
    Stephen P Jobs, 1 Infinite Loop, Cupertino, CA 95014
    Tim Cook, 1 Infinite Loop, Cupertino, CA 95014
    Larry Page, 1600 Amphitheatre Pkwy, Mountain View, CA 94043
    Sergey Brin, 1600 Amphitheatre Pkwy, Mountain View, CA 94043
    Erich Schmidt, 1600 Amphitheatre Pkwy, Mountain View, CA 94043
    Stephen P Jobs, 1 Infinite Loop, Cupertino, CA 95014
    Tim Cook, 1 Infinite Loop, Cupertino, CA 95014
    Larry Page, 1600 Amphitheatre Pkwy, Mountain View, CA 94043
    Sergey Brin, 1600 Amphitheatre Pkwy, Mountain View, CA 94043
    Erich Schmidt, 1600 Amphitheatre Pkwy, Mountain View, CA 94043
    Stephen P Jobs, 1 Infinite Loop, Cupertino, CA 95014
\end{filecontents*}


\newcommand*{\NewAddress}[1]{%
\noindent
\begin{minipage}[t][0.12\textheight]{0.33\linewidth}
\begin{tabular}{@{}l@{}}
    #1
\end{tabular}%
\end{minipage} % <-- Need space here
}

\begin{document}
\DTLloaddb[noheader,keys={Name,Address,City,StateAndZip}]{myDB}{address.csv}
\DTLforeach*{myDB}{\Name=Name,\Address=Address,\City=City, \StateAndZip=StateAndZip}{%
    \NewAddress{%
        \Name \\
        \Address, \\
        \City, \\
        \StateAndZip  \\
    }%
}%
\end{document}

答案2

labels与之结合的包装对此textmerg非常有用。我用它在激光打印机上打印标签页,但你当然也可以在普通纸上打印,然后根据需要将其剪下来并粘贴。

地址详细信息保存在单独的文件中,此处使用 包含该文件filecontents

\documentclass{article}
\usepackage{textmerg}                                                                                                           \usepackage[newdimens]{labels}
\usepackage{filecontents}% insists on writing comments to first 4 lines of file for some reason so need dummy text on first line which can be discarded below
\begin{filecontents*}{\jobname.dat}
    firstname1
    surname1
    address1
    zip1
    city1
    firstname2
    surname2
    address2
    zip2
    city2
    firstname3
    surname3
    address3
    zip3
    city3
    firstname4
    surname4
    address4
    zip4
    city4
    firstname5
    surname5
    address5
    zip5
    city5
    firstname6
    surname6
    address6
    zip6
    city6
    firstname7
    surname7
    address7
    zip7
    city7
    firstname8
    surname8
    address8
    zip8
    city8
    firstname9
    surname9
    address9
    zip9
    city9
    firstname10
    surname10
    address10
    zip10
    city10
    firstname11
    surname11
    address11
    zip11
    city11
    firstname12
    surname12
    address12
    zip12
    city12
    firstname13
    surname13
    address13
    zip13
    city13
    firstname14
    surname14
    address14
    zip14
    city14
    firstname15
    surname15
    address15
    zip15
    city15
    firstname16
    surname16
    address16
    zip16
    city16
    firstname17
    surname17
    address17
    zip17
    city17
    firstname18
    surname18
    address18
    zip18
    city18
    firstname19
    surname19
    address19
    zip19
    city19
    firstname20
    surname20
    address20
    zip20
    city20
    firstname21
    surname21
    address21
    zip21
    city21
    firstname22
    surname22
    address22
    zip22
    city22
    firstname23
    surname23
    address23
    zip23
    city23
    firstname24
    surname24
    address24
    zip24
    city24
    firstname25
    surname25
    address25
    zip25
    city25
    firstname26
    surname26
    address26
    zip26
    city26
    firstname27
    surname27
    address27
    zip27
    city27
    firstname28
    surname28
    address28
    zip28
    city28
\end{filecontents*}


\LabelCols=3
\LabelRows=8
\LeftPageMargin=4.5mm
\RightPageMargin=4.5mm
\TopPageMargin=13mm
\BottomPageMargin=13mm
\InterLabelColumn=2.5mm
\InterLabelRow=0mm
\RightLabelBorder=5mm
\LeftLabelBorder=5mm
\TopLabelBorder=5mm
\BottomLabelBorder=5mm

% \LabelGridtrue %turn on to line stuff up; off to process final version
\numberoflabels=1

\begin{document}

  \Fields{\firstname\surname\address\zip\city}

  \Merge{\jobname.dat}{%
      \addresslabel[\small\sffamily]{%
        \firstname\ \surname\\\address\\\zip\ \city
      }%
  }


\end{document}

28 个标签

相关内容