設置字體相關命令

原文地址:http://blog.csdn.net/xiazdong/article/details/8892070  接下來是無腦粘貼複製……

設置字體

\CJKfamily{song}:設置爲宋體。
\CJKfamily{hei}:設置爲黑體。
\CJKfamily{kai}:設置爲楷體。

\CJKfamily 命令,他不帶有任何參數,他對其後的整個文本起作用,如果想限制作用範圍,可以用分組,如這是 {\CJKfamily{song}宋體} 字。
爲了使用方便,我們一般會在“導言區”定義下面的命令。

\newcommand{\song}{\CJKfamily{song}}    % 宋體
\newcommand{\fs}{\CJKfamily{fs}}             % 仿宋體
\newcommand{\kai}{\CJKfamily{kai}}          % 楷體
\newcommand{\hei}{\CJKfamily{hei}}         % 黑體
\newcommand{\li}{\CJKfamily{li}}               % 隸書


設置字體大小

需要加入:\usepackage{type1cm}  (其中的 cm 爲 Computer Modern 的縮寫)

\fontsize{字號}{行距}
這個命令對其後所有文本都起作用,在使用此命令後需要用 \selectfont 才能使字體大小設置起作用。

我們通常會遇到別人規定:“正文用小四,宋體”,但是 LaTeX 並沒有小四,只有 pt,因此下表爲字號對應的轉換表:

字號 初號 小初 一號 小一 二號 小二 三號 小三 四號 小四 五號 小五 六號 小六 七號 小七
大小 42pt 36pt 26pt 24pt 22pt 18pt 16pt 15pt 14pt 12pt 10.5pt 9pt 7.5pt 6.5pt 5.5pt 5pt
1.5行距時的 \baselineskip 設置值 63pt 54pt 39pt 36pt 33pt 27pt 24pt 22.5pt 21pt 18pt 15.75pt 13.5 11.25 9.75pt 8.25pt 7.5pt

比如:\fontsize{12pt}{18pt}\selectfont 就設置了 小四,且 1.5 倍行距。

錯誤:
Latex font warning: font shape `OT1/cmr/m/n' in size <15> not available

LaTeX font warning: size s stitutions with differences
       up to 0.6 pt have occurred

解決方案:\usepackage{type1cm}

通常我們會根據具體要求在源文件的導言區加入下面的語句,以方便設置字號:

\newcommand{\yihao}{\fontsize{26pt}{36pt}\selectfont}           % 一號, 1.4 倍行距
\newcommand{\erhao}{\fontsize{22pt}{28pt}\selectfont}          % 二號, 1.25倍行距
\newcommand{\xiaoer}{\fontsize{18pt}{18pt}\selectfont}          % 小二, 單倍行距
\newcommand{\sanhao}{\fontsize{16pt}{24pt}\selectfont}        % 三號, 1.5倍行距
\newcommand{\xiaosan}{\fontsize{15pt}{22pt}\selectfont}        % 小三, 1.5倍行距
\newcommand{\sihao}{\fontsize{14pt}{21pt}\selectfont}            % 四號, 1.5 倍行距
\newcommand{\banxiaosi}{\fontsize{13pt}{19.5pt}\selectfont}    % 半小四, 1.5倍行距
\newcommand{\xiaosi}{\fontsize{12pt}{18pt}\selectfont}            % 小四, 1.5倍行距
\newcommand{\dawuhao}{\fontsize{11pt}{11pt}\selectfont}       % 大五號, 單倍行距
\newcommand{\wuhao}{\fontsize{10.5pt}{15.75pt}\selectfont}    % 五號, 單倍行距


\song\xiaosi 可以快速設置爲“宋體,小四,1.5 倍行距”。


設置粗體、斜體

\textbf{文本}:粗體命令。
\textbf 是一個命令,且帶有一個參數,目的是將參數中的文本變爲粗體,他的命令定義爲:\newcommand{\textbf}[1]{內容},此處的 [1] 爲命令有一個參數,{內容}爲命令定義。
\textit{文本}:斜體命令。


附錄

如果你想要設置一些擴展字體,則下面列出了需要的宏包,比如“Times New Roman”字體,在論文中經常用,我們可以使用:\usepackage{times} 使得 英文默認字體都是 Times New Roman。


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章