2

Here is a file that uses the pst-barcode package to generate a barcode. Namely, there is a need for files with ISBN numbers to be located in a separate folder and individual files. The question is how to define the path to the file (for example, ISBN_2.txt) with the ISBN number in the \psbarcode command.


\usepackage{lipsum}
\usepackage{pst-barcode}

%path to ISBN files
\def\ISBNPath{./input/ISBN_List}

\def\FileNumber{2}

\pagestyle{empty}

\begin{document}

\lipsum[1]

\begin{pspicture}(0,0)(0,0)
\psbarcode{\input{\ISBNPath/ISBN_\FileNumber.txt}}{width=1.5 height=0.8}{isbn}
\end{pspicture}


\end{document}

If it is written as in the attached example, an error occurs when compiling the Latex file.

I'm sure someone knows the answer and the solution. Please help and for one example. Thanks in advance.

0

1 Answer 1

1

The following assumes you have a bunch of files ISBN_#.txt where # is some number and ISBN_#.txt contains a single ISBN that you want to print.

You have 3 options:

  1. Ignore the files and enter the ISBN verbatim.

  2. Use the file option with \psbarcode to identify that you're working with a file, not a verbatim barcode.

  3. Capture the contents of ISBN_#.txt using catchfile's \CatchFileDef{<cmd>}{<file>}{}, and the print the barcode using \psbarcode{<cmd>}{<opts>}{}.

enter image description here

\documentclass{article}

\usepackage{pst-barcode}
\usepackage{catchfile}

\def\FileNumber{2}

\begin{document}

\begin{pspicture}(0,0)
  % 1. Input ISBN barcode verbatim
  %\psbarcode{978-3-16-148410-0}{width=1.5 height=0.8}{isbn}
  
  % 2. Input ISBN barcode from file
  \psbarcode[file]{ISBN_\FileNumber.txt}{width=1.5 height=0.8}{isbn}

  % 3. Capture ISBN barcode from file before printing
  %\CatchFileDef{\barcode}{ISBN_\FileNumber.txt}{}%
  %\psbarcode{\barcode}{width=1.5 height=0.8}{isbn}
\end{pspicture}

\end{document}

Note that the files ISBN_#.txt should contain the ISBN only, no line feeds.

1
  • Thank you for your response. Everything you wrote was very helpful to me. You solved my problem. Thank you very much. Nov 3, 2021 at 17:33

You must log in to answer this question.

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