2

I am creating a page of sticky labels containing Library of Congress Classification call numbers (LCCs). They are in what the labels package calls "plain format".

\begin{filecontents*}{\jobname.dat}
PR
6051
.D3352
M68

Z
253.4
.T47
K58

QA
76.6
.K644

Z
250.8
.M46
E578

PR
5815

PR
6039
.O32
T65
\end{filecontents*}
\documentclass[letterpaper,10pt]{article}

\usepackage[newdimens]{labels}
\LabelCols=3
\LabelRows=10
\LeftPageMargin=4mm
\RightPageMargin=4mm
\TopPageMargin=12.5mm
\BottomPageMargin=13mm
\InterLabelColumn=4mm
\InterLabelRow=0mm
\LeftLabelBorder=0.2mm
\RightLabelBorder=0.2mm
\TopLabelBorder=0.2mm
\BottomLabelBorder=0mm

\LabelGridtrue % show grid for labels
\LabelInfotrue % show info for labels

\begin{document}
\labelfile{\jobname.dat}
\end{document}

It looks like this:

simple labels, left flush

However, I actually want to adjust the formatting of the labels so that they are shifted to the right while still being left-aligned. I accomplished this like so:

\begin{center}%
\parbox{20mm}{%
PR
6051
.D3352
M68}\end{center}

Full text here:

\documentclass[letterpaper,10pt]{article}

\usepackage[newdimens]{labels}
\LabelCols=3
\LabelRows=10
\LeftPageMargin=4mm
\RightPageMargin=4mm
\TopPageMargin=12.5mm
\BottomPageMargin=13mm
\InterLabelColumn=4mm
\InterLabelRow=0mm
\LeftLabelBorder=0.2mm
\RightLabelBorder=0.2mm
\TopLabelBorder=0.2mm
\BottomLabelBorder=0mm

\LabelGridtrue % show grid for labels
\LabelInfotrue % show info for labels

\begin{document}
\begin{labels}%
\begin{center}%
\parbox{20mm}{%
PR
6051
.D3352
M68}\end{center}

\begin{center}%
\parbox{20mm}{%
Z
253.4
.T47
K58}\end{center}

\begin{center}%
\parbox{20mm}{%
QA
76.6
.K644}\end{center}

\begin{center}%
\parbox{20mm}{%
Z
250.8
.M46
E578}\end{center}

\begin{center}%
\parbox{20mm}{%
PR
5815}\end{center}

\begin{center}%
\parbox{20mm}{%
PR
6039
.O32
T65}\end{center}

\end{labels}

\end{document}

It looks like this:

better formatted labels

Of course, I still need to read in from the external file. I thought maybe I could modify the \labelfile macro to accomplish this. However, when I looked at labels.sty, I found it was just a wrapper for \input.

\def\labelfile#1{\begin{labels}\input#1\end{labels}}

So next I tried textmerg.

\begin{filecontents*}{\jobname.dat}
PR
6051
.D3352
M68

Z
253.4
.T47
K58

QA
76.6
.K644

Z
250.8
.M46
E578

PR
5815

PR
6039
.O32
T65
\end{filecontents*}
\documentclass[letterpaper,10pt]{article}

\usepackage{textmerg}

\usepackage[newdimens]{labels}
\LabelCols=3
\LabelRows=10
\LeftPageMargin=4mm
\RightPageMargin=4mm
\TopPageMargin=12.5mm
\BottomPageMargin=13mm
\InterLabelColumn=4mm
\InterLabelRow=0mm
\LeftLabelBorder=0.2mm
\RightLabelBorder=0.2mm
\TopLabelBorder=0.2mm
\BottomLabelBorder=0mm

\LabelGridtrue % show grid for labels
\LabelInfotrue % show info for labels

\begin{document}
\Fields{\subclass\number\cutter}

\Merge{\jobname.dat}{%
  \addresslabel{
    \begin{center}
    \parbox{20mm}{
      \subclass\\
      \number\\
      \cutter}
    \end{center}
  }%
}%
\end{document}

Unfortunately, LCCs are variable length; they are typically between two to four lines long. Some have one or more Cutter numbers; some do not. This means the numbers get split up incorrectly.

labels split up incorrectly

Of the following, what would be the best approach?

  • Override the macros in labels to get the formatting I want?

    (I wasn't able to find a hint on this in the documentation.)

  • Use an advanced feature of textmerg to handle the variable-length format?

    (The "complicated example" in the manual deals with a "table of indeterminate length, albeit fixed width". I believe in this case the width is not fixed.)

  • Use a different package, such as datatool?

    Most of the examples in datatool deal with CSVs, so I'm not sure how well this would work.

Here is a link to a git repository to make it easier to get the files:

https://github.com/nbeaver/lcc-label-question

1

Set \LeftLabelBorder to a higher value:

\documentclass[letterpaper,10pt]{article}
\usepackage[pass]{geometry} % because my default output paper would be A4

\usepackage[newdimens]{labels}
\LabelCols=3
\LabelRows=10
\LeftPageMargin=4mm
\RightPageMargin=4mm
\TopPageMargin=12.5mm
\BottomPageMargin=13mm
\InterLabelColumn=4mm
\InterLabelRow=0mm
\LeftLabelBorder=10mm    % <--- changed
\RightLabelBorder=0.2mm
\TopLabelBorder=0.2mm
\BottomLabelBorder=0mm

\LabelGridtrue % show grid for labels
\LabelInfotrue % show info for labels

\begin{document}
\labelfile{\jobname.dat}
\end{document}

enter image description here

  • Can't believe I missed such a simple and elegant solution! – Nathaniel M. Beaver Aug 3 '18 at 16:14

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.