1

I use pdflatex and I am interested in using \psbarcode from \usepackage{pst-barcode}. I think I found the answer in the last post here but the explanation starts with run pdflatex -shell-escape <file> How and where to do this? Could you please give me an example with some file name and file extension. I suppose I have to write .tex? I work on Windows 7. I use TeXnicCenter.

2
  • which editor do you use?
    – user2478
    Commented Jun 4, 2012 at 13:12
  • 1
    for TeXnicCenter you'll find her what to do: tug.org/PSTricks/main.cgi?file=pdf/pdfoutput#TXC However, the easiest way is to use xelatex instead of pdflatex
    – user2478
    Commented Jun 4, 2012 at 14:59

1 Answer 1

2

It is better to separate codes to generate diagrams from the main TeX input file. Here I put the code to generate barcode in a single separate file called mybarcode.tex for example.

%compile it with xelatex or the combo sequence latex-dvips-ps2pdf
%it is mybarcode.tex

\documentclass{article}

\usepackage{pst-barcode}

\usepackage[tightpage,active]{preview}
\PreviewBorder=0pt
\PreviewEnvironment{pspicture}


\begin{document}

\begin{pspicture}[showgrid=false](1.49,1.49)% I got this value by inspection (zooming up to 1000%)
    \psbarcode{tug.org}{}{qrcode}
\end{pspicture}

\end{document}

Compiling mybarcode.tex with xelatex or latex-dvips-ps2pdf, you will get mybarcode.pdf as follows:

enter image description here

From within your main TeX input file, you can import the PDF using \includegraphics[scale=2]{mybarcode} macro provided by graphicx.

5
  • for xelatex there is no need for loading preview and pspicture is already defined as a preview environment. However, using \usepackage[pdf]{pstricks} simplifies the whole setting.
    – user2478
    Commented Jun 4, 2012 at 16:02
  • preview is not needed for PSTricks, it does only the cropping in this case
    – user2478
    Commented Jun 5, 2012 at 6:06
  • using auto-pst-pdf does it all.
    – user2478
    Commented Jun 5, 2012 at 10:49
  • it loads pst-pdf and that package uses preview
    – user2478
    Commented Jun 5, 2012 at 10:54
  • for the PostScript part latex and for the document that program what the user started, pdflatex or xelatex
    – user2478
    Commented Jun 5, 2012 at 11:01

You must log in to answer this question.

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