Difference between revisions of "Latex on Ubuntu"

From DiLab
Jump to: navigation, search
(Good resources)
(Using Latex)
 
(15 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{TocRight}}
This is what I did to get TeX/Latex working on Ubuntu 10.04. Note, this is not the only way...

Also, this may have some redundant packages.
== Latex setup on Ubuntu ==

Install some packages to get ''pdflatex'', ''xelatex'' and other tools for Latex support. I use xelatex for international text input (e.g. in Latvian).

sudo apt-get install texlive texlive-latex-extra texlive-xetex texlive-fonts-recommended
sudo apt-get install texlive-publishers


There is a Winefish program to edit the latex files, but you can do it using gedit or emacs if you know most of the commands or have a good example or template. A good editor would have syntax highlighting and auto spell-check.
There is a Winefish program to edit the latex files, but you can do it using gedit or emacs if you know most of the commands or have a good example or template. A good editor would have syntax highlighting and auto spell-check.


== Using Latex ==
Install some packages to get ''pdflatex'' and other tools. Note, there is no package named ''pdflatex''.


You can create a pdf document from TeX like this
sudo apt-get install tex-common
sudo apt-get install texlive-latex-base
sudo apt-get install texlive-latex-extra


pdflatex mydoc.tex
Get some fonts to avoid the infamous missing 'ptmri7t' error.


I find it useful having [[LATEX::Makefile | my Latex Makefile]] that will do this, cleaning up the log files and some other tasks.
sudo apt-get install texlive-fonts-recommended
Here is a simple makefile example:


BASE_NAME=main
all:
xelatex $(BASE_NAME).tex
bibtex $(BASE_NAME)
xelatex $(BASE_NAME).tex
xelatex $(BASE_NAME).tex
clean:
rm -f $(BASE_NAME).pdf *.aux *.bbl *.dvi *.log *.blg


== LATEX with IDE (CodeBlocks) ==
You can create the pdf document from TeX like this


Sometimes I have many tex files that make up a latex document.
pdflatex mydoc.tex
Therefore it is useful to have a project and a sort of friendly integrated development environment (IDE).
Some editors such as LED incorporate a multiple file management features.
IDE however may allow for more flexibility, and is not limited to tex file editing and building.
There are several out there, such as
[http://www.eclipse.org/ Eclipse],
[http://eclipse-latex.sourceforge.net/ LaPsE],
[http://texlipse.sourceforge.net/ TeXlipse],
and
[http://www.codeblocks.org/ Code::Blocks].

The following is a short how-to for using Code::Blocks (CB) for the task. Get CB first:
sudo apt-get install codeblocks
I use a Makefile to custom build my latex pdf targets.
* Configure CB to use a Makefile: enable '''Menu->Project->Properties->"This is a custom makefile"''' checkbox.
* Create build targets under '''Menu->Project->Properties->Build Targets'''.
** I have "''final''" as the main target from the Makefile.
** In addition I specify the directory name where the source files are. I have a special support in my makefile that filters the command line goals against the subdirectories. For example, if my files are in the ''MyPaper'' directory, then the target is ''final MyPaper''. BTW, you could make the document without the IDE from command line like this "make final MyPaper".

* To start the pdf viewer using the IDE's "Run" option, my Makefile has a ''viewpdf'' target that generates a shell script ''viewpdf.sh''. Place this file name under the project options for the executable for the target: '''Menu->Project->Properties->Build Targets->Output Filename'''

* And, obviously, you need to add the source files to the project in IDE for the convenient access and editing.

Finally,
'''[[LATEX::Makefile | here is my Makefile]]'''
for building latex documents.


I find it useful creating a makefile that will do this and some other tasks, such as cleaning up the log files and such.


== Good resources ==
== Good resources ==

* in general: http://en.wikibooks.org/wiki/LaTeX
* in general: http://en.wikibooks.org/wiki/LaTeX
* Fonts and text size: http://en.wikibooks.org/wiki/LaTeX/Formatting#Font_Styles_and_size
* Fonts and text size: http://en.wikibooks.org/wiki/LaTeX/Formatting#Font_Styles_and_size

Latest revision as of 20:00, 24 February 2012

Latex setup on Ubuntu

Install some packages to get pdflatex, xelatex and other tools for Latex support. I use xelatex for international text input (e.g. in Latvian).

sudo apt-get install texlive texlive-latex-extra texlive-xetex texlive-fonts-recommended
sudo apt-get install texlive-publishers

There is a Winefish program to edit the latex files, but you can do it using gedit or emacs if you know most of the commands or have a good example or template. A good editor would have syntax highlighting and auto spell-check.

Using Latex

You can create a pdf document from TeX like this

pdflatex mydoc.tex

I find it useful having my Latex Makefile that will do this, cleaning up the log files and some other tasks. Here is a simple makefile example:

BASE_NAME=main

all:
	xelatex $(BASE_NAME).tex
	bibtex $(BASE_NAME)
	xelatex $(BASE_NAME).tex
	xelatex $(BASE_NAME).tex

clean:
	rm -f $(BASE_NAME).pdf *.aux *.bbl *.dvi *.log *.blg

LATEX with IDE (CodeBlocks)

Sometimes I have many tex files that make up a latex document. Therefore it is useful to have a project and a sort of friendly integrated development environment (IDE). Some editors such as LED incorporate a multiple file management features. IDE however may allow for more flexibility, and is not limited to tex file editing and building. There are several out there, such as Eclipse, LaPsE, TeXlipse, and Code::Blocks.

The following is a short how-to for using Code::Blocks (CB) for the task. Get CB first:

sudo apt-get install codeblocks

I use a Makefile to custom build my latex pdf targets.

  • Configure CB to use a Makefile: enable Menu->Project->Properties->"This is a custom makefile" checkbox.
  • Create build targets under Menu->Project->Properties->Build Targets.
    • I have "final" as the main target from the Makefile.
    • In addition I specify the directory name where the source files are. I have a special support in my makefile that filters the command line goals against the subdirectories. For example, if my files are in the MyPaper directory, then the target is final MyPaper. BTW, you could make the document without the IDE from command line like this "make final MyPaper".
  • To start the pdf viewer using the IDE's "Run" option, my Makefile has a viewpdf target that generates a shell script viewpdf.sh. Place this file name under the project options for the executable for the target: Menu->Project->Properties->Build Targets->Output Filename
  • And, obviously, you need to add the source files to the project in IDE for the convenient access and editing.

Finally, here is my Makefile for building latex documents.


Good resources