我想在上面打印带有以下内容的“贴纸”:* 条形码 * 有效日期 * 或许还有一些其他信息。
我有 A4 贴纸纸:65 张贴纸:38 毫米 x 21 毫米;5 列,13 行。我正在使用的贴纸 行与行之间没有间隙;5 列之间有 2mm 间隙(列之间有 4 x 2mm 间隙)。
条形码/有效期(...)可能会以 .eps 格式创建,这将由外部脚本制作,该脚本将使用注释中的最后一个 cell_number 填充 model_stickers.tex,以选择为此特定打印填充哪些单元格。
我认为“model_stickers.tex”可以这样写,但我找不到真正按照我想要的方式创建文档。
\documentclass[english,10pt,a4paper]{article}
% The a4 page to print as a 4mm margin on right and left
% and a 10mm margin on top and bottom
% which leaves a 202mm x 276mm working area
\usepackage[a4paper, textheight=276mm, textwidth=202mm]{geometry}
\pagestyle{empty}
\renewcommand{\arraystretch}{5}
\begin{document}
%\begin{tabu}{|p{38mm}|p{2mm}|p{38mm}|p{2mm}|p{38mm}|p{2mm}|p{38mm}|p{2mm}|p{38mm}|}
\begin{tabu} to \textwidth{|p{38mm-2\tabcolsep}|p{38mm-2\tabcolsep}|p{38mm-2\tabcolsep}|p{38mm-2\tabcolsep}|p{38mm-1\tabcolsep}|}
\centering 1st cell && % cell_1
\centering 2nd cell && % cell_2
\centering 3rd cell && % cell_3
\centering 4th cell && % cell_4
\centering 5th cell \\ % cell_5
\hline
%(...)
\centering 61th cell && % cell_61
\centering 62th cell && % cell_62
\centering 63th cell && % cell_63
\centering 64th cell && % cell_64
\centering 65th cell \\ % cell_65
\end{tabu}
当然,在生产中,我不会放置“\hline”和 vline {|p|p|p|}...但我不知道如何获得一个带有表格的“model_stickers.{ps,dvi,pdf}”。即使我使用“p{40mm-2\tabcolsep}”,或尝试使用 {easytable}...总是有一些东西阻碍我。有人可以告诉我哪个“documentclass”,哪个“tabular/tabularx/tabu/easytable”...以及哪些选项最适合实现我想要做的事情?
答案1
文档letteracdp
类(实际上是我本人编写的:-) 用于写信,但有一个生成地址标签的环境,在您的环境下可能会派上用场:
\documentclass[a4paper]{letteracdp}
\usepackage[T1]{fontenc}
\usepackage[ascii]{inputenc}
\setcounter{addrlabelcolumns}{5}
\setcounter{addrlabelrows} {13}
\setlength{\addrlabelwidth} {38mm}
\setlength{\addrlabelheight}{21mm}
\setlength{\addrlabelshsep} {2mm} % horizontal separation between labels
\setlength{\addrlabelsvsep} {0mm} % vertical separation between labels
\setlength{\addrlabelstopmargin} {1cm} % top margin above labels
\setlength{\addrlabelsleftmargin}{6mm} % left margin
% The following draws a thin border around the labels:
\renewenvironment*{labels}{%
\begin{baselabels}%
\setlength{\fboxrule}{.2pt}% adjust according to your needs
\addtolength{\fboxsep}{-2\fboxrule}%
}{%
\end{baselabels}%
}
\newcommand*{\sticker}[1]{\basemlabel{}{\centering #1}}
\begin{document}
\begin{labels}
\begin{labelgroup}
% You could also use a loop, here:
% row #1
\sticker{First\\sticker}
\sticker{Second\\sticker}
\sticker{Third\\sticker}
\sticker{Fourth\\sticker}
\sticker{Fifth\\sticker}
% row #2
\sticker{And so on\\sticker}
\sticker{And so on\\sticker}
\sticker{And so on\\sticker}
\sticker{And so on\\sticker}
\sticker{And so on\\sticker}
% row #3
\sticker{And so on\\sticker}
\sticker{And so on\\sticker}
\sticker{And so on\\sticker}
\sticker{And so on\\sticker}
\sticker{And so on\\sticker}
% ... and so on
\sticker{And so on\\sticker}
\sticker{And so on\\sticker}
\sticker{And so on\\sticker}
\sticker{And so on\\sticker}
\sticker{And so on\\sticker}
\end{labelgroup}
\end{labels}
\end{document}
上面的代码只生成了前四行,但原理很清晰!下面是它生成的输出:
添加
该类letteracdp
具有额外的好处,对于自动包含名为、、、myImage1.<ext>
……等的图形文件非常有用:每次打印标签时,它会踩下一个名为的(LaTeX)计数器;此外,该计数器在每个环境开始时重置为零(实际上,该环境仅为此目的而存在)。myImage2.<ext>
myImage3.<ext>
myImage10.<ext>
label
labelgroup
例如,以下代码包含第二个labelgroup
环境,在该环境中,我们生成包含三个示例图像的贴纸,分别为image-a
、image-b
和image-c
(它们由包提供mwe
):
\documentclass[a4paper]{letteracdp}
\usepackage[T1]{fontenc}
\usepackage[ascii]{inputenc}
\usepackage{mwe}
\setcounter{addrlabelcolumns}{5}
\setcounter{addrlabelrows} {13}
\setlength{\addrlabelwidth} {38mm}
\setlength{\addrlabelheight}{21mm}
\setlength{\addrlabelshsep} {2mm} % horizontal separation between labels
\setlength{\addrlabelsvsep} {0mm} % vertical separation between labels
\setlength{\addrlabelborder} {2mm} % clearance around label contents
\setlength{\addrlabelstopmargin} {1cm} % top margin above labels
\setlength{\addrlabelsleftmargin}{6mm} % left margin
% The following draws a thin border around the labels:
\renewenvironment*{labels}{%
\begin{baselabels}%
\setlength{\fboxrule}{.2pt}% adjust according to your needs
\addtolength{\fboxsep}{-2\fboxrule}%
}{%
\end{baselabels}%
}
\newcommand*{\sticker}[1]{\basemlabel{}{\centering #1}}
\begin{document}
\begin{labels}
\begin{labelgroup}
% You could also use a loop, here:
% row #1
\sticker{First\\sticker}
\sticker{Second\\sticker}
\sticker{Third\\sticker}
\sticker{Fourth\\sticker}
\sticker{Fifth\\sticker}
% row #2
\sticker{And so on\\sticker}
\sticker{And so on\\sticker}
\sticker{And so on\\sticker}
\sticker{And so on\\sticker}
\sticker{And so on\\sticker}
% row #3
\sticker{And so on\\sticker}
\sticker{And so on\\sticker}
\sticker{And so on\\sticker}
\sticker{And so on\\sticker}
\sticker{And so on\\sticker}
% ... and so on
\sticker{And so on\\sticker}
\sticker{And so on\\sticker}
\sticker{And so on\\sticker}
\sticker{And so on\\sticker}
\sticker{And so on\\sticker}
\end{labelgroup}
\begin{labelgroup}
% You can also use the "label" counter, which is stepped each time
% a label is printed, to select which graphics file to load.
% This counter is reset to zero at the beginning of each "labelgroup"
% environment (this is, actually, the only purpose of this environment).
% For example, to load files "image-a", "image-b", and "image-c":
\sticker{
\includegraphics[
width = \addrlabeltrimwidth,
height = \addrlabeltrimheight
]{image-\alph{label}}
}
\sticker{
\includegraphics[
width = \addrlabeltrimwidth,
height = \addrlabeltrimheight
]{image-\alph{label}}
}
\sticker{
\includegraphics[
width = \addrlabeltrimwidth,
height = \addrlabeltrimheight
]{image-\alph{label}}
}
\sticker{There is no\\\texttt{image-\alph{label}} file}
\sticker{Neither\\\texttt{image-\alph{label}}}
\end{labelgroup}
\end{labels}
\end{document}
这是相应的输出:
您可以通过设置长度来调整图像周围的边框\addrlabelborder
。这里我使用的值为 2mm。