目錄
系列文章目錄
前言
一、排版中文
二、Latex的字元
三、強調、斷行等
總結
提示:寫完文章後,目錄可以自動生成,如何生成可參考右邊的幫助文檔
系列文章目錄
一、Latex安裝
二、Latex簡介
前言
文字是排版的基礎,在本篇文章将繼續介紹Latex的使用
提示:以下是本篇文章正文内容,下面案例可供參考
一、排版中文
隻說最簡單的一個方式即:使用ctex宏包。
ctex 宏包和文檔類是對 CJK 和 xeCJK 等宏包的進一步封裝。 ctex 文檔類包括 ctexart /
ctexrep / ctexbook,是對 LATEX 的三個标準文檔類的封裝,對 LATEX 的排版樣式做了許多調整,以切合中文排版風格。最新版本的 ctex 宏包/文檔類甚至能夠根據作業系統自動配置字型。比如:
\documentclass{ctexart}
\begin{document}
你好\LaTeX{}排版
\end{document}
Latex排版文字系列文章目錄前言一、排版中文二、Latex的字元三、強調、斷行等總結

二、Latex的字元
1.空格和分段
空格:在Latex源代碼中為空格鍵和Tab鍵輸入的空白字元為“空格”,行末的回車視為一個空格,連續的若幹個空白字元視為一個空格。其中開頭的空格忽略不計。
分段:連續的兩個回車,多個空行視為一個空行。行末使用\par指令也是空行即分段。
\documentclass{ctexart}
\begin{document}
多個空格隻顯示 一個 空格
行末
的回車等于一個空格
兩個回車就是新的一行\par
在行末使用\verb|\par|指令也可以開始新的一行
\end{document}
2.注釋
Latex使用%字元作為注釋,%字元之後直至行末都被忽略。
\documentclass{ctexart}
\begin{document}
% 注釋在Latex
% 源碼中不參與編譯
\verb|%|字元後面直至行末的都不會%
顯示,但是不會作用的下一行的文字,即使沒有使用換行指令
\end{document}
3、特殊字元
在C語言或者其他程式設計語言對與特殊字元都會使用轉義字元來代替,在Latex中也是同樣如此。
比如 # $ % & { }等
\documentclass{ctexart}
\begin{document}
\# \$ \% \& \{ \} \_
% \^ \~ 這兩個指令需要帶參數,如果不加一對花括号{}(空參數),就将
% 後面的字元作為參數,形成重音的效果
% 反斜杠也不可使用\\,因為\\被直接定義成手動換行的指令,所有隻好使用\textbackslash
\^{} \~{} \textbackslash
\end{document}
4、連字
在英文排版中經常出現字母之間的連字現象,常見的有ff、fi、fl、ffi、ffl
\documentclass{ctexart}
\begin{document}
It's difficult to find \ldots .
It's dif{}f{}icult to f{}ind \ldots .
\end{document}
結果應該很明顯的呈現出來了
5、标點符号
中文的标點符号使用中文輸入法即可。在英文中
5.1、引号
Latex的單引号‘’使用`'輸入;雙引号“”使用``和''輸入
\documentclass{ctexart}
\begin{document}
``Please press the `x' key.''
\end{document}
5.2 連字号和破折号
Latex中存在3種長度的橫線可用:連字号、短破折号、長破折号
\documentclass{ctexart}
\begin{document}
連字号: - \par
短破折号: -- \par
長破折号: ---
\end{document}
5.3 省略号
Latex中的省略号使用指令\ldots生成 \ldots和\dots是兩個等效指令
6、特殊符号與重音
7、特殊符号
\documentclass{ctexart}
\begin{document}
\P{} \S{} \dag{} \ddag{}\par
\copyright{} \pounds{} \par
\textasteriskcentered\par
\textperiodcentered\par
\textbullet\par
\textregistered{} \texttrademark
\end{document}
三、強調、斷行等
1、強調
Latex定義了\underline指令用來為文字添加下劃線。
\documentclass{ctexart}
\begin{document}
強調\underline{文字}
\end{document}
還可以調用宏包ulem,它提供的\uline指令能夠輕松生成自動換行的下劃線
\documentclass{ctexart}
\usepackage{ulem}
\begin{document}
% \uline 能夠輕松生成自動換行的下劃線
An example of \uline{some
long and underlined \\words.}
% \emph 指令用來将文字變為斜體以示強調。如果在本身已經用 \emph 指令強調的文字内部
% 嵌套使用 \emph 指令,内部則使用直立體文字
Some \emph{emphasized words,
including \emph{double-emphasized}
words}, are shown here.
% 嵌套使用
Some \uline{\emph{emphasized words,
including \emph{double-emphasized}
words}}, are shown here.
\end{document}
2、斷行與斷頁
如果我們确實需要手動斷行,可使用如下指令:
\\[⟨length⟩] \newline
它們有兩點差別:一是 \\ 可以帶可選參數 〈length〉,用于在換行處向下增加垂直間距,而 \newline 不帶可選參數;二是 \\ 也在表格、公式等地方用于分行,而 \newline隻用于文本段落中。
斷頁:
\newpage or \clearpage
通常情況下兩個指令都能起到另起一頁的作用,但有一些差別:一是在雙欄排版中 \newpage
隻起到另起一欄的作用;二是涉及到浮動體的排版上行為不同
總結
本篇主要寫的是Latex文字排版的點