Ubuntu下安装latex (支持中文CJK环境)

来源:互联网 发布:数据库发展趋势 编辑:程序博客网 时间:2024/05/22 10:40

转载于点击打开链接

This guide explains how to install LaTeX in Ubuntu Linux. LaTeX is a document preparation system for high-quality typesetting. It is most often used for medium-to-large technical or scientific documents but it can be used for almost any form of publishing.

LaTeX is not a word processor! Instead, LaTeX encourages authors not to worry too much about the appearance of their documents but to concentrate on getting the right content.

Installing LaTeX is also compatible to any hosting, Just make sure that the hosting you have is a reliable one.

How to install LaTeX in Ubuntu

In Ubuntu Linux, you have to first install LaTeX to use it. This is how LaTeX is installed in Ubuntu.

$ sudo apt-get install texlive

The above command will install a basic subset of TeX Live’s functionality. To install all the packages in the LaTeX distribution, you have to run the following command.

$ sudo apt-get install texlive-full

Gedit LaTeX Plugin

Gedit has a plugin for LaTeX which converts Gedit into a LaTeX editor. You can install the Gedit LaTeX plugin as follows :

$ sudo apt-get install gedit-latex-plugin

Once you install the plug-in, you will have to enable the plug-in in Gedit to begin using it. This is achieved by opening Gedit Preferences (GEdit > Edit > Preferences). Then clicking on the Plugins tab and turning on the “Gedit LaTeX plugin”. Now when ever you open a TeX file, you will have access to the LaTeX menu in Gedit.

Recommended LaTeX Packages

  • latex-beamer – Beamer package is used to create presentations. It is an excellent LaTeX class that supports dynamic effects.
  • TeXPower – Is a bundle of style and class files for creating dynamic online presentations with LaTeX.
  • Prosper – A LaTeX class for writing transparencies.
  • texlive-pictures – This is a LaTeX package for drawing graphics. It contain several classes such as ‘curve’ (for creating resumes), ‘bardiag’ (for bar graphs), ‘pmgraph’ (poor man’s graphics) and so on.
  • texlive-latex-extra – This is a large collection of addon packages for LaTeX. The full list of classes in this package are listed here.

This is the full command I used to install LaTeX on my machine running Ubuntu Linux.

$ sudo apt-get install gedit-latex-plugin texlive-fonts-recommended latex-beamer texpower texlive-pictures texlive-latex-extra texpower-examples imagemagick


Latex中文环境配置,转载于点击打开链接


LaTeX是一个强大的排版软件,但是其最初只是为英文排版而设计的。为了使其能够胜任中文排版的重任,我们还需要进行一些额外的调教。这篇文章中,就谈谈如何在Ubuntu下(使用12.04)进行LaTeX中文环境配置。

第一步,安装基本的LaTeX环境:

1sudo apt-get install texlive

第二步,安装中文字体包。字体包中包含bsmi,bkai,gkai,gbsn四种中文字体。bsmi和bkai是Big5编码的宋体和楷体字;后两者gkai和gbsn分别处理简体中文楷体字和宋体字。

1sudo apt-get install latex-cjk-all

至此,基本的配置就完成了。此时,我们可以新建一个tex文件并输入以下测试内容。正常情况下,编译这个tex文件就能在文档中显示中文了。值得说明的一点是,这些字体是不支持斜体格式的,但支持加粗。其实,在正式的中文排版中,如果要强调某些部分,是通过使用仿宋体或者楷体来实现,而不是像英文中那样通过斜体来实现。

01\documentclass{article}
02\usepackage{CJKutf8}
03\begin{document}
04\begin{CJK}{UTF8}{gkai}
05这是一个楷体中文测试,处理简体字。
06\end{CJK}
07\begin{CJK}{UTF8}{gbsn}
08这是一个宋体中文测试,处理简体字。
09\end{CJK}
10\begin{CJK}{UTF8}{bkai}
11這是一個big5編碼的楷體中文測試,處理繁體文字。
12\end{CJK}
13\begin{CJK}{UTF8}{bsmi}
14這是一個个big5編碼的明體中文測試,處理繁體文字。
15\end{CJK}
16\end{document}

接下来,还要针对中文排版进行进一步的设置。

首先,设置每一行的首行缩进。

1/usepackage{indentfirst}
2/setlength{/parindent}{2em}

其次,中文文档习惯于使用“目录”、“插图目录”、“表格目录”、“参考文献”、“摘要”、“索引”、“表格”、“图”等字样作为文章特殊部分的标题,而 LaTeX 对于这些部分的标题默认是使用英文的,因此可以通过重定义宏的方式将其重定义为中文字样。

1/renewcommand{/contentsname}{目录}
2/renewcommand{/listfigurename}{插图目录}
3/renewcommand{/listtablename}{表格目录}
4/renewcommand{/refname}{参考文献}
5/renewcommand{/abstractname}{摘要}
6/renewcommand{/indexname}{索引}
7/renewcommand{/tablename}{表}
8/renewcommand{/figurename}{图}

写到这里,用LaTeX来进行日常的中文排版就不成问题了。如果有进一步的需求,可以参看下面这篇《用LaTeX写漂亮学术论文》的文章。最后,希望大家都能喜欢LaTeX这个功能强大的排版软件。


原创粉丝点击