3

I've just started using the labels package to manage labels, business cards, and pretty much anything I plan to print "X-up".

The documentation is pretty clear --

The task of this package is to produce a rectangular grid of items on a sheet of paper, with each item centered in its grid area.

[...]

Then, within each label, the label text is vertically centered in a box

Is there a way to override this, so that my labels are top-aligned?

It looks like the appropriate code is here:

 \boxing@type{%
  \vbox to \label@height{%
   \vskip\TopLabelBorder
   \vss
   \hbox to \label@width{%
    \hskip\LeftLabelBorder
    \usebox{\this@label}%
    \hss
  }%
  \vss
  \vskip\BottomLabelBorder
 }%
}%

Perhaps there is something I can include (that would go into the \this@label spot) that would somehow (I don't know the proper use of terms like "glue" and "stretch") overrule the existing \vss and force my label to be aligned to the top?

  • One could place each label into a \parbox[c][<height>[t]{<width}{...}, but that sort of defeats the whole purpose of the labels environment. But not the \addresslabel \boxedaddresslabel approach. – John Kormylo Nov 6 '18 at 17:04
1

You need to call labels with the newdimens options and then patching \BuildB@x to remove the top \vss works.

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

enter image description here

Adjust also \TopLabelBorder to suit your needs.

A different hack is to set \TopLabelBorder to cancel \vss itself:

\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}
  • The second (short) one worked perfectly. Thank you! – hymie Nov 7 '18 at 14:51
0

This solution is a lot uglier, but does better with two and four line labels.

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

demo

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.