1

How to specify dimensions of barcode in mm ? (when using pst-barcode and labels packages)

scalex,scaley seems to work. Why not absolute dimensions specifications ?

\documentclass[a4paper,12pt]{article}
\usepackage[newdimens]{labels}
\usepackage{pst-barcode}
\usepackage{auto-pst-pdf} % require -shell-escape
\LabelCols=4%
\LabelRows=11%
\LeftPageMargin=7mm%
\RightPageMargin=7mm%
\TopPageMargin=15mm%
\BottomPageMargin=2mm%
\InterLabelColumn=0mm%
\InterLabelRow=0mm%
% These four parameters give the extra space used around the text on
% each actual label.
\LeftLabelBorder=4mm%
\RightLabelBorder=4mm%
\TopLabelBorder=4mm%
\BottomLabelBorder=4mm%
\begin{document}

% Specification of 4mm x 4mm seems not respected
\numberoflabels=4
\boxedaddresslabel{
\begin{pspicture}(4,4mm)
\psbarcode{38}{includetext guardwhitespace}{ean2}
%\psbarcode[scalex=0.2,scaley=0.2]{38}{includetext guardwhitespace}{ean2}
\end{pspicture}
}

% Specification of 0.1in x 0.1in seems not respected
\numberoflabels=4
\boxedaddresslabel{
\begin{pspicture}(0.1,0.1in)
\psbarcode{38}{includetext guardwhitespace}{ean2}
%\psbarcode[scalex=0.2,scaley=0.2]{38}{includetext guardwhitespace}{ean2}
\end{pspicture}
}

% but scalex, scaley seems respected
\numberoflabels=36
\boxedaddresslabel{
\begin{pspicture}
\psbarcode[scalex=0.1,scaley=0.1]{38}{includetext guardwhitespace}{ean2}
\end{pspicture}
}

\end{document}

Command line

pdflatex -shell-escape input.tex

enter image description here

Notes:

If mm are not possible or overcomplicate code, let it be in in.

1

\begin{pspicture}(0.1,0.1in) makes no sense. Without a unit or a preceding \psset{unit=1in} it is always cm. Same for \begin{pspicture}(4,4mm). You have to specify both units if not the default one:

\documentclass[a4paper,12pt]{article}
\usepackage[newdimens]{labels}
\usepackage{pst-barcode}
\usepackage{auto-pst-pdf} % require -shell-escape
\LabelCols=4%
\LabelRows=11%
\LeftPageMargin=7mm%
\RightPageMargin=7mm%
\TopPageMargin=15mm%
\BottomPageMargin=2mm%
\InterLabelColumn=0mm%
\InterLabelRow=0mm%
% These four parameters give the extra space used around the text on
% each actual label.
\LeftLabelBorder=4mm%
\RightLabelBorder=4mm%
\TopLabelBorder=4mm%
\BottomLabelBorder=4mm%
\begin{document}
    \numberoflabels=4
    \boxedaddresslabel{%
        \begin{pspicture}(4mm,4mm)
        \psbarcode{38}{height=0.158 includetext guardwhitespace}{ean2}
        \end{pspicture}%
    }

    \numberoflabels=4
    \boxedaddresslabel{%
        \begin{pspicture}(0.1in,0.1in)
        \psbarcode{38}{width=0.1 height=0.1 includetext guardwhitespace}{ean2}
        \end{pspicture}%
    }

\end{document}

height= and width= are used on PostScript level and are always in the unit inch. 4mm=4/25.3 in=0.158in

enter image description here

scalex and scaley are used on TeX level.

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.