[①LaTex]: Ubuntu 18.04使用LaTex

前言

LaTex(音译"拉泰赫")是一种基于ΤΕΧ的排版系统。用LaTex写的文章排版十分精美,在生成复杂表格和数学公式这方面,LaTex的能力无出其右,所以一些权威的学术论文都要求用LaTex来制作,比如下面是IEEE论文LaTex的模板:
[①LaTex]: Ubuntu 18.04使用LaTex_第1张图片
LaTex是用宏语言写的,在一开始写LaTex时,有点像写代码,所以对初学者不太友好。但是LaTex根据人们排版文章的习惯,定义了许多命令和模板,并且有很多宏包可以使用,所以在撰写文章时不会被文章排版细节干扰精力,并且达到非常好的排版效果(尤其是数学排版),后期修改排版也十分方便,这些都是word非常难做到的。所以LaTex门槛高,但是你熟练掌握后就会事半功倍。另外LaTex非常显著的优点是:多平台并且免费

Ubuntu 18.04 安装LaTex

下面就先介绍下在Ubuntu 18.04 Linux系统中LaTex的安装方法。首先LaTex常用的安装包有:

  • texlive-latex-base – 136 MB
  • texlive-latex-recommended – 177 MB
  • texlive – 240 MB
  • texlive-latex-extra – 404 MB
  • texlive-full – 4714 MB

我们可以根据实际的硬盘空间和使用情况安装,比如:

sudo apt install texlive-latex-base

简单介绍下几个安装包之间的区别:

  • texlive-latex-base – 最基本的安装包,没什么特别要求的话安装这个就可以了,包含28个CTAN packages(宏包, 宏包个别下载地址:https://www.ctan.org/pkg):
ae, amscls, amsmath, babel, babel-english, babelbib, carlisle, colortbl, fancyhdr, fix2col, geometry, graphics, graphics-cfg, hyperref, latex, latex-bin, latex-fonts, latexconfig, ltxmisc, mfnfss, mptopdf, natbib, oberdiek, pslatex, psnfss, pspicture, tools, url
  • texlive-latex-recommended – 包含了一些推荐的add-on packages,比如说TIPA,提供国际音标以其他音标功能。在安装时也会安装texlive-latex-base,包含188个CTAN packages:
anysize, beamer, booktabs, breqn, caption, cite, cmap, crop, ctable, eso-pic, euenc, euler, etoolbox, extsizes, fancybox, fancyref, fancyvrb, filehook, float, fontspec, fp, index, jknapltx, koma-script, latexbug, l3experimental, l3kernel, l3packages, lineno, listings, lwarp, mathspec, mathtools, mdwtools, memoir, metalogo, microtype, ms, ntgclass, parskip, pdfpages, polyglossia, powerdot, psfrag, rcs, sansmath, section, seminar, sepnum, setspace, subfig, textcase, thumbpdf, translator, typehtml, ucharcat, underscore, unicode-math, xcolor, xkeyval, xltxtra, xunicode
  • texlive – 包含了texlive-latex-base,texlive-latex-recommended和texlive-fonts-recommended。texlive-fonts-recommended是TeX Live推荐安装的字体,包括大字符集的Computer Modern、Latin Modern、psnfss(PostScript35套字体,Helvetica/Times/Palatino等)、TeX Gyre(PostScript35套字体的OTF对应版本,还包括四个OpenType数学字体)。一般来说安装这个包已经能满足用户大部分的需求。

  • texlive-latex-extra – 包含了更多的add-on packages,在安装时也会安装texlive-latex-base,texlive-latex-recommended,texlive-fonts-recommended和texlive-pictures(包含Tikz,用于绘图等)。包含1239个CTAN packages:

2up, ESIEEcv, GS1, HA-prosper, Tabbing, a0poster, a4wide, a5comb, abraces, abstract, achemso, acro, acronym, acroterm, actuarialangle, actuarialsymbol, addfont, addlines, adjmulticol, adjustbox, adrconv, advdate, akktex, akletter, alertmessage, alnumsec, alterqcm, altfont, amsaddr, animate, anonchap, answers, anyfontsize, appendix, appendixnumberbeamer, apptools, arcs, arrayjobx, arraysort, arydshln, asciilist, assignment, assoccnt, attachfile, aurl, authoraftertitle, authorarchive, authorindex, autonum, autopdf, avremu, axessibility, background, bankstatement, bashful, basicarith, bchart, beamer2thesis, beameraudience, beamercolorthemeowl, beamerdarkthemes, beamerposter, beamersubframe, beamertheme-cuerna, beamertheme-detlevcm, beamertheme-epyt, beamertheme-focus, beamertheme-light, beamertheme-metropolis, beamertheme-npbt, beamertheme-phnompenh, beamertheme-saintpetersburg, beamertheme-upenn-bc, beamerthemejltree, beamerthemenirma, beton, bewerbung, bez123, bezos, bhcexam, bibletext, bigfoot, bigints, biochemistry-colors, bizcard, blindtext, blkarray, block, blowup, bnumexpr, boites, bold-extra, bookcover, bookest, booklet, boolexpr, bophook, boxedminipage, boxedminipage2e, boxhandler, bracketkey, braket, breakurl, bullcntr, bussproofs, bxcalc, bxdpx-beamer, bxdvidriver, bxenclose, bxnewfont, bxpapersize, bxpdfver, bxtexlogo, calcage, calctab, calculator, calrsfs, cals, calxxxx-yyyy, cancel, canoniclayout, capt-of, captcont, captdef, carbohydrates, cases, casyl, catchfilebetweentags, catechis, catoptions, cbcoptic, ccaption, cclicenses, cd, cd-cover, cdpbundl, cellprops, cellspace, censor, changebar, changelayout, changelog, changepage, changes, chappg, chapterfolder, cheatsheet, chet, chextras, childdoc, chkfloat, chletter, chngcntr, chronology, circ, classics, classpack, clefval, cleveref, clipboard, clock, cloze, clrdblpg, clrstrip, cmdstring, cmdtrack, cmsd, cnltx, cntformats, cntperchap, codedoc, codepage, codesection, collcell, collectbox, colophon, colordoc, colorinfo, coloring, colorspace, colortab, colorwav, colorweb, colourchange, combelow, combine, comma, commado, commedit, comment, competences, concepts, concprog, constants, continue, contour, contracard, conv-xkv,  identkey, idxcmds, idxlayout, iffont, ifmslide, ifmtarg, ifnextok, ifoddpage, ifplatform, ifthenx, iitem, image-gallery, nyind, marginfit, marginfix, marginnote, markdown, mathalfa, mathastext, mathexam, mathfam256, mathfont, maybemath, mbenotes, mcaption, mceinleger, mcexam, mcite, mciteplus, mdframed, media9, medstarbeamer, meetingmins, memexsupp, memory, mensa-tex, menu, menukeys, metalogox, method, metre, mfirstuc, mftinc, mi-solns, midpage, minibox, minidocument, minifp, minipage-marginpar, minitoc, minorrevision, minted, minutes, mla-paper, mlist, mmap, mnotes, moderncv, modernposter, moderntimeline, modref, modroman, modular, monofill, moodle, moreenum, morefloats, morehype, moresize, moreverb, morewrites, movie15, mparhack, mpostinl, msc, msg, mslapa, mtgreek, multenum, multiaudience, multibbl, multicap, multicolrule, multidef, multienv, multiexpand, multilang, multirow, mversion, mwe, mycv, mylatexformat, nag, nameauth, namespc, ncclatex, ncctools, needspace, nestquot, newcommand, newenviron, newfile, newlfm, newspaper, newunicodechar, ... 
  • texlive-full – 包含所有的安装包,支持多语言,比如中文。

当然还能用apt方法安装其他有特定功能的安装包,例如:

  • texlive-publishers – 学术论文和毕业论文模板等相关的
  • texlive-science – mathematics, natural sciences, computer science等相关的
  • texlive-pstricks – PSTricks绘图工具等相关的

用下面的命令可以搜索所有跟TeX Live相关的安装包:

apt-cache search texlive
[①LaTex]: Ubuntu 18.04使用LaTex_第2张图片

第一个简单的LaTex文章

LaTex的编译文件后缀名为.tex,创建一个名为hello_world.tex的文件:

touch hello_world.tex

打开文件,在文件中添加以下内容:

\documentclass{article}
\usepackage{hyperref}
\begin{document}
Hello world \LaTeX

\url{https://www.ctan.org/pkg}
\end{document}

保存退出后用pdflatex命令编译,并且生成pdf文件:

pdflatex hello_world.tex

最后查看pdf文件:

evince hello_world.pdf
[①LaTex]: Ubuntu 18.04使用LaTex_第3张图片

结语

在一些关于LaTex的介绍中,有句话让博主非常有感触:对于LaTex爱好者来说,LaTex不仅是一种文字编辑排版工具,它更是一门艺术,给人以美的享受。然而,追求完美是要付出一定代价的。对于想使用LaTex,但又害怕使用LaTex的同学们,希望这篇博客对你们有所帮助。

你可能感兴趣的:(ubuntu,linux)