Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
    
which editor do you use? –  Herbert Jun 4 '12 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 –  Herbert Jun 4 '12 at 14:59
add comment

1 Answer 1

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.

share|improve this answer
    
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. –  Herbert Jun 4 '12 at 16:02
    
preview is not needed for PSTricks, it does only the cropping in this case –  Herbert Jun 5 '12 at 6:06
    
using auto-pst-pdf does it all. –  Herbert Jun 5 '12 at 10:49
    
it loads pst-pdf and that package uses preview –  Herbert Jun 5 '12 at 10:54
    
for the PostScript part latex and for the document that program what the user started, pdflatex or xelatex –  Herbert Jun 5 '12 at 11:01
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.