![标签包——不居中](https://linux22.com/image/385394/%E6%A0%87%E7%AD%BE%E5%8C%85%E2%80%94%E2%80%94%E4%B8%8D%E5%B1%85%E4%B8%AD.png)
我刚刚开始使用该labels
软件包来管理标签、名片以及几乎所有我计划打印“X-up”的东西。
文档非常清楚——
这个包的任务是在一张纸上制作一个矩形网格,每个项目位于其网格区域的中心。
[...]
然后,在每个标签内,标签文本在框中垂直居中
有没有办法覆盖这个,以便我的标签顶部对齐?
看起来适当的代码在这里:
\boxing@type{%
\vbox to \label@height{%
\vskip\TopLabelBorder
\vss
\hbox to \label@width{%
\hskip\LeftLabelBorder
\usebox{\this@label}%
\hss
}%
\vss
\vskip\BottomLabelBorder
}%
}%
也许我可以包含一些东西(它会进入现场\this@label
),它会以某种方式(我不知道“胶水”和“拉伸”等术语的正确用法)推翻现有的\vss
并强制我的标签与顶部对齐?
答案1
您需要labels
使用newdimens
选项进行调用,然后进行修补\BuildB@x
以删除顶部\vss
作品。
\documentclass{article}
\usepackage[newdimens]{labels}
\usepackage{xpatch}
\makeatletter
\xpatchcmd{\BuildB@x}{\vss}{}{}{}
\makeatother
\begin{document}
\begin{labels}
Me
My address
My City, State, Zipcode
My Brother
His address
His City, State, Zipcode
You
Your address
Your City, State, Zipcode
Me
My address
My City, State, Zipcode
My Brother
His address
His City, State, Zipcode
You
Your address
Your City, State, Zipcode
\end{labels}
\end{document}
还可进行调整\TopLabelBorder
以满足您的需要。
另一种方法是将其设置\TopLabelBorder
为自行取消\vss
:
\documentclass{article}
\usepackage[newdimens]{labels}
\usepackage{xpatch}
\let\TopLabelBorder\relax % :-(, \TopLabelBorder is a dimen
\newlength\TopLabelBorder % let's make it into a skip
\setlength{\TopLabelBorder}{0pt plus -1fil minus -1fil} % cancel the \vss
\begin{document}
答案2
这个解决方案很丑陋,但是对于两行和四行标签来说效果更好。
\documentclass{article}
\usepackage{labels}
\makeatletter
\renewcommand*{\BuildB@x}{%
\iflabel@traddimens
\boxing@type{\parbox[c][\label@height][t]{\label@width}{%
\rule{\LeftBorder}{0pt}%
\usebox{\this@label}%
\rule{\RightBorder}{0pt}%
}%
}%
\else
\begingroup
\fboxsep=-\fboxrule
\boxing@type{\parbox[c][\label@height][t]{\label@width}{%
\vskip\TopLabelBorder
\centering% optional
\usebox{\this@label}
\vskip\BottomLabelBorder
}}%
\endgroup
\fi
\ifnum\skip@labels<\sk@pped\message{x}\else\message{+}\fi
\ifnum\label@number=\LabelCols
\message{|}%
\endgraf\nointerlineskip
\iflabel@traddimens\else\vskip\InterLabelRow\fi
\global\label@number=1
\else\global\advance\label@number by 1
\iflabel@traddimens\else\hskip\InterLabelColumn\fi
\fi
}%
\makeatother
\begin{document}
\begin{labels}
first line
second line
first line
second line
third line
first line
second line
third line
fourth line
first line
second line
first line
second line
third line
first line
second line
third line
fourth line
\end{labels}
\end{document}