目前宏中存在的側欄支援功能確實支援背景顏色。對於標題等不會分欄的內容,套用背景顏色也相對容易。我們之所以能做到這一點,是因為它們是頁面上不需要拆分的一塊文本,因此要在頁面上放置背景顏色,它實際上會計算出文本塊的大小,在頁面上繪製一個該形狀的方塊,然後將文本放在上面。
雖然 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