
我想創建一個如下所示的標題:
_________________________________________________________________________________
| | | Sufix |
| Prefix unwrapped (CAPS) | Unwrapped title (Small Caps) | wraped |
| | | as needed |
=================================================================================
Ba ba Ba ba
• Sub text 1 • Sub text 2 • Sub text 3 • Sub text 4 •
Ba Black Sheep
它需要是:
- 拉伸到整個頁面
- 帶顏色底線 (=)
- 上、左、右、中無幹擾(|、_)
- 由分隔符號 (•) 分隔的子文字居中或頂部對齊,並進行調整以實現最佳匹配。
到目前為止我所做的是(標題/標題的第一部分):
\define[3]\TITLE{\midaligned{\framed[frame=off,align=middle,bottomframe=on,framecolor=blue]
{\inframed[frame=off]{{\tfa\WORD#1}: {\tfb\sc#2}}\inframed[frame=off]{{\tfa, #3}}}}}
但這並沒有產生預期的結果。
我該怎麼做?
答案1
我不完全理解規格,所以讓我嘗試迭代地回答這個問題。
- 我假設 的寬度
Prefix + Title < \textwdith
。如果不是,那麼這兩個之一也必須換行。 - 目前尚不清楚如何
Prefix
以及Title
應該垂直對齊。我選擇了中間對齊(lohi
在ConTeXt中稱為)
從概念上講,最簡單的方法是使用表。所以,基本的宏是:
\define[3]\TITLE
{\startTABLE[setups=table:title]
\NC #1 \NC #2 \NC #3 \NC \NR
\stopTABLE}
現在,我們需要做的就是定義設定table:title
以獲得正確的格式,可以按如下方式完成:
\startsetups table:title
\setupTABLE[each][each][frame=off,bottomframe=on,rulethickness=2bp]
\setupTABLE[column][1][style=WORD, align=lohi]
\setupTABLE[column][2][style=\sc, align=lohi]
\setupTABLE[column][3][align={hyphenated,tolerant}]
\stopsetups
就是這樣!
這是帶有輸出的完整程式碼:
\startsetups table:title
\setupTABLE[each][each][frame=off,bottomframe=on,rulethickness=2bp]
\setupTABLE[column][1][style=WORD, align=lohi]
\setupTABLE[column][2][style=\sc, align=lohi]
\setupTABLE[column][3][align={hyphenated,tolerant}]
\stopsetups
\define[3]\TITLE
{\startTABLE[setups=table:title]
\NC #1 \NC #2 \NC #3 \NC \NR
\stopTABLE}
\showframe % To visualize the page frame
\starttext
\TITLE{prefix}{Unwrapped title}{\dorecurse{5}{A very long text\space}}
\stoptext
這使
頂框和側框只是為了\showframe
顯示表格延伸到頁面邊界的邊緣。