# How to use \usepackage{pst-barcode}

When using \usepackage {pst-barcode} I get error :

  \documentclass[10pt,a4paper,twoside,openany]{book}
\usepackage[spanish]{babel}
\usepackage[dvipsnames,x11names]{pstricks}% Options for xcolor
\usepackage{pst-barcode}
\usepackage[utf8]{inputenc}
\begin{document}
\begin{pspicture}(3.5,1.2in)
\end{pspicture}
\end{document}


• Your edited example works just fine with xelatex or latex->dvips->ps2pdf – user2478 Feb 20 '16 at 9:53
• The last digit "6" is wrong, it must be "7". See my example – user2478 Feb 23 '16 at 14:43
• @Herbert And if I use the digit " 6" how can I make it work ? i need bar code with the tex 1613198400316 – casio Feb 24 '16 at 2:36
• The 13th digit is a check digit for ean13 and is computed depending to the Otter digits See en.wikipedia.org/wiki/International_Article_Number_(EAN) – user2478 Feb 24 '16 at 5:46

You can pass the options for xcolor via pstricks:

\documentclass{article}
\usepackage[dvipsnames,x11names]{pstricks}% Options for xcolor
\usepackage{pst-barcode}
\begin{document}
\begin{pspicture}(3.5,1.2in)
\end{pspicture}
\end{document}


xcolor itself loads by default color

And with

\psbarcode[linecolor=red]{1613198400317}{includetext inkspread=0.5}{ean13}


• thanks for you answer, but when i tried your code to ean13, not function to me – casio Feb 20 '16 at 4:18
• Did you run the example with xelatex? – user2478 Feb 20 '16 at 6:15
• i run with latex->dvips->ps2pdf . But when I try your code with 1613198400316 , bar codes without appears , that happen? – casio Feb 20 '16 at 22:20
• My Code was ean8, but your Long Numbers needs ean13 – user2478 Feb 21 '16 at 7:08
• The number must be {161319840031} or {1613198400317} . In the first case the control digit is computed internally and in the second case it is corect with 7 but not a 6 as in your above example. – user2478 Feb 22 '16 at 21:01

Pstricks (loaded by pst-barcode) already loads xcolor without option. If you load the latter with an option, there will be an ‘option clash’. The solution consists in loading the option from within the document class, which will propose it to all subsequent packages, until one of them recognises it.

Alternative solution: write in the preamble \PassOptionsToPackage{selected options}{xcolor}.