5

I am making a sheet of ISBN barcodes like this:

\documentclass{article}

\usepackage{GS1}
\usepackage{textmerg}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.dat}
  0201134489
  978-0201529838
  978-3-319-23796-1
  978-0321173850
  9781847199867
  978-0201362992
\end{filecontents*}

\usepackage[newdimens]{labels}
\LabelCols=3
\LabelRows=5

\LabelGridtrue % show grid for labels

\begin{document}

\Fields{\isbn}

\Merge{\jobname.dat}{%
  \addresslabel{
    \EANBarcode{ISBN \isbn}
  }%
}%

\end{document}

Unfortunately, the barcodes are all zeros instead of ISBN numbers:

Barcodes with just zeros

How can I fix this?

2

2 Answers 2

3

As Marijn pointed out, the solution is as simple as \expandafter\EANBarcode\expandafter{\isbn} instead of \EANBarcode{ISBN \isbn}. I tried this before posting but forgot to remove the "ISBN" filler from the GS1 documentation, so got an error and thought it hadn't fixed the problem. Here is the full working example for completeness:

\documentclass{article}

\usepackage{GS1}
\usepackage{textmerg}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.dat}
  0201134489
  978-0201529838
  978-3-319-23796-1
  978-0321173850
  9781847199867
  978-0201362992
\end{filecontents*}

\usepackage[newdimens]{labels}
\LabelCols=3
\LabelRows=5

\LabelGridtrue % show grid for labels

\begin{document}

\Fields{\isbn}

\Merge{\jobname.dat}{%
  \addresslabel{
    \expandafter\EANBarcode\expandafter{\isbn}
  }%
}%

\end{document}

ISBN barcodes rendered correctly

1

I've recently uploaded to CTAN a suitable version (>=0.0.10 is required) of the package barracuda with ISBN and ISSN support. Now you can resolve the argument expansion naturally because automatic expansion of tokens, being passed to the \directlua primitive.

You don't need to write Lua code thanks to barracuda.sty LaTeX package deployed in bundle---barracuda is quite entirely written in Lua and may works also with a normal interpreter like texlua to produce SVG barcode.

The benefit consists in a more sophisticated input and output barcode processing. In your example the package is able to decide if the label ISBN text upon the symbol must be printed or not. In fact, if no additional information are provided respect to the underlying EAN code, no ISBN notation is made. For instance, if in the input code are present dash characters, then this is assumed to be an additional information suitable for the top ISBN label addition, while if the input code is merely a digit sequence, no label option is choosen.

Anyway, the user could correct this behavior with the option text_isbn_enable. The accepted value are true, false or "auto" that it's the default.

As a final remark, if the checksum is correct barracuda accepts equally as ISBN 10 digits long input code or EAN 13 equivalent.

The \barracuda macro syntax is: \barracuda[option]{encoder}{input code} like in:

\barracuda[text_isbn_enable = false]{ean-isbn}{0201134489}

The code example for LuaLaTeX is as follow (barracuda doesn't work with pdflatex engine):

% !TeX program = LuaLaTeX
\documentclass{article}
\usepackage{fontspec}
\setmainfont{ocrb10}
\usepackage{barracuda}

\usepackage{textmerg}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.dat}
  0201134489
  978-0201529838
  978-3-319-23796-1
  978-0321173850
  9781847199867
  978-0201362992
\end{filecontents*}

\usepackage[newdimens]{labels}
\LabelCols=3
\LabelRows=5

\LabelGridtrue % show grid for labels

\begin{document}
\Fields{\isbn}

\Merge{\jobname.dat}{%
  \addresslabel{
    \barracuda{ean-isbn}{\isbn}% naturally expanded
  }%
}%
\end{document}

Thank you. R.

2
  • There is no need for font change really, but perhaps you can use \ttfamily (not \setmainfont{ocrb10}). Also, filecontents is obsolete.
    – Werner
    Feb 7, 2020 at 0:00
  • Sure. I was focused on barcode input code expansion. Thank you. R.
    – robitex
    Feb 7, 2020 at 13:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .