8
\documentclass{article}
\usepackage{pst-barcode}

\begin{document}
\begin{pspicture}
  \psbarcode{\input{\jobname.tex}}{}{qrcode}
\end{pspicture}
\end{document}

I tried placing \expandafters before and after \psbarcode, but no juice. It can handle control sequences just fine, but it will expand them. How can I get it to not expand its argument at all (save, of course, \input) and take it verbatim?

The encoding of this particular document is

enter image description here

3
  • 1
    This can’t really work because \input already makes a test for { to decide between the TeX version \input \jobname.tex and the LaTeX version \input{\jobname.tex}. Those then test whether the file exist at all and do all things that are not expandable. (Have you tried scanning the codes you get.) The TeX version of \input (in LaTeX \@@input) is even a primitive I believe. Oct 25 '13 at 22:48
  • @Qrrbrbirlbel TeX's \input is a primitive, but doesn't it 'sort-of'-'I would never say this to egreg' expand (in the true macro sense) to the file contents? Oct 25 '13 at 23:03
  • I guess, yes and no. It does insert it in the input stream but then it would just continue to expand it when it is written on the PS/Barcode code. You need to \detokenize it before. But for some reason, it cannot find the file. I guess the catchfile will be helpful. Oct 25 '13 at 23:09
10

A start: Using the catchfile package to write the content of the file into a macro that will then get expanded once and detokenized for \psbarcode.

For some reason my scanner doesn’t show any \s, \bs or \ts. I don’t know whether this is a matter of \psbarcode or of my scanner that interprets them as some kind of escape sequences (German list). However, the sequence \string\\ shows up correctly as \.

Also, an empty line shows up as \par (or rather par).

Code

\documentclass{article}
\usepackage{pst-barcode,catchfile}
\CatchFileDef\myFile{\jobname.tex}{}
\makeatletter\let\TeXinput\@@input\makeatother
\begin{document}
\ttfamily
\meaning\myFile

\begin{pspicture}
  \expandafter\psbarcode\expandafter{\detokenize\expandafter{\myFile}\string\\}{}{qrcode}
  % fails with "I can't find file" error
%  \expandafter\psbarcode\expandafter
%    {\detokenize\expandafter{\TeXinput\jobname.tex}}{}{qrcode}
\end{pspicture}
\end{document}

Output

enter image description here

8

That will make no real sense! PostScript and TeX have different special characters. For example: a single ) without a correscponding ( in your TeX code will break the PostScript code. ) is the closing character for a PostScript string; it has to be escaped by \). But that has another meaning in TeX. Same for other characters.

You need a pre-processor which escapes the ) character in the TeX file. However, if you do not have a single ) in your TeX source you can use the optional argument file (needs latest TL2013):

\documentclass{article}
\usepackage{pst-barcode,fancyvrb}
\begin{document}
\VerbatimInput{\jobname.tex}% test 

\begin{pspicture}(2in,2in)
  \psbarcode[file]{\jobname.tex}{}{qrcode}
\end{pspicture}

\end{document}

enter image description here

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.