4

I have been trying to include tikz in a document that already has program included. I have read somewhere that tikz should be included before program, because program kind of uses a version of tikz. So putting it after doesn't work, it's true (you get a Missing \endcsname inserted error), but before doesn't either for me.

I get errors like Bad character code (280) in program.sty, Tab overflow on \BEGIN line 11, and multiple others. The compilation log can be found here, with the errors starting at line 697.

My question is similar to this one except that I don't use etex at all, and the bug described seems to be with etex.

Here is a minimal failing example. If I comment \usepackage{tikz}, it compiles fine. The program itself was found here, so I assume it is correctly typed.

\documentclass[review]{article}
\usepackage[utf8]{inputenc}

\usepackage{tikz}
\usepackage{program}

\begin{document}

\begin{program}
    \mbox{A fast exponentiation procedure:}
    \BEGIN \\ %
    \FOR i:=1 \TO 10 \STEP 1 \DO
    |expt|(2,i); \\ |newline|() \OD %
    \rcomment{This text will be set flush to the right margin}
    \WHERE
    \PROC |expt|(x,n) \BODY
    z:=1;
    \DO \IF n=0 \THEN \EXIT \FI;
    \DO \IF |odd|(n) \THEN \EXIT \FI;
    \COMMENT{This is a comment statement};
    n:=n/2; x:=x*x \OD;
    \{ n>0 \};
    n:=n-1; z:=z*x \OD;
    |print|(z) \ENDPROC
    \END
\end{program}

\end{document}

Any idea why ?

  • It is the same issue as the previous question except that prior to the 2015 latex release you needed the etex package to access the extended registers from latex but it isn't needed in current releases. – David Carlisle May 5 '17 at 9:30
  • I have mailed the author of program.sty referencing this question. – David Carlisle May 5 '17 at 9:55
  • A new version has been uploaded to ctan but may take some days to reach ctan mirrors. – David Carlisle May 5 '17 at 15:27
4

program package needs updating, you could try to contact the author but for now you can make it work by

\documentclass[review]{article}
\usepackage[utf8]{inputenc}

\usepackage{tikz}

\let\oldchardef\chardef
\let\chardef\mathchardef
\usepackage{program}
\let\chardef\oldchardef

\begin{document}

\begin{program}
    \mbox{A fast exponentiation procedure:}
    \BEGIN \\ %
    \FOR i:=1 \TO 10 \STEP 1 \DO
    |expt|(2,i); \\ |newline|() \OD %
    \rcomment{This text will be set flush to the right margin}
    \WHERE
    \PROC |expt|(x,n) \BODY
    z:=1;
    \DO \IF n=0 \THEN \EXIT \FI;
    \DO \IF |odd|(n) \THEN \EXIT \FI;
    \COMMENT{This is a comment statement};
    n:=n/2; x:=x*x \OD;
    \{ n>0 \};
    n:=n-1; z:=z*x \OD;
    |print|(z) \ENDPROC
    \END
\end{program}

\end{document}

The issue is that under etex so since 1993 or so) (e)tex can have more than 256 dimen registers, so you can not store the number as a character code (which is at most 255 in etex)

2

I am the author of progam.sty

I have just uploaded a new version to CTAN which should fix this problem.

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.