5

Consider this simple document:

 \input amstex
 \input opmac

 \hyperlinks \Blue \Green

 \maketoc

 \chap Chapter

 \bye

If compiled with pdftex or luatex gives no problems; while with xetex gives as error message "! Use of \next doesn't match its definition. ...". The problem is caused by the activation of hyperlinks (I think the problem resides in the opmac-xetex.tex file which is additionally loaded when the xetex engine is detected.)

Looking at the error message I found, as a workaround, this

 \input amstex
 \catcode`\@=11
 \let\at@\relax

 \input opmac

 \hyperlinks \Blue \Green

 \maketoc

 \chap Chapter

 \bye

but this is not a good solution because I can't restore the chategory code of @ and because I think amstex needs in some way \at@. What is a good solution?

3
  • Why not loading opmac before amstex which even makes more sense, in my opinion?
    – egreg
    Nov 24, 2015 at 22:07
  • @egreg. Why does it make more sense to you to input opmac before amstex? Look at the "Intelligent \dots like in AMSTeX" trick here: petr.olsak.net/opmac-tricks-e.html. I think some reason should exists for loading amstex before opmac, if the author of opmac says: "You can do \input amstex before \input opmac".
    – User
    Nov 24, 2015 at 22:23
  • @egreg. For example \sec which stands for section in opmac is redefined as secant in amstex. But the principal reason for not loading amstex after opmac I think lays in the font system of opmac which amstex may alter, but I'm not sure
    – User
    Nov 24, 2015 at 22:34

2 Answers 2

4

The usage of OPmac with amstex.tex may bring problems. For example, you discovered that amstex.tex sets the @ as active. So, users must write:

\input amstex \catcode`\@=12
\input opmac

You cannot restore \catcode`\@=\active at beginning of your document when you plan to use the @ feature in the argument of \ii macro (insertion to index) and to sort the index (see the page 6 of OPmac manual). Better solution would be to set catcode of @ as active only locally when commutative diagram is created:

\def\diagram{\begingroup\catcode`@=\active}
\def\enddiagram{\endgroup}

Another problem can occur when math formula is included in the argument of \write (math formulas in section titles, for example). AMSTeX didn't expect that somebody needs to do something like:

\maketoc
...
\sec The function $\sin$

You can try it and look to the *.ref file. You can see something like this:

\Xtoc{1}{\rm }{1}{The function $\mathop {\fam \z@ sin}\let \next \relax \def \countxviii@=\count42{\let \countxviii@=\count42\nolimits \countxviii@=\count42}\futurelet \next \countxviii@=\count42$ }{1}

On the other hand, when original definition of \sin from plain TeX is used (without \input amstex) then you can see in the *.ref file:

\Xtoc{1}{\rm }{1}{The function $\mathop {\fam 0\tenrm sin}\nolimits $ }{1}

And this is robust and works in the TOC (for example) without problems. If you need to avoid this problem with amstex.tex then you must to \addprotect many control sequences:

\addprotect\sin \addprotect\cos ... etc.

Probably next problems occur. I am not sure because I don't know AMSTeX (I have no manual "Joy of TeX").

I strongly recommend to re-implement the features of AMSTeX and not to use the amstex.tex directly. If somebody needs to implement some interesting feature from ASMTeX, he/she can sent me email and I can write new OPmac trick in my www page. This is not problem for me.

Notice about the order of \input opmac, \input amstex. If OPmac is loaded first then AMSTeX fonts math setting are activated and only static sizes of fonts 10pt/7pt/5pt and CM are available. When you use reverting order, then \typosize and \typoscale works for math fonts too because math font setting is now done by macro file ams-math.tex.

8
  • Is it possible to \addprotect some control sequence with an @ character? If so, then I think it would be sufficient to \addprotect only \qopname@ which is common to all of \sin, \cos, ...
    – User
    Mar 11, 2016 at 19:55
  • @User yes, it is possible (if catcode of @ is 11 during \addprotect). Your idea will work.
    – wipet
    Mar 11, 2016 at 20:24
  • Before asking you I already tried \input amstex \catcode'\@=12 \input opmac \catcode'\@=11 \addprotect\qopname@ \catcode'\@=12 \maketoc \chap $\sin$ \bye but it does not work on the second tex pass. Why?
    – User
    Mar 11, 2016 at 20:32
  • The quote ' instead of the back-quote ` is only to make it format correctly. Of course, there should be also a \par after \chap $sin$
    – User
    Mar 11, 2016 at 20:40
  • 1
    Thank for interesting idea (making format with opmac macros). You can do this. The formatname.ref file does not exist during format generation so no special file is read. When you are using such format, you must write \inputref at beginning of your document, more precisely before first reference is saved (because it removes the previous version of this file). Maybe you can put \inputref to the \everyjob of such generated format. I didn't do these experiments.
    – wipet
    Mar 12, 2016 at 11:11
4

amstex makes @ active for usage in the commutative diagram macros and other utilities. You can disable this behavior when loading opmac and restore it later.

\input amstex

% save the category code of @
\chardef\savedatcatcode=\catcode`@
% restore the standard code
\catcode`@=12

\input opmac

% restore amstex category code of @
\catcode`@=\savedatcatcode

\hyperlinks \Blue \Green

\maketoc

\chap Chapter

\bye

If you want to use more sensible names for section and chapters, while saving \sec for the secant, you can do it.

\input amstex

% save the category code of @
\chardef\savedatcatcode=\catcode`@
% restore the standard code
\catcode`@=12
\let\amstexsec\sec

\input opmac

% restore amstex category code of @
\catcode`@=\savedatcatcode
\let\section\sec
\let\sec\amstexsec
\let\chapter\chap

\hyperlinks \Blue \Green

\maketoc

\chapter Chapter

\section Section

\bye
4
  • 1
    Note, that \sec and \secans is mentioned and solved in OPmac trick petr.olsak.net/opmac-tricks-e.html#sec
    – wipet
    Nov 25, 2015 at 5:03
  • 1
    @wipet Solved? Something like \sec About $\sec x$ is surely wrong.
    – egreg
    Nov 25, 2015 at 7:31
  • 1
    As usual, I don't agree with your opinion. Do you know the context dependent primitives and macros? Secondly, OPmac suggests to use \sec, \secc and \chap for sections etc. User can use another markup but this means that the markup given by OPmac isn't respected.
    – wipet
    Nov 25, 2015 at 8:19
  • 1
    @wipet Of course I know about \span, \penalty and \kern, for instance. I believe that they are like that just because of size considerations, which were important at the time TeX was written. I also believe that a command can have contextual dependent definitions but just in order to do the same (or analogous) thing in different situations (like \\ in LaTeX, but this covers \penalty and \kern). Using the same command name for very different things is wrong (and yes, I think the same about \span). Besides, aren't you always blaming LaTeX for being too rigid?
    – egreg
    Nov 25, 2015 at 8:26

You must log in to answer this question.

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