• 沒有找到結果。

調整字族、字型系列、字形的指令

在文檔中 大家來學 (頁 41-44)

4.7 字型的相關調整

4.7.2 調整字族、字型系列、字形的指令

字型 標準指令 宣告式指令(環境) 舊用法

字 textup \textup{textup} {\upshape textup}

italic \textit{italic} {\itshape italic} {\it italic}

slant \textsl{slant} {\slshape slant} {\sl slant}

small caps \textsc{small caps} {\slshape small caps} {\sc small caps}

系 medium \textmd{medium} {\mdseries medium}

列 boldface \textbf{boldface} {\bfseries boldface} {\bf boldface}

字 roman \textrm{roman} {\rmfamily roman} {\rm roman}

族 sans serif \textsf{sans serif} {\sffamily sans serif} {\sf sans serif}

typewriter \texttt{typewriter} {\ttfamily typewriter} {\tt typewriter}

先別嚇了一跳,這是有跡可循的。其中 upright, medium, roman 都是一樣的,這是一般的 正常字,就不必麻煩去設定他了,除非是要在特定字型範圍裡頭,重新改變成正常字體。

從前面所說的簡稱的字串,再和 text, family, series, shape 去配對來使用,這樣只要記得 簡稱就行了,例如:italic 的就是 \textit{}。不然也可以使用「偷吃步」的舊用法,其 實這也不是什麼偷吃步,他是原始 Plain TEX 所定義的,在舊版的 LATEX 2.09 也相容他而 沿用,並加以擴充。但如果使用舊用法,那有時組合式的表示時可能會無效,例如粗斜體 這種粗體和斜體設定混合時,就無法產生粗斜體了,這時還是得乖乖使用正統標準 LATEX 的表示法。

要注意的是,大括號的位置,宣告式的指令,整個作用範圍是連指令一起包住的,他可以 當成環境來使用,例如 \begin{itsahpe}, \end{itshape},這樣在這個環境內的文字就 通通會使用 italic 斜體,也可以不加參數使用,例如 \itshape,這樣以下的文字通通會使

4 章 實際上排版玩看看 4.7. 字型的相關調整

用 italic 斜體,直至另一個改變字型的指令出現為止。標準指令的作用範圍則是當做指令 的一個參數,這些參數是出現在指令後的大括號內的。現在就來實際編譯個例子試看看:

% example8.tex

\documentclass{report}

\title{\bfseries Aesop Fables}

\author{Aesop\thanks{Thanks to the reader.}

\and Nobody\thanks{Thanks to nobody}}

\date{\today}

\begin{document}

\maketitle

\tableofcontents

\chapter{Aesop Fables}

\section{The \textsl{Ant} and the \textsl{Dove}}

\itshape

An antwent to the bank of a river to quench its thirst, and being carried away by the rush of the stream, was on the point of drowning.

\upshape

A \textsl{Dove} sitting on a tree overhanging the water plucked a

leaf and let it fall into the stream close to her. The \textbf{\textsl{Ant}}

climbed onto it and floated in safety to the bank.

\section{The {\it Dog}\/ in the Manger}

A \textbf{\textit{dog}} lay in a manger, and by his growling and snapping prevented the oxen from eating the hay which had been

placed for them.

‘‘What a selfish Dog!’’ said one of them to his companions;

‘‘he cannot eat the hay himself, and yet refuses to allow those to eat who can.’’

\chapter{The \textsc{Eagle} and the Arrow}

An \textsc{eagle} sat on a lofty rock, watching the movements of a Hare whom he sought to make his prey.

An archer, who saw the \textsc{Eagle} from a place of concealment, took an accurate aim and wounded him mortally.

\end{document}

我們把 title page 的標題改成粗體(請注意,宣告式或舊用法,大括號是把指令和文字整 個括住的),把 Dove 改成 slant 斜體,把 dog 改成 italic 粗斜體2,把 ant 改成 slant 粗

2請注意,這兩種斜體是不一樣的,slant 是一般正常的字,只是把他傾斜個角度而已,但 italic 則是另一

4 章 實際上排版玩看看 4.7. 字型的相關調整

斜體,把 eagle 改成 small caps。由於章節標題原本就會轉換成粗體,所以章節標題的部 份,粗體就不必重複設了。

但這裡發現例子裡第二章標題中的 Eagle 並沒有改變字體,而且以 latex 編譯時會產生以 下的錯誤(這些訊息也會在 example8.log 中找到):

...

LaTeX Font Warning: Font shape ‘OT1/cmr/bx/sc’ undefined

(Font) using ‘OT1/cmr/bx/n’ instead on input line 4.

...

LaTeX Font Warning: Some font shapes were not available, defaults substituted.

...

現在我們看到了前面所談的屬性簡稱,這在 LATEX 就會使用這種屬性來表示而發出訊 息,這裡 OT1/cmr/bx/sc 就表示了 OT1 編碼,Computer Modern Roman 字族,Bold extended 系列,而且是 small caps 形狀的字型,錯誤訊息顯示,他並沒有定義,因此,

這個字型將會使用預設的字型來代替,這裡就是以 n 正常形狀的 bx 系列字型來替代。所 以,字型指令並不是都可以隨意組合的,有些是根本就沒有這種字型,有些則是沒有用巨 集去定義好,這樣 LATEX 就取不到字了,但別擔心,頂多就是使用預設的字型罷了!

另一個很奇怪的地方,就是第一章、第二節的標題,為什麼是{\it Dog}\/ in the...}?

這個插入的 \/ 是什麼東西?這是 TEX 系統調整斜體字(包括 iatlic 及 slanted)和正常字 之間的空白的一個指令,稱為 italic correction。這樣,在斜體字和正常字之間的空白才會 正常。那為什麼其他的斜體指令沒有加這個調整呢?這是因為 LATEX 巨集在設計時就有考 慮到這個問題,所以 \textit{} 這類標準指令都會自動調整 italic correction,不必由我 們手動調整。

另外,章節標題本就會自動轉換成粗體,標題上的 dog 為什麼沒有變粗體?這在前面有提 到過,這種舊用法有時是無法複合使用的,粗體又斜體的指令會用不上來。因此,建議盡 量使用 LATEX 的第一種標準指令來改變字型。使用 {\it ...} 或 {\itshape ...}3 這種 指令的話,就得時時注意 italic correction 的問題,也得注意是否可以複合使用指令的問 題,所以,還是不要偷懶的好。:-)

後下是排版出來的結果:

http://edt1023.sayya.org/tex/latex123/example8.tex http://edt1023.sayya.org/tex/latex123/example8.pdf 種獨特的字型設計。

3宣告式指令可以複合使用,但仍然會需要手動做italic correction。

4 章 實際上排版玩看看 4.7. 字型的相關調整

在文檔中 大家來學 (頁 41-44)