目前宏中存在的侧边栏支持功能确实支持背景颜色。对于标题等不会分页的内容,应用背景颜色也相对容易。我们可以这样做,因为它们是页面上不需要拆分的一块文本,所以要在页面上添加背景颜色,实际上就是计算出文本块的大小,在页面上绘制一个相应大小的方块,然后将文本放在上面。
虽然 XeTeX 在字体中包含颜色的概念,但它没有背景颜色的概念,因此我们需要采用上述方法。我想,排版一个段落然后在每一行后面放置一个方框也是可能的,但这里的问题是,上伸部和下伸部可能会被后续行覆盖,或者人们会抱怨方框在页面上留下条纹。
另一个选项是编写一些巧妙的代码,对段落的起点和终点进行特殊处理,但我不太了解 PDF 代码,不知道是否可以在文件后面绘制的内容覆盖前面绘制的内容。
当然,这里说的是段落,而不是单词。一种取巧的方法可能是在每个字母后面绘制一个方框,但这可能会产生比我之前提到的行更丑陋的副作用。
要实现你在 Word 中习惯的那种背景颜色,使其可以完美地应用于字体中的所有元素,而不需要丑陋的变通方法,可能有人需要修改 XeTeX 本身(以及设备驱动程序)来实现这一点。这项更改是一周的编程工作量还是三个月,我完全不知道。
The sidebar support that exists in the macros at the moment does support a background colour. It would also be relatively easy to apply a background colour to things like headings which don’t split. We can do this because they are a chunk of text on the page that doesn’t need to be split up, so to put a background colour on the page, it literally works out how big the text block is, paints a square that shape on the page and puts the text on top.
While XeTeX includes the concept of colour in the a font, there is no concept of a background colour in it, thus we needed to take the above approach. I guess it would be possible to typeset a paragraph and then put a box behind every single line, but the problem here is that ascenders and descenders will likely get painted over by subsequent lines or people will complain about the boxes leaving stripes on the page.
Another option is to write magic bits of code that do something clever with the start and end points of a paragraph, but I don’t understand PDF-code well enough to know if it is even possible to have something later in the file painting below what’s come earlier.
That is of course talking about paragraphs, not words. A cheating method might be to draw a box behind every letter, but this would probably have some even uglier side-effects than the lines I mentioned earlier
To implement background colour like you are used to in Word, so that it can apply to everything in a font, beautifully without ugly hacks, someone would probably need to modify XeTeX itself (and device drivers) to do this. Whether that change is a week of programming effort or three months, I’ve no idea.
机器翻译自 English