使用 LaTeX 和 TeXstudio 排版文檔
LaTeX 是一個(gè)服務(wù)于高質(zhì)量排版的文檔準(zhǔn)備系統(tǒng)。通常用于大量的技術(shù)和科學(xué)文檔的排版。不過,你也可以使用 LaTex 排版各種形式的文檔。教師可以編輯他們的考試和教學(xué)大綱,學(xué)生可以展示他們的論文和報(bào)告。這篇文章讓你嘗試使用 TeXstudio。TeXstudio 是一個(gè)便于編輯 LaTeX 文檔的軟件。
啟動(dòng) TeXstudio
如果你使用的是 fedora Workstation,請(qǐng)啟動(dòng)軟件管理,然后輸入 TeXstudio 以搜索該應(yīng)用程序。然后選擇安裝并添加 TeXstudio 到你的系統(tǒng)。你可以從軟件管理中啟動(dòng)這個(gè)程序,或者像以往一樣在概覽中啟動(dòng)這個(gè)軟件。
或者,如果你使用終端,請(qǐng)輸入 texstudio
。如果未安裝該軟件包,系統(tǒng)將提示你安裝它。鍵入y
開始安裝。
$ texstudiobash: texstudio: command not found...Install package 'texstudio' to provide command 'texstudio'? [N/y] y
你的第一份文檔
LaTeX 命令通常以反斜杠 開頭,命令參數(shù)用大括號(hào)
{}
括起來(lái)。首先聲明documentclass
的類型。這個(gè)例子向你展示了該文檔的類是一篇文章。
然后,在聲明 documentclass
之后,用begin
和end
標(biāo)記文檔的開始和結(jié)束。在這些命令之間,寫一段類似以下的內(nèi)容:
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}
使用間距
要?jiǎng)?chuàng)建段落分隔符,請(qǐng)?jiān)谖谋局g保留一個(gè)或多個(gè)換行符。下面是一個(gè)包含四個(gè)段落的示例:
從該示例中可以看出,多個(gè)換行符不會(huì)在段落之間創(chuàng)建額外的空格。但是,如果你確實(shí)需要留出額外的空間,請(qǐng)使用 hspace
和vspace
命令。這兩個(gè)命令分別添加水平和垂直空間。下面是一些示例代碼,顯示了段落周圍的附加間距:
documentclass{article}begin{document}hspace{2.5cm} The four essential freedomsvspace{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
命令來(lái)避免縮進(jìn)。這里是上面 LaTeX 源碼的結(jié)果:
使用列表和格式
如果把自由軟件的四大基本自由列為一個(gè)清單,這個(gè)例子看起來(lái)會(huì)更好。通過在列表的開頭使用begin{itemize}
,在末尾使用end{itemize}
來(lái)設(shè)置列表結(jié)構(gòu)。在每個(gè)項(xiàng)目前面加上item
命令。
額外的格式也有助于使文本更具可讀性。用于格式化的有用命令包括粗體、斜體、下劃線、超大、大、小和 textsc 以幫助強(qiáng)調(diào)文本:
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 包含一些高級(jí)功能的函數(shù)作為宏包。usepackage
命令加載宏包以便你可以使用這些功能。
例如,要使用圖像,可以使用命令 usepackage{graphicx}
。或者,要設(shè)置列和鏈接,請(qǐng)分別使用usepackage{multicol}
和usepackage{hyperref}
。
includegraphics
命令將圖像內(nèi)聯(lián)放置在文檔中。(為簡(jiǎn)單起見,請(qǐng)將圖形文件包含在與 LaTeX 源文件相同的目錄中。)
下面是一個(gè)使用所有這些概念的示例。它還使用下載的兩個(gè) 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 功能的表面。你可以在該項(xiàng)目的幫助和文檔站點(diǎn)了解更多關(guān)于它們的信息。
via: https://fedoramagazine.org/typeset-latex-texstudio-fedora/
作者:Julita Inca Chiroque選題:Chao-zhi譯者:Chao-zhi校對(duì):wxy
本文由 LCTT原創(chuàng)編譯,Linux中國(guó)榮譽(yù)推出