在 Linux 上开始使用 Latex
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1017055/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Get started with Latex on Linux
提问by Lakshman Prasad
Impressed by is-latex-worth-learning-today, and many how-to's on Windows,
对is-latex-worth-learning-today以及 Windows 上的许多操作方法印象深刻,
How do you have someone started with LaTeX on Linux?
你是如何让某人开始在 Linux 上使用 LaTeX 的?
How do you generate a pdf out of it and give up the OOO Word processer?
您如何从中生成 pdf 并放弃 OOO Word 处理器?
Update:
更新:
Thanks to all the suggestions given in here. I was able to create an awesome ppt using the Beamer class: http://github.com/becomingGuru/gids-django-ppt. I found this approach too far better than using powerpoint and the like.
感谢这里给出的所有建议。我能够使用 Beamer 类创建一个很棒的 ppt:http: //github.com/becomingGuru/gids-django-ppt。我发现这种方法比使用 powerpoint 之类的方法要好得多。
Those interested may checkout the TEX file, with many custom commands and the corresponding presentation.
采纳答案by David Gardner
First you'll need to Installit:
首先你需要安装它:
If you're using a distro which packages LaTeX (almost all will do) then look for texliveor tetex. TeX Live is the newer of the two, and is replacing tetex on most distributions now.
If you're using Debian or Ubuntu, something like:
apt-get install texlive
..will get it installed.
RedHat or CentOS need:
yum install tetex
如果您使用的是包含 LaTeX 的发行版(几乎所有都可以),请查找texlive或tetex。TeX Live 是两者中较新的一个,现在正在取代大多数发行版上的 tetex。
如果您使用的是 Debian 或 Ubuntu,则类似于:
apt-get install texlive
..会安装它。
RedHat 或 CentOS 需要:
yum install tetex
Note : This needs root permissions, so either use su
to switch user to root, or prefix the commands with sudo
, if you aren't already logged in as the root user.
注意:这需要 root 权限,因此如果您尚未以 root 用户身份登录,则可以使用su
将用户切换为 root,或者在命令前加上sudo
。
Next you'll need to get a text editor. Any editor will do, so whatever you are comfortable with. You'll find that advanced editors like Emacs (and vim) add a lot of functionality and so will help with ensuring that your syntax is correct before you try and build your document output.
接下来你需要得到一个文本编辑器。任何编辑器都可以,所以无论您喜欢什么。您会发现像 Emacs(和 vim)这样的高级编辑器添加了很多功能,因此有助于在您尝试构建文档输出之前确保语法正确。
Create a file called test.tex and put some content in it, say the example from the LaTeX primer:
创建一个名为 test.tex 的文件并在其中放入一些内容,例如LaTeX 入门中的示例:
\documentclass[a4paper,12pt]{article}
\begin{document}
The foundations of the rigorous study of \emph{analysis}
were laid in the nineteenth century, notably by the
mathematicians Cauchy and Weierstrass. Central to the
study of this subject are the formal definitions of
\emph{limits} and \emph{continuity}.
Let $D$ be a subset of $\bf R$ and let
$f \colon D \to \mathbf{R}$ be a real-valued function on
$D$. The function $f$ is said to be \emph{continuous} on
$D$ if, for all $\epsilon > 0$ and for all $x \in D$,
there exists some $\delta > 0$ (which may depend on $x$)
such that if $y \in D$ satisfies
\[ |y - x| < \delta \]
then
\[ |f(y) - f(x)| < \epsilon. \]
One may readily verify that if $f$ and $g$ are continuous
functions on $D$ then the functions $f+g$, $f-g$ and
$f.g$ are continuous. If in addition $g$ is everywhere
non-zero then $f/g$ is continuous.
\end{document}
Once you've got this file you'll need to run latexon it to produce some output (as a .dvi file to start with, which is possible to convert to many other formats):
获得此文件后,您需要在其上运行 latex以生成一些输出(作为 .dvi 文件开始,可以转换为许多其他格式):
latex test.tex
This will print a bunch of output, something like this:
这将打印一堆输出,如下所示:
=> latex test.tex
This is pdfeTeX, Version 3.141592-1.21a-2.2 (Web2C 7.5.4)
entering extended mode
(./test.tex
LaTeX2e <2003/12/01>
Babel <v3.8d> and hyphenation patterns for american, french, german, ngerman, b
ahasa, basque, bulgarian, catalan, croatian, czech, danish, dutch, esperanto, e
stonian, finnish, greek, icelandic, irish, italian, latin, magyar, norsk, polis
h, portuges, romanian, russian, serbian, slovak, slovene, spanish, swedish, tur
kish, ukrainian, nohyphenation, loaded.
(/usr/share/texmf/tex/latex/base/article.cls
Document Class: article 2004/02/16 v1.4f Standard LaTeX document class
(/usr/share/texmf/tex/latex/base/size12.clo))
No file test.aux.
[1] (./test.aux) )
Output written on test.dvi (1 page, 1508 bytes).
Transcript written on test.log.
..don't worry about most of this output -- the important part is the Output written on test.dviline, which says that it was successful.
..不要担心这个输出的大部分——重要的部分是写在 test.dvi行上的输出,它表明它是成功的。
Now you need to view the output filewith xdvi:
现在您需要使用 xdvi查看输出文件:
xdvi test.dvi &
This will pop up a window with the beautifully formatted output in it. Hit `q' to quit this, or you can leave it open and it will automatically update when the test.dvi file is modified (so whenever you run latex to update the output).
这将弹出一个窗口,其中包含格式精美的输出。点击 `q' 退出,或者你可以让它保持打开状态,当 test.dvi 文件被修改时它会自动更新(所以每当你运行 latex 来更新输出时)。
To produce a PDF of thisyou simply run pdflatexinstead of latex:
要生成这样的 PDF,您只需运行pdflatex而不是 latex:
pdflatex test.tex
..and you'll have a test.pdf file created instead of the test.dvi file.
..并且您将创建一个 test.pdf 文件而不是 test.dvi 文件。
After this is all working fine, I would suggest going to the the LaTeX primerpage and running through the items on there as you need features for documents you want to write.
一切正常后,我建议您访问LaTeX 入门页面并浏览那里的项目,因为您需要要编写的文档的功能。
Future things to consider include:
未来需要考虑的事情包括:
Use tools such as xfigor diato create diagrams. These can be easily inserted into your documents in a variety of formats. Note that if you are creating PDFs then you shouldn't use EPS (encapsulated postscript) for images-- use pdf exported from your diagram editor if possible, or you can use the
epstopdf
package to automatically convert from (e)ps to pdf for figures included with\includegraphics
.Start using version control on your documents. This seems excessive at first, but being able to go back and look at earlier versions when you are writing something large can be extremely useful.
Use maketo run latex for you. When you start on having bibliographies, images and other more complex uses of latex you'll find that you need to run it over multiple files or multiple times (the first time updates the references, and the second puts references into the document, so they can be out-of-date unless you run latex twice...). Abstracting this into a makefile can save a lot of time and effort.
Use a better editor. Something like Emacs + AUCTeX is highly competent. This is of course a highly subjective subject, so I'll leave it at that (that and that Emacs is clearly the best option :)
使用xfig或dia等工具创建图表。这些可以很容易地以各种格式插入到您的文档中。请注意,如果您正在创建 PDF,那么您不应该对图像使用 EPS(封装后记)——如果可能,请使用从图表编辑器导出的 pdf,或者您可以使用该
epstopdf
包自动从 (e)ps 转换为 pdf 以用于数字包含在\includegraphics
.开始对您的文档使用版本控制。这乍一看似乎有些过分,但是在编写大型内容时能够返回并查看早期版本可能非常有用。
使用make为您运行 Latex。当您开始使用书目、图像和其他更复杂的 Latex 用途时,您会发现您需要在多个文件或多次运行它(第一次更新参考文献,第二次将参考文献放入文档中,因此它们除非您两次运行 Latex ,否则可能会过时......)。将其抽象为 makefile 可以节省大量时间和精力。
使用更好的编辑器。像 Emacs + AUCTeX 这样的东西非常有能力。这当然是一个非常主观的主题,所以我将把它留在那个(那个和那个 Emacs 显然是最好的选择:)
回答by Residuum
It depends on your Linux distibution and your preference of editors etc. but I would recommend to start with Kile(a KDE app) as it is easy to learn and installing it should install most of the needed packages for LaTex and PDF generation. Just have a look at the screenshots.
这取决于您的 Linux 发行版和您对编辑器的偏好等。但我建议从Kile(一个 KDE 应用程序)开始,因为它易于学习并且安装它应该会安装大多数 LaTex 和 PDF 生成所需的包。看看屏幕截图。
回答by las3rjock
To get started with LaTeX on Linux, you're going to need to install a couple of packages:
要在 Linux 上开始使用 LaTeX,您需要安装几个软件包:
You're going to need a LaTeX distribution. This is the collection of programs that comprise the (La)TeX computer typesetting system. The standard LaTeX distribution on Unix systems used to be teTeX, but it has been superceded by TeX Live. Most Linux distributions have installation packages for TeX Live--see, for example, the package database entries for Ubuntuand Fedora.
You will probably want to install a LaTeX editor. Standard Linux text editors will work fine; in particular, Emacs has a nice package of (La)TeX editing macros called AUCTeX. Specialized LaTeX editors also exist; of those, Kile(KDE Integrated LaTeX Environment) is particularly nice.
You will probably want a LaTeX tutorial. The classic tutorial is "A (Not So) Short Introduction to LaTeX2e," but nowadays the LaTeX wikibookmight be a better choice.
您将需要一个LaTeX 发行版。这是组成 (La)TeX 计算机排版系统的程序集合。Unix 系统上的标准 LaTeX 发行版曾经是teTeX,但它已被TeX Live取代。大多数 Linux 发行版都有 TeX Live 的安装包——例如,参见Ubuntu和Fedora的包数据库条目。
您可能想要安装LaTeX 编辑器。标准的 Linux 文本编辑器可以正常工作;特别是,Emacs 有一个很好的 (La)TeX 编辑宏包,称为AUCTeX。还存在专门的 LaTeX 编辑器;其中,Kile(KDE 集成 LaTeX 环境)特别好。
您可能需要LaTeX 教程。经典教程是“对 LaTeX2e 的(不那么)简短介绍”,但现在LaTeX wikibook可能是更好的选择。
回答by Oliver Friedrich
I would recommend start using Lyx, with that you can use Latex just as easy as OOO-Writer. It gives you the possibility to step into Latex deeper by manually adding Latex-Code to your Document. PDF is just one klick away after installatioin. Lyx is cross-plattform.
我建议开始使用 Lyx,这样您就可以像 OOO-Writer 一样轻松地使用 Latex。它让您可以通过手动将 Latex 代码添加到您的文档中来更深入地使用 Latex。PDF 安装后只需一键即可。Lyx 是跨平台的。
回答by ConcernedOfTunbridgeWells
LaTeX comes with most Linux distributions in the form of the teTeXdistribution. Find all packages with 'teTeX' in the name and install them.
大多数 Linux 发行版都以teTeX发行版的形式提供了 LaTeX 。找到名称中带有“teTeX”的所有软件包并安装它们。
Most editors such as vimor emacscome with TeX editing modes. You can also get WYSIWIG-ish front-ends (technically WYSIWYM), of which perhaps the best known is LyX.
The best quick intro to LaTeX is Oetiker's 'The not so short intro to LaTeX'
LaTeX works like a compiler. You compile the LaTeX document (which can include other files), which generates a file called a
.dvi
(device independent). This can be post-processed to various formats (including PDF) with various post-processors.To do PDF, use
dvips
and use the flag -PPDF (IIRC - I don't have a makefile to hand) to produce a PS with font rendering set up for conversion to pdf. PDF conversion can then be done withps2pdf
or distiller (if you have this).The best format for including graphicsin this environment is
eps
(Encapsulated Postscript) although not all software produces well-behaved postscript. Photographs in jpeg or other formats can be included using various mechanisms.
大多数编辑器如vim或emacs都带有 TeX编辑模式。您还可以获得 WYSIWIG 式的前端(技术上为WYSIWYM),其中最著名的可能是LyX。
LaTeX 最好的快速介绍是 Oetiker 的“The not so short intro to LaTeX”
LaTeX 就像一个编译器。您编译 LaTeX 文档(可以包含其他文件),它会生成一个名为 a
.dvi
(设备无关)的文件。可以使用各种后处理器将其后处理为各种格式(包括 PDF)。要制作 PDF,请使用
dvips
并使用标志 -PPDF(IIRC - 我没有手头的 makefile)来生成带有字体渲染设置以转换为 pdf 的 PS。然后可以使用ps2pdf
或蒸馏器(如果有的话)完成 PDF 转换。在此环境中包含图形的最佳格式是
eps
(Encapsulated Postscript),尽管并非所有软件都能生成表现良好的 postscript。可以使用各种机制包含 jpeg 或其他格式的照片。
回答by Manuel Ignacio López Quintero
If you use Ubuntu or Debian, I made a tutorial easy to follow: Install LaTeX on Ubuntu or Debian. This tutorial explains how to install LaTeX and how to create your first PDF.
如果您使用 Ubuntu 或 Debian,我制作了一个易于遵循的教程:在 Ubuntu 或 Debian 上安装 LaTeX。本教程介绍了如何安装 LaTeX 以及如何创建您的第一个 PDF。
回答by E. Bye
I would personally use a complete editing package such as:
我个人会使用一个完整的编辑包,例如:
- TexWorks
- TexStudio
- 纺织工场
- 纺织工作室
Then I would install "MikTeX" as the compiling package, which allows you to generate a PDF from your document, using the pdfLaTeX
compiler.
然后我将安装“MikTeX”作为编译包,它允许您使用pdfLaTeX
编译器从您的文档生成 PDF 。
回答by Paul
yum -y install texlive
was not enough for my centos distro to get the latex command.
不足以让我的 centos 发行版获得 latex 命令。
This site https://gist.github.com/melvincabatuan/350f86611bc012a5c1c6contains additional packages. In particular:
该站点https://gist.github.com/melvincabatuan/350f86611bc012a5c1c6包含其他软件包。特别是:
yum -y install texlive texlive-latex texlive-xetex
was enough but the author also points out these as well:
已经足够了,但作者还指出了这些:
yum -y install texlive-collection-latex
yum -y install texlive-collection-latexrecommended
yum -y install texlive-xetex-def
yum -y install texlive-collection-xetex
Only if needed:
仅在需要时:
yum -y install texlive-collection-latexextra