
我正在使用 sphinx 生成多種文件格式。由於這是一個 TeX/LaTeX 特定論壇,並且主要輸出之一是 .pdf,我認為在這裡詢問很有用。
是否可以要求乳膠以多種字體輸出特定單詞,並在每次出現在文件中時顯示顏色。無論該詞出現在標題或正文中,都應該這樣寫。
進一步來說:
- 這個字是:「AccuROAM」拼成一個單字,沒有空格,如圖所示,
- 「Accu」是世紀哥德字體,黑色RGB(0,0,0),正常粗細,
- 「ROAM」採用Calibri字體,紅色RGB(165,0,33),正常粗細,
- 即使在粗體文字環境中,粗細也應保持不變。
- 大小應與周圍文字相同
圖片說明:
非常感謝任何幫助,
答案1
這是基於德古德曼的回答但使用 XeLaTeX 來選擇系統字體。我沒有世紀哥德式,所以我用 的fontconfig
選擇代替了。我也使用過\newcommand*
而不是\def
因為這是一個 LaTeX 文件。此範例表示名稱的權重保持不變。將字體縮放到周圍文字大小的功能fontspec
用於適當縮放兩種字體。
\documentclass{article}
\usepackage{color}
\definecolor{myred}{RGB}{165,0,33}
\usepackage{fontspec}
\newfontface\calibrifam[Scale=MatchUppercase]{Calibri}
\newfontface\cgothicfam[Scale=MatchUppercase]{TeX Gyre Adventor}% I don't have Century Gothic
\newcommand*\accuroam{%
{\cgothicfam Accu}%
{\calibrifam\textcolor{myred}{ROAM}}%
}%
\begin{document}
\Huge
Now is the time for all good men to come to the aid of
\accuroam.
\normalsize\bfseries
Now is the time for all good men to come to the aid of
\accuroam.
\normalfont\tiny
Now is the time for all good men to come to the aid of
\accuroam.
\end{document}
答案2
TeX 是一種巨集語言,所以是的,這絕對是可能的,甚至很容易。我目前沒有可用的特定字體,但這裡有一個使用 Computer Modern Sans 和 Computer Modern Serif 的粗略示例,只是為了展示使用兩種單獨的字體是多麼簡單。我以通用方式選擇了這些字體,以展示您如何選擇您的字體,假設它們已安裝並準備在您的系統上使用。如果您使用 LuaTeX 和 fontspec,字型選擇將會有所不同。
\documentclass{article}
\usepackage{color}
\definecolor{myred}{RGB}{165,0,33}
\def\accuroam{%
\usefont{OT1}{cmss}{m}{n}Accu%
\usefont{OT1}{cmr}{m}{n}\textcolor{myred}{ROAM}%
}%
\begin{document}
\Huge
Now is the time for all good men to come to the aid of
\accuroam.
\normalsize
Now is the time for all good men to come to the aid of
\accuroam.
\tiny
Now is the time for all good men to come to the aid of
\accuroam.
\end{document}
這顯示了巨集在三種不同尺寸下工作,我myred
根據您的紅色規格定義了一種顏色。可以輕鬆添加首都大小和類似性質的調整。