TeX China认证群组  - 讨论区

标题:How to Convert LaTeX to dvi, ps, pdf and HTML formats

2010年06月03日 星期四 17:56

How to Convert LaTeX to dvi, ps, pdf and HTML formats

This document outlines various different methods for converting latex documents into other formats.

DVI

Simply run latex on the document in question to produce the dvi file.

POSTSCRIPT

First run latex to obtain the dvi file. Then use

dvips -o file.ps file[.dvi]

You could add an option -D600 to specifically set the resolution in dpi if the output appears to be coming out at a lower resolution.

PDF

There are several ways to produce PDF output.

Using dvipdfm

The command dvipdfm will convert the ordinary dvi file (output by the latex command) into a pdf file, e.g.

dvipdfm file[.dvi]

This approach is useful if the original document contains postscript figures.

Using pdflatex

The pdflatex command processes a (pdf)latex document directly outputing a pdf file. A key difference between latex and pdflatex is that latex uses postscript images whereas pdflatex uses pdf or jpeg images.

Thus if you have an ordinary latex document with postscript images it is quicker to use the above approach of using dvipdfm. Otherwise you would first have to convert all the images to pdf. This can be done simply with epstopdf, e.g.

epstopdf figure.eps

will produce figure.pdf.

Assuming you insert such graphics with either the epsfig or includegraphics command then you can make your tex work with both pdflatex and latex simply by refering to the files without the extensions. latex or pdflatex will then look for a default extension including eps or ps for latex and pdf or jpg for pdflatex, e.g. doing

\includegraphics{figure}

it will look for figure.eps or figure.ps when running latex but will look for figure.pdf when running pdflatex.

If you use pstex andd pstex_t files from xfig then you need to remove the explicit .pstex extension reference made in the pstex_t file to make it work with pdflatex.

Using ps2pdf

A less efficient approach that either of the above it to use the ps2pdf command having first produced a postscript version, e.g.

ps2pdf file.ps file.pdf

Note, however, this approach typically produces larger pdf files whcih can also be a lower quality.

L A TEX2HTML

First latex the document as normal as latex2html will use the generated .aux files for crossreferencing etc. Then in its simplest form you could do

latex2html file.tex

Doing this it will use the default options and eventually generate all the HTML and GIF/PNG images in a subdirectory with the name file. The resulting files can then be put on the web server (or alternatively you could have moved the tex file to the web server before you started).

To see the full list of option to latex2html run

latex2html -h

and the full instruction manual is available on the Help web pages, simply follow the links to online documentation.

Some useful options may be

-address
Supply your own string if you don't like the default <Name> <Date>. For example
-address "Last changed $address_data[1].<BR><I>K.A. Gillow.</I><BR><A
HREF="mailto: gillow@maths.ox.ac.uk "> gillow@maths.ox.ac.uk </A>"
-dir
Sets the output directory to something other than file.
-info
Do not make an about this document page.
-no_math
all maths is passed to latex and produced as a gif. The default behaviour means it will try to use plain text to display equation if the entire equation can be done that way. However combining this with the option -html_version 3.2,math does something different. This causes it to only produce gifs for individual bits of equations that it cannot adequately represent with simple text.
-no_resuse
Prompt as to whether to resue previously generated images. Useful if the previous run failed to force it to do everything from scratch.
-show_section_numbers
To make it show the section numbering.
-split
Stop splitting sections into separate files at this depth. The default is 8.

All these can also be set using a personal latex2html configuration file called ~/.latex2html-init.

Thus the above option can be set with the lines

$ADDRESS = "Last changed $address_data[1].<BR><I>K.A. Gillow.</I><BR><A
HREF="mailto: gillow@maths.ox.ac.uk "> gillow@maths.ox.ac.uk </A>";

$DESTDIR = <dirname>;

$INFO = 0;

$NO_MATH = 1;

$HTML_VERSION = 3.2,math;

$REUSE = 0;

$SHOW_SECTION_NUMBERS = 1;

$MAX_SPLIT_DEPTH = <num>;

Other useful options that can be set this way are

$BODYTEXT = 'BGCOLOR=#ffffff'; -- this specifies the pages should have a background color #ffffff (i.e. white). This can also be set in the latex document itself by adding in the line \usepackage{html} after the documentclass line and the line \bodytext{BGCOLOR="\#ffffff"} after the \begin{document} line.

$FIGURE_SCALE_FACTOR = 1.6; -- scale factor applied to all images of figure and other environments, when being made into an image.

$MATH_SCALE_FACTOR = 1.6; -- scale factor applied to all images of mathematics, both inline and displayed.

$DISP_SCALE_FACTOR = 1; -- extra scale factor applied to images of displayed math environments. When set, this value multiplies $MATH_SCALE_FACTOR to give the total scaling. A value of `1.3' is a good choice to accompany $MATH_SCALE_FACTOR = 1.0;.

2010年06月03日 星期四 18:13

哈哈,有Tex群组了~~必顶!!!

2010年06月03日 星期四 18:16

一起交流经验吧。

2010年06月03日 星期四 18:19

当然~~

2010年06月03日 星期四 18:29

wonderful! Bill!

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2024

    京ICP备05028076号