olsak / OpTeX

OpTeX - LuaTeX format with extended Plain TeX macros
http://petr.olsak.net/optex/
35 stars 13 forks source link

Inline verbatim in tables #66

Closed vlasakm closed 3 years ago

vlasakm commented 3 years ago

The commit cde08d91f98cfdd637c35ecbec661d2cb1c57e8c broke the following example:

\fontfam[lm]

\verbchar`

\table{p{20pt\fL}}{
`\0`
}

\bye

The problem is "fixed" by bringing the old defintion of \_tabdeclarep:

\_def\_paramtabdeclarep#1{\_the\_tabiteml
   \_vtop{\_hsize=#1\_relax \_baselineskip=\_normalbaselineskip
   \_lineskiplimit=\_zo \_noindent \_hskip\_zo \_relax ##\_unsskip
   \_ifvmode\_vskip\_dp\_tstrutbox \_else\_lower\_dp\_tstrutbox\_hbox{}\_fi}\_the\_tabitemr}

Is there any possibility to make inline verbatim work again? I am lost.

olsak commented 3 years ago

The problem is that the table item (used in \halign primitive) is preprocessed: it is expanded until first non-expandable token and then it is read again in its expanded form after the left template of the table column is processed. See TeXbook page 240 or TeXbook naruby, page 136. The workaround is to insert \relax at the beginning of the table item by a user. But we want to be more conceptual. There is two ways. First way: to create all macros (which can be used at beginning of the table item) more robust. I started this and I created more robust \fornum in my lats commit. We can do

\_adef{#1}{\_begingroup \_inlineverb}

in \verbchar macro and define

\_def\_inlineverb{\_setverb \_adef{ }{\_dsp}\_ttfont \_the\_everyintt\_relax \_readverb}

to make inline verbatim more robust in the context of the problem of table items mentioned above. And we must to do something similar with \lipsum macro too. Second way is to define \_paramtabdeclarep differently. But this macro solves more issues and it will be much more complicated. I tried it in my computer but I am not satisfied with it. I have to think about it more. It will take me more time.

olsak commented 3 years ago

I hope that the last commit solves it.

vlasakm commented 3 years ago

I confirm that my use case works now. Thank you very much!

Though I will still study your applied changes and reasoning above.