毛宁波工作室分享 http://blog.sciencenet.cn/u/毛宁波 探讨高教改革、专业建设、人才培养方案、课程建设、教材建设、实验实习和大学生创新实验

博文

[转载]LaTeX Tutorial

已有 3604 次阅读 2010-1-24 02:14 |个人分类:地震勘探(学习指南)|系统分类:科普集锦|关键词:LaTeX,Tutorial| Tutorial |文章来源:转载

LaTeX Tutorial

University of New Hampshire,
Department of Mathematics,

 

Kingsbury Hall
University of New Hampshire
Durham, NH 03824
phone: (603)862-2320
fax: (603)862-4096

Overview

The easiest way to get started is to download our example files and then follow the directions on how to work with an existing LaTeX file. The easiest way to edit a file is to use "nedit." It is a basic editor which should feel familiar if you have worked with an editor before.

The basic structure of a file is given below. Here we assume that we have a file called "brilliant.tex" given by the following:

documentclass[12pt]{article}

% Anything following a % is a comment
% This part of the document is called the "preamble"
% There are certain commands that can only appear here.

begin{document}

% This is where the printed document is.

Brilliant observations appear hear. [sic]

end{document}

 

The file can now be converted into something viewable. To do this use the "latex" command:

% latex brilliant
The program looks for a file called brilliant.tex and creates several new files. One of the files, "brilliant.dvi," is the file that can be converted into a printable document.

 

You can view this file using "xdvi":

% xdvi brilliant&
The program looks for a file called "brilliant.dvi" and displays it on the screen. See the other sections in this documents for more information.

 

Example Files

A number of example files are available. Each one focuses on a particular example:

 

Example Thesis Files

A set of example files are available for use in creating a thesis. A complete list of the files are available as a compressed tar file for unix/linux systems or as a zip file for MicroSoft based systems. The files are also available individually, and a list of files is given below. You need to download each file, and the last file given is a gzip'ed tar file that contains all of the previous files. First, here are the files used for an example of using the style files:

The necessary style files are included below:

 

The main thesis file that you will latex is "mythesis.tex," and it includes the other files which you will edit. You can put each chapter in a separate file making this a convenient way to manage your thesis.

Using LaTeX on Existing Files

When you create a LaTeX file you can use any editor that you prefer. Once you have created and saved the file it is time to use LaTeX to typeset your document. For now we will assume that you created a file and called it document.tex. You can typeset the file using the latex command,

%latex document 
You may have to edit the document several times to get it right. If LaTeX finds something it doesn't like it will stop and ask directions. Just type 'q' to quit and go to the line number it gives you to see what went wrong. Sometimes the error occured before the line number and LaTeX couldn't figure out what happened.

 

You may have had some of your references change and you may have to use latex a second time. The second time through will clear things up. This is a bit akward, but it is a necessary step to make sure that any references or citations are correct.

Viewing Documents

The program used to view a file is called "xdvi." To view a file call xdvi with the filename:

% xdvi filename
A viewer will appear on your screen which will show the current latex'ed version of the file.

 

The xdvi program will assume that the extension is .dvi so you do not have to provide it. A new window will appear on your machine and you can step through the document using the space key. The b key will let you back-up through the document. Other keys allow you to do different things. See the manual pages for xdvi to get a full explanation,

% man xdvi 

 

Important keys include the following:

  • - move one page forward.
  • "b" - move one page backwards
  • "d" - move down towards the bottom of the page.

 

Printing Files

Once you have a document that LaTeX can typeset you are ready to print. Before printing make sure you run the document through LaTeX a second time.

You print the file by using dvips,

% dvips -t letter document 
This will take the dvi file, convert it into postscript, and then send it to the default printer. You need to add the "-t letter" option to make sure that the formater uses an 8.5" by 11" paper size. There are times when you want to convert the file into a postscript file rather than print it. For example, if you want to send your paper via email you likely want to just send the postscript file.

 

The command to convert a file to postscript is

%dvips -t letter document -o 
This will create the new file document.ps (on some systems it creates texfile.ps so be careful!). You can print this file using the "lpr" command.

Viewing Files on cisunix

The LaTeX program will read in your file and create a ``dvi'' file. This new file is called document.dvi. If you are on one of the workstations you can view the file using xdvi. To do so requires that you let cisunix know what machine you are working on. You must first let the workstation know that cisunix will be opening a window on the machine.

The first issue is that there is no machine called "cisunix." It is a collection of machines, and you have to figure out which one you are logged on to. To do this use the "hostname" command

% hostname 
This command will return the name of the particular machine you are using. For example, one of the machine name is "turing.unh.edu."  

Now you let the local workstation know what machine will be connecting to it. You will have to open a new window on the local machine and then let it know the name of the other machine. This is done with the xhost command,

% xhost + turing.unh.edu 
To view a dvi file you can now use xdvi from cisunic,
% xdvi document


http://blog.sciencenet.cn/blog-339326-289609.html

上一篇:[转载]推荐一个Matlab入门的网站
下一篇:提前半月的MIT中国学生虎年春节晚会

0

发表评论 评论 (0 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备14006957 )

GMT+8, 2019-10-19 10:20

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部