olsak / OpTeX

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

Interaction of verbatim and lists #141

Closed vlasakm closed 1 year ago

vlasakm commented 1 year ago

Consider what happens when \begtt is nested under \begitems and we color the verbatim text and increase the indentation to highlight the issue:

\fontfam[lm]

\_def\liBlue{\_setcmykcolor{.2 .08 0 0}}
\_def\_printverbline#1{\penalty \_ttpenalty \noindent 
   \rlap{\vbox to0pt{\vss\liBlue 
         \hrule width\hsize height10pt depth4pt \kern-4pt}}%
   \_printverblinenum \hskip 1em #1 \par
}

\iindent=20mm

\begtt
a
\endtt

\begitems
*
\begtt
b
\endtt

\begitems
*
\begtt
c
\endtt
\enditems

\enditems

\bye

The colored verbatim blocks go off the side.

To be honest I am not sure what is the right typograhical handling of this, and I guess that maybe use of such constructs is even discouraged.

Nonetheless I needed it, and in the end settled on adding this to my document:

\toksapp\everylist{\toksapp\everytt{\hsize=\dimexpr\hsize-\iindent\relax}}

Though a proper handling would be needed. I admit I am not even sure how \hsize really interacts with (colored) verbatim and lists.

olsak commented 1 year ago

Better solution is to use

    \hrule width\dimexpr\hsize-\leftskip height10pt depth4pt \kern-4pt}}%

in the \_printverbline macro. I corrected CTUstyle in this sense, see https://github.com/olsak/CTUstyle3/commit/ac693ca7c367357ec9557f2e9a237422303951d8.

Thank you for noticing.

vlasakm commented 1 year ago

Thanks, much better!