![如何将仿生阅读风格运用到整个文档中?](https://linux22.com/image/451064/%E5%A6%82%E4%BD%95%E5%B0%86%E4%BB%BF%E7%94%9F%E9%98%85%E8%AF%BB%E9%A3%8E%E6%A0%BC%E8%BF%90%E7%94%A8%E5%88%B0%E6%95%B4%E4%B8%AA%E6%96%87%E6%A1%A3%E4%B8%AD%EF%BC%9F.png)
答案1
应该实施,但有限制:
- 的内容
\bionic...\endbionic
必须是纯文本,不能使用任何宏。只能是空行分隔的段落文本。我实现了一个例外(作为示例):$...$
可以使用内联数学模式,但必须在其前面留有空格。 - 连字功能无法起作用。
可以\bionic...\endbionic
封装几个段落,或者(另一方面)可以在段落内部使用以便仅修改段落的一部分。
仿生百分比参数可以通过设置\setbionic{num}
,默认为\setbionic{50}
。
\newcount\tmpnum
\def\setbionic#1{\def\wratio{#1}}
\setbionic{50}
\long\def\bionic #1\endbionic{%
\begingroup
\let\bionicfin=\par
\everypar{\bionicS\bionicA}%
\ifhmode \def\bionicfin{}\bionicS \expandafter \bionicA\fi
#1 \bionicfin
\endgroup
}
\long\def\bionicA #1{%
\let\next=\bionicC
\ifx#1\par \let\next=\relax \fi
\ifx#1\bionicfin \let\next=\relax \fi
\ifx#1$\let\next=\bionicM \fi %$
\next #1%
}
\def\bionicC #1 {\ifx\par#1\else
\spacebetweenwords
\tmpnum=0 \lcount #1{}% saves the number of letters to \tmpnum
\multiply\tmpnum by\wratio \divide\tmpnum by100
\testIm #1''\end % says \tmpnum=0 if #1 includes ' inside the word
\bgroup \bf \wordpart #1%
\expandafter\bionicA \fi
}
\def\bionicM $#1${ $#1$\bionicS\futurelet\next\bionicN}
\def\bionicN{\expandafter\ifx\space\next
\afterfi{ \afterassignment\bionicA\let\next= }\else \afterfi\bionicA\fi
}
\def\bionicS{\def\spacebetweenwords{\def\spacebetweenwords{ }}}
\def\lcount #1{\ifx^#1^\else \advance\tmpnum by1 \expandafter\lcount\fi}
\def\wordpart #1{%
\ifnum\tmpnum=0 \egroup#1%
\else #1\advance\tmpnum by-1 \expandafter \wordpart \fi}
\def\testIm #1'#2'#3\end{\ifx^#2^\else \tmpnum=0 \fi}
\def\afterfi#1#2\fi{\fi#1}
Text \bionic inside the paragraph.\endbionic{} Next verse.
\bionic
Confucius said: Madam, I'm Adam.
Next paragraph $a + b = c$ uff.
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula augue eu neque. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Mauris ut leo. Cras viverra metus rhoncus sem. Nulla et lectus vestibulum urna fringilla ultrices. Phasellus eu tellus sit amet tortor gravida placerat. Integer sapien est, iaculis in, pretium quis, viverra ac, nunc. Praesent eget sem vel leo ultrices bibendum. Aenean faucibus. Morbi dolor nulla, malesuada eu, pulvinar at, mollis ac, nulla. Curabitur auctor semper nulla. Donec varius orci eget risus. Duis nibh mi, congue eu, accumsan eleifend, sagittis quis, diam. Duis eget orci sit amet orci dignissim rutrum.
Nam dui ligula, fringilla a, euismod sodales, sollicitudin vel, wisi. Morbi auctor lorem non justo. Nam lacus libero, pretium at, lobortis vitae, ultricies et, tellus. Donec aliquet, tortor sed accumsan bibendum, erat ligula aliquet magna, vitae ornare odio metus a mi. Morbi ac orci et nisl hendrerit mollis. Suspendisse ut massa. Cras nec ante. Pellentesque a nulla. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aliquam tincidunt urna. Nulla ullamcorper vestibulum turpis. Pellentesque cursus luctus mauris.
Nulla malesuada porttitor diam. Donec felis erat, congue non, volutpat at, tincidunt tristique, libero. Vivamus viverra fermentum felis. Donec nonummy pellentesque ante. Phasellus adipiscing semper elit. Proin fermentum massa ac quam. Sed diam turpis, molestie vitae, placerat a, molestie nec, leo. Maecenas lacinia. Nam ipsum ligula, eleifend at, accumsan nec, suscipit a, ipsum. Morbi blandit ligula feugiat magna. Nunc eleifend consequat lorem. Sed lacinia nulla vitae enim. Pellentesque tincidunt purus vel magna. Integer non enim. Praesent euismod nunc eu purus. Donec bibendum quam in tellus. Nullam cursus pulvinar lectus. Donec et mi. Nam vulputate metus eu enim. Vestibulum pellentesque felis eu massa.
Quisque ullamcorper placerat ipsum. Cras nibh. Morbi vel justo vitae lacus tincidunt ultrices. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. In hac habitasse platea dictumst. Integer tempus convallis augue. Etiam facilisis. Nunc elementum fermentum wisi. Aenean placerat. Ut imperdiet, enim sed gravida sollicitudin, felis odio placerat quam, ac pulvinar elit purus eget enim. Nunc vitae tortor. Proin tempus nibh sit amet nisl. Vivamus quis tortor vitae risus porta vehicula.
\endbionic
\bye
您可以通过 Plain TeX 尝试此示例,即pdftex document
。