3

With the following MWE:

\documentclass{minimal}
\usepackage{pst-barcode}
\begin{document}
\begin{pspicture}(3.5,3)
    \psbarcode{3-88309-455}{includetext}{isbn}
\end{pspicture}
\end{document}

I get a barcode like this:

So, it’s a little bit anoying, because I want the guard bars (left, middle, and right) reach the base line of the bottom numbers or go over like this:

So, is there an option in \pstbarcode to force the guard lines to be longer than default behavior?

  • The first image is missing. Also, it seems the default behavior is 'correct', compare for example en.wikipedia.org/wiki/Barcode. – Marijn Mar 25 at 16:37
  • So yes, but I search to get an incorrect rendering and I assume it. – fauve Mar 25 at 22:49
1

The postscript code for producing the barcode images is located in the file pst-barcode.pro which is found in your TEXMF tree in /dvips/pst-barcode. You can copy this file to the directory of your document and then the pst-barcode package will load the local file instead of the system file.

Modify the following lines in the ean13 encoder (starting at line 1165 in my version of pst-barcode):

includetext {
        /bhs [height height 12{height .075 sub}repeat height height 12{height .075 sub}repeat height height] def
        /bbs [0 0 12{.075}repeat 0 0 12{.075}repeat 0 0] def
    }

into the following:

includetext {
        /bhs [2{height 0.1 add}repeat 12{height .075 sub}repeat 2{height 0.1 add}repeat 12{height .075 sub}repeat 2{height 0.1 add}repeat] def
        /bbs [-0.1 -0.1 12{.075}repeat -0.1 -0.1 12{.075}repeat -0.1 -0.1] def
    }

Make sure you modify the right lines, there are a lot of similar lines for other encoders but this is the one for ean13 which is used by the isbn encoder.

Explanation (note this may be wrong, I don't know Postscript at all): the bhs line controls the length of the bars. It starts with two bars of length height, then twelve bars of length height-0.075, then two normal bars, etc. The second line controls the baseline of the lines, which is 0 for the first two, 0.075 for the next twelve, etc. So all you need to do is increase the length of the long bars (with the 0.1 add instruction) and lower the baseline (to -0.1 in the example).

Result:

enter image description here

It might be possible to patch the code on the fly (similar to etoolbox/xpatch) instead of copying and modifying the file, but I don't know how to do that.

  • What is the command to find the local path of package in Unix? It seams to be latexdef but I can’t find yet a local copy of pst-barcode. – fauve Mar 28 at 10:43
  • The command is kpsewhich pst-barcode.sty (see tex.stackexchange.com/a/1138). You can also look in the terminal output or in the log file of your document to see the full path of each package used. Note that pst-barcode has a bit of a complex file structure, there is pst-barcode.sty which is a boilerplate package that loads pst-barcode.tex which is a frontend for pst-barcode.pro, each in different directories. I usually just try find . -name somefilename from /usr/share if I want to find the location of a file. – Marijn Mar 28 at 10:53

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.