Installing Latex and Compiling a Latex Docuent in Linux

Latex is a popular document preparation system that is widely used for creating scientific and technical documents. Compiling Latex documents on Linux is a straightforward process that requires only a few Latex packages and a set of commands. By following the steps outlined in this post, you can easily compile Latex documents on your Linux system and customize the compilation process to suit your specific needs.

Installing Latex Packages

In Linux, the packages needed for compiling Latex documents can be easily installed by running the following command as root:

# yum install texlive* dvipdfmx

or

$ apt-get install texlive-full 

This command installs a comprehensive set of Latex packages and the dvipdfmx tool that is required for converting the DVI output of Latex to PDF format.

Compiling a Latex Document

Once you have installed the required packages, you can compile a Latex document by executing the following commands in the terminal:

$ latex doc
$ bibtex doc
$ latex doc
$ latex doc
$ dvips doc.dvi
$ ps2pdf doc.ps

In the above example, “doc” is the name of the Latex document that you want to compile. The latex command generates a DVI file from the Latex source code, while bibtex is used to generate a bibliography file if you are using any references. After running latex again, the document is processed once more to get the correct cross-references and page numbers. Finally, dvips generates a PostScript file, which is then converted to PDF format using ps2pdf.

Once the compilation process is complete, you should be able to find the generated PDF file in the same directory as the Latex source code.

Using a Makefile for Automatic Compilation

If you frequently compile Latex documents, you can simplify the process by using a Makefile. A Makefile is a script that automates the compilation process by specifying the dependencies between the different files.

A simple Makefile for automatically compiling a Latex document can be found from this post:

filename=MAIN_LATEX_FILE_NAME_WITHOUT_.tex

pdf: ps
    ps2pdf ${filename}.ps

pdf-print: ps
    ps2pdf -dColorConversionStrategy=/LeaveColorUnchanged -dPDFSETTINGS=/printer ${filename}.ps

text: html
    html2text -width 100 -style pretty ${filename}/${filename}.html | sed -n '/./,$$p' | head -n-2 >${filename}.txt

html:
    @#latex2html -split +0 -info "" -no_navigation ${filename}
    htlatex ${filename}

ps: dvi
    dvips -t letter ${filename}.dvi

dvi:
    latex ${filename}
    bibtex ${filename}||true
    latex ${filename}
    latex ${filename}

read:
    evince ${filename}.pdf &

aread:
    acroread ${filename}.pdf

clean:
    rm -f ${filename}.{ps,pdf,log,aux,out,dvi,bbl,blg}

The Makefile specifies the dependencies between the Latex source code, the bibliography file, and the generated PDF file. By running the make command in the terminal, you can automatically compile the Latex document without having to execute the individual commands manually.

Customizing ps2pdf Options

By default, the ps2pdf command used in the compilation process generates a PDF file with default options. However, you can customize the options used by ps2pdf by specifying additional arguments.

For example, to generate a PDF file with higher-quality images, you can use the following command:

$ ps2pdf -dPDFSETTINGS=/prepress doc.ps

This command generates a PDF file with higher resolution images and other settings suitable for prepross use.

Similar Posts

  • MFC程序使用系统风格界面

    VC6默认编译出来的程序在XP下Luma风格下运行也是Windows的经典界面, 有损界面的美观与统一. VC2008默认设置下如果不是使用的unicode也是如此. 本文给出使VC6和VC2008可以编译出使用系统界面风格的解决方案. 1. 使VC6编译出使用系统风格的程序 步骤如下: 1) 创建一个.manifest文件的资源. 在res/文件夹下创建一个跟以程序名加.manifest的文件, 如果程序为test.exe, 则创建test.exe.manifest 文件可由此下载: https://www.systutorials.com/t/g/programming/resultcollector.manifest/ 注意要使用utf-8编码保存。 2) 将新定义的资源加入到.rc2文件中, 类型设为24. 打开res/文件夹下的.rc2文件, 在其中加入如下定义: 1 24 MOVEABLE PURE “res/test.exe.manifest” 其中的文件地址按1)步中修改的设置即可. 之后编译即可, 为了使程序界面可能充分利用系统的界面特性, 可以将界面字体设置为TrueType类型的, 利用Windows XP等系统的屏幕字体平滑特性. 2. 使VC2008编译出使用系统风格的程序 在VC2008下就比较简单了, 如果程序字符集使用unicode则默认就是使用系统界面风格的, 如果选择其它的类型, 则编辑下stdafx.h即可. 最后面部分找到这么一段: #ifdef _UNICODE #if defined _M_IX86 #pragma comment(linker,”/manifestdependency:”type=’win32′ name=’Microsoft.Windows.Common-Controls’ version=’6.0.0.0′ processorArchitecture=’x86′ publicKeyToken=’6595b64144ccf1df’ language=’*'””) #elif defined _M_IA64 #pragma comment(linker,”/manifestdependency:”type=’win32’…

  • |

    How to check whether a file of a given path is a block device in Python?

    How to check and test whether a file of a given path is a block device in Python? This can be Linux specific. You can use the os.stat() function to get the stat of the path. Then use the stat.S_ISBLK() function against the stat’s .st_mode to test whether it is a block device. An example:…

  • Systems Conferences

    Which ones are good systems conferences? Top ones by ACM and USENIX: OSDI: https://www.usenix.org/conferences/byname/179 SOSP: http://sosp.org/ Other SIGOPS Events: http://www.sigops.org/conf-sponsored.html EuroSys: http://www.eurosys.org/ SoCC: http://www.socc2013.org/ (SoCC 2013) ASPLOS: http://www.sigplan.org/Conferences/ASPLOS/Main VEE: http://www.sigplan.org/vee.htm USENIX ATC: https://www.usenix.org/conferences/byname/131 NSDI: https://www.usenix.org/conferences/byname/178 IEEE Conferences: ICDCS: http://www.temple.edu/cis/icdcs2013/ (2013) IPDPS: http://www.ipdps.org/ Other related ones and workshops: HPCA: Search HPCA ConferenceSC: http://www.supercomp.org/IEEE CLUSTER: http://www.clustercomp.org/ HotCloud:…

  • |

    Dynamics CRM Consultants Explain How To Filter Sub Branch Lookup Field Value in CRM

    In this blog Dynamics CRM consultants are sharing a step-by-step guide to explain how to filter another lookup field value based on one Lookup field value. In this Lead entity, they are having two fields Branch and Sub Branch and you will learn how they filter Subbranch based on Branch field. Based on one Lookup…

  • Broken links checker for sites

    Tools to check broken links for websites. This tool is great for broken link checking: http://www.brokenlinkcheck.com/ . It check all your site automatically. W3C also has a tool to check a single page: http://validator.w3.org/checklink There is also an open-source tool LinkChecker: http://wummel.github.io/linkchecker/ If you are using WordPress, a plugin is also available: http://wordpress.org/plugins/broken-link-checker/ Read more:…

Leave a Reply

Your email address will not be published. Required fields are marked *