Optex 中将编号框添加到“框列表”

Optex 中将编号框添加到“框列表”

我正在尝试在 Optex 中制作一个类似于 提供的“框列表” tcolorbox。我使用了手册中的两个技巧,即“圆形框架”和“X 的新列表”以及“新标题”。但似乎当我使用标题时,我必须添加\vskip 0pt当我在 内部使用它时\roundframe。有没有更好的方法来实现这一点?

\fontfam[Heros]

\ptlang

\hyperlinks \Green \Blue


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newdimen\corners  \newtoks\roundframeparams
\def\parstrut{\par\kern-\prevdepth\kern\dp\strutbox}
\def\twobox#1#2#3#4{%
   \vbox{%
      \setbox0=\vbox{\fmtfirst{#2}}%
      \hbox{\rlap{#1\vrule height\ht0 depth\dp0 width\wd0}\box0}
      \setbox0=\vbox{\fmtsecond{#4}}%
      \betweenfirstsecond \nointerlineskip
      \hbox{\rlap{#3\vrule height\ht0 depth\dp0 width\wd0}\box0}
   }%
}
\def\roundframe#1#2{{%
   \the\roundframeparams \roundness=\corners
   \setbox0=\twobox\titlecolor{#1}%<<<<
   \bodycolor{#2}%<<<<
   \setbox1=\vbox to\dimexpr\ht0-2\corners{}\wd1=\dimexpr\wd0-2\corners\relax
   \hbox{\ifx\bgoval\undefined \else \raise\corners\rlap{\bgoval}\fi
         \clipinoval .5\wd0 .5\ht0 \wd0 \ht0 {\box0}}%
}}

\def\fmtfirst  #1{\kern2pt\noindent\strut\White\bf #1\parstrut\kern1pt}
\def\fmtsecond #1{\kern3pt\noindent\strut\Black\rm #1\parstrut\kern1pt}
\def\betweenfirstsecond {\Yellow\hrule height2pt}
\roundframeparams {\hsize=6cm \leftskip=3mm \rightskip=3mm \corners=3mm
   \parindent=0pt \let\titlecolor=\Blue \let\bodycolor=\LightGrey
}
\def\bgoval{\inoval[\roundness=\corners \shadow=Y \lwidth=0pt]{\box1}}


%\url{http://petr.olsak.net/optex/optex-tricks.html\#roundframe}

%%%%%%%%%%%%%%%%% QUADROS %%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Frame titles without adding to "list" work fine:
%\newcount\quadro %\quadro=0

%\def\tituloquadro{\global\advance\quadro by 1 {\bf Quadro~\_othe\_chapnum.\_othe\_secnum.\the\quadro:}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\let\_printcaptionq = \_printcaptionf \let\_everycaptionq = \_everycaptionf
\newcount\_qnum \addto\_chapx {\_qnum=0 }
\def\_theqnum {\_othe\_chapnum.\_othe\_secnum.\_the\_qnum}
\sdef{_mt:q:en}{Box} \sdef{_mt:q:pt}{Quadro} % + your language...
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%http://petr.olsak.net/optex/optex-tricks.html#lot%%%%%%%

\_refdecl{%
\_def\lotlist{} \_def\loflist{}^^J
\_def\Xtab#1#2#3{\_addto\lotlist{\lline{#1}{#2}{#3}}\_ea\_addto\_ea\lotlist\_ea{\_currpage}}^^J
\_def\Xqua#1#2#3{\_addto\loqlist{\lline{#1}{#2}{#3}}\_ea\_addto\_ea\loqlist\_ea{\_currpage}}^^J
\_def\Xfig#1#2#3{\_addto\loflist{\lline{#1}{#2}{#3}}\_ea\_addto\_ea\loflist\_ea{\_currpage}}
}
\def\captionT [#1]#2{\caption/t[#1]\_ewref\Xtab{{#1}{\_thetnum}{#2}}\ignorespaces}
\def\captionF [#1]#2{\caption/f[#1]\_ewref\Xfig{{#1}{\_thefnum}{#2}}\ignorespaces}
\def\captionQ [#1]#2{\caption/q[#1]\_ewref\Xqua{{#1}{\_theqnum}{#2}}\ignorespaces}

\def\lline#1#2#3#4#5{\line{\hskip2em\llap{\bf \ref[#1] } #3 \_tocdotfill\ \_ilink[pg:#4]{#5}}}

\def\makell#1{\par
   \ifx\lotlist\undefined \opwarning{\noexpand#1 empty, try to run TeX again}
   \else #1\fi
}
\def\makeLOF{\makell\loflist}
\def\makeLOT{\makell\lotlist}
\def\makeLOQ{\makell\loqlist}


\nonum \notoc \sec Lista de Quadros

\makeLOQ

\nonum \notoc \sec Lista de Figuras

\makeLOF

\captionF[figura] {Uma para lista.} Uma figura.

\captionQ[quadro1] {Uma para lista de quadros} Um quadro.



\roundframe  {\captionQ[quadro2] {Outro para lista de quadros} Um quadro.\vskip 0pt}
            {Text dgd adhkd had dsglj dagjadg fsj csgsd
             gs sgls fsglfs gfsl fglf gfs rtyr rire wrurey.}


\_theqnum

O Quadro \ref[quadro2] está na página \pgref[quadro2].


\bye

在此处输入图片描述

答案1

是的,在 OpTeX 1.08 版(2022 年 8 月的最后一个 CTAN 版本)中,您必须通过空行或 来完成字幕文本\_par。您的解决方法\vskip0pt也是一样,因为 TeX在水平模式下会\_par先发出。\vskip

我已于 10 月 19 日在此解决了这个问题犯罪。现在,您无需\_par在标题文本末尾添加,这样您的问题就解决了。提到的提交不是上一个 CTAN 版本的一部分,但它将在大约两周内发布。

(题外话)为了无错误地运行您的代码,我做了以下更正:

\_def\lotlist{} \_def\loflist{}^^J

->

\_def\lotlist{} \_def\loflist{} \_def\loqlist{}^^J

\ifx\lotlist\undefined \opwarning{\noexpand#1 empty, try to run TeX again}

->

\ifx#1\undefined \opwarning{\noexpand#1 empty, try to run TeX again}

相关内容