Linux中國

使用 LaTeX 和 TeXstudio 排版文檔

LaTeX 是一個服務於高質量排版的文檔準備系統。通常用於大量的技術和科學文檔的排版。不過,你也可以使用 LaTex 排版各種形式的文檔。教師可以編輯他們的考試和教學大綱,學生可以展示他們的論文和報告。這篇文章讓你嘗試使用 TeXstudio。TeXstudio 是一個便於編輯 LaTeX 文檔的軟體。

啟動 TeXstudio

如果你使用的是 Fedora Workstation,請啟動軟體管理,然後輸入 TeXstudio 以搜索該應用程序。然後選擇安裝並添加 TeXstudio 到你的系統。你可以從軟體管理中啟動這個程序,或者像以往一樣在概覽中啟動這個軟體。

或者,如果你使用終端,請輸入 texstudio。如果未安裝該軟體包,系統將提示你安裝它。鍵入 y 開始安裝。

$ texstudio
bash: texstudio: command not found...
Install package 'texstudio' to provide command 'texstudio'? [N/y] y

你的第一份文檔

LaTeX 命令通常以反斜杠 開頭,命令參數用大括弧 {} 括起來。首先聲明 documentclass 的類型。這個例子向你展示了該文檔的類是一篇文章。

然後,在聲明 documentclass 之後,用 beginend 標記文檔的開始和結束。在這些命令之間,寫一段類似以下的內容:

documentclass{article}
begin{document}
The Fedora Project is a project sponsored by Red Hat primarily to co-ordinate the development of the Linux-based Fedora operating system, operating with the vision that the project "creates a world where free culture is welcoming and widespread, collaboration is commonplace, and people control their content and devices". The Fedora Project was founded on 22 September 2003 when Red Hat decided to split Red Hat Linux into Red Hat Enterprise Linux (RHEL) and a community-based operating system, Fedora.
end{document}

使用間距

要創建段落分隔符,請在文本之間保留一個或多個換行符。下面是一個包含四個段落的示例:

從該示例中可以看出,多個換行符不會在段落之間創建額外的空格。但是,如果你確實需要留出額外的空間,請使用 hspacevspace 命令。這兩個命令分別添加水平和垂直空間。下面是一些示例代碼,顯示了段落周圍的附加間距:

documentclass{article}
begin{document}

hspace{2.5cm} The four essential freedoms

vspace{0.6cm} 
A program is free software if the program's users have the 4 essential freedoms:

The freedom to run the program as you wish, for any purpose (freedom 0).vspace{0.2cm} 
The freedom to study how the program works, and change it so it does your computing as you wish (freedom 1). Access to the source code is a precondition for this.vspace{0.2cm}

The freedom to redistribute copies so you can help your neighbour (freedom 2).vspace{0.2cm}

The freedom to distribute copies of your modified versions to others (freedom 3). By doing this you can give the whole community a chance to benefit from your changes. Access to the source code is a precondition for this.

end{document}

如果需要,你也可以使用 noindent 命令來避免縮進。這裡是上面 LaTeX 源碼的結果:

使用列表和格式

如果把自由軟體的四大基本自由列為一個清單,這個例子看起來會更好。通過在列表的開頭使用begin{itemize},在末尾使用 end{itemize} 來設置列表結構。在每個項目前面加上 item 命令。

額外的格式也有助於使文本更具可讀性。用于格式化的有用命令包括粗體、斜體、下劃線、超大、大、小和 textsc 以幫助強調文本:

documentclass{article}
begin{document}

hspace{2cm} {huge The four essential freedoms}

vspace{0.6cm} 
noindent {large A program is free software if the program's users have the 4 essential freedoms}:
begin{itemize}
item vspace{0.2cm} 
noindent textbf{The freedom to run} the program as you wish, for any purpose textit{(freedom 0)}. vspace{0.2cm} 
item noindent textbf{The freedom to study} how the program works, and change it so it does your computing as you wish textit{(freedom 1)}. Access to the source code is a precondition for this.vspace{0.2cm}

item noindent textbf{The freedom to redistribute} copies so you can help your neighbour textit{(freedom 2)}.vspace{0.2cm}

item noindent textbf{The freedom to distribute copies of your modified versions} to others textit{(freedom 3)}. tiny{By doing this you can give the whole community a chance to benefit from your changes.underline{textsc{ Access to the source code is a precondition for this.}}}
end{itemize}
end{document}

添加列、圖像和鏈接

列、圖像和鏈接有助於為文本添加更多信息。LaTeX 包含一些高級功能的函數作為宏包。usepackage 命令載入宏包以便你可以使用這些功能。

例如,要使用圖像,可以使用命令 usepackage{graphicx}。或者,要設置列和鏈接,請分別使用 usepackage{multicol}usepackage{hyperref}

includegraphics 命令將圖像內聯放置在文檔中。(為簡單起見,請將圖形文件包含在與 LaTeX 源文件相同的目錄中。)

下面是一個使用所有這些概念的示例。它還使用下載的兩個 PNG 圖片。試試你自己的圖片,看看它們是如何工作的。

documentclass{article} 
usepackage{graphicx}
usepackage{multicol}
usepackage{hyperref}
begin{document} 
 textbf{GNU}
 vspace{1cm}

 GNU is a recursive acronym for "GNU's Not Unix!", chosen because GNU's design is Unix-like, but differs from Unix by being free software and containing no Unix code.

 Richard Stallman, the founder of the project, views GNU as a "technical means to a social end". Stallman has written about "the social aspects of software and how Free Software can create community and social justice." in his "Free Society" book.
 vspace{1cm}

 textbf{Some Projects}

 begin{multicols}{2}
 Fedora
 url{https://getfedora.org}
 includegraphics[width=1cm]{fedora.png}

 GNOME
 url{https://getfedora.org}
 includegraphics[width=1cm]{gnome.png}
 end{multicols} 

end{document}

這裡的功能只觸及 LaTeX 功能的表面。你可以在該項目的幫助和文檔站點了解更多關於它們的信息。

via: https://fedoramagazine.org/typeset-latex-texstudio-fedora/

作者:Julita Inca Chiroque 選題:Chao-zhi 譯者:Chao-zhi 校對:wxy

本文由 LCTT 原創編譯,Linux中國 榮譽推出


本文轉載來自 Linux 中國: https://github.com/Linux-CN/archive

對這篇文章感覺如何?

太棒了
0
不錯
0
愛死了
0
不太好
0
感覺很糟
0
雨落清風。心向陽

    You may also like

    Leave a reply

    您的電子郵箱地址不會被公開。 必填項已用 * 標註

    此站點使用Akismet來減少垃圾評論。了解我們如何處理您的評論數據

    More in:Linux中國