Category Archives: LaTeX

JabRef – Bibliography interface to LaTeX

Anyone who has written any report with proper, formatted (as demanded by the international community) references, will agree that they are indeed a pain! JabRef is a nice attempt at solving this problem by using a database like approach to bibliography. This article will briefly explain how to get started.

Firstly, you can install it on Windows, download from website, and Ubuntu has it in its repos already πŸ™‚ (as usual!). The main concept is relatively simple. Start off by creating a new database, and adding bibtex entries to this. BibTeX entries are found in most places where you can download papers – IEEEXplore, ScienceDirect, Citeseer, etc. For IEEEXplore, Open link to paper, Download Citation, choose BibTeX and there you are!

For example, typically a transactions article in IEEEXplore would start with “@ARTICLE{5039…”. The first word after @ will help in choosing an appropriate datatype* which is asked the moment you click on add. Then you can just copy-paste the BibTeX entry in the BibTeX source, and the columns in the earlier tabs will be filled out for you. Once this is done I would recommend using a more sensible BibTeXkey rather than some arbitrary number.

So once you are done generating databases in JabRef, its time to add them. The best part here, is that it will add only the references that you have used \cite{key} for. Also, it will automatically order them at place of citation, i.e. early citations, smaller numbers, and so on.

At the place you need to put the bibliography (end) you write in your .tex file,
\bibliographystyle{bib style filename}
\bibliography{database1_name,database2_name}
Bibliography style files, have a .bst extension. Again, there is no need to put extensions, both in the style and the database names. Note that you also don’t need to use the standard \begin{thebibliography} part.

Now, in case you are using good old compilation from your terminal, you first need to call
$ bibtex filename (without extension)
$ pdflatex / latex filename.tex

LyX / Kile and others should be able to handle that directly I suppose.

That should get your references ready. In case the citations appear as [?] its because it requires another compilation! πŸ˜› The first compile checks what are being used, and creates a document ready to insert, and the second inserts.

* Am still wondering how to get the other datatypes to show the Conf title. Something is fishy. For now, “article” for everything works well.

UPDATE (15Jun10): I am now able to get all types working! For \documentclass[conference]{IEEEtran} I just needed to add
\bibliographystyle{IEEEtran}
\bibliography{reportbib}

where reportbib.bib was the flie managed by JabRef. I guess as long as the document class and the style are matching it should be able to generate the bibliography!

UPDATE (24Jan11): Use the curly braces {} to ensure capitalization is kept. Else the IEEEtran style along with JabRef is converting the entire title as a sentence for “article” type.
e.g. Paper about {MIMO} – would be the title in the JabRef to get an output as – “Paper about MIMO” and prevent “Paper about mimo”

Advertisements

Insert Movies in your PDF document – LaTeX

This post is because I see an increasing number of Google searches on “movie15” leading to my blog πŸ™‚ just because of the mention of the movie15 package in the LaTeX – Beamer tutorial.

So, inserting movies is very easy, nothing to fret! Just ensure that you have a PDF reader that supports multimedia. Adobe Reader 9 and Foxit Reader 3 does. Even the Portable Foxit Reader does the job, and it is pretty useful if you are taking your PDFs as presentations to different places.

So your document head should have the line \usepackage{movie15} followed by the standard \begin{document}.

Insertion of the movie is exactly like the insertion of a figure.
\begin{figure}[ht]
\includemovie[poster,text={\small(Loading Video...)}]{6cm}{4cm}{decoded_initial.avi}
\end{figure}

The poster options inserts the first frame of the video and then loads the movie clip, Loading Video… is that text which appears before the video loads in your PDF reader, 6cm is the width, 4cm is the height and decoded_initial.avi is the movie filename.

There are many more options to reference a movie, make it play, pause, etc. which can be found at the CTAN (Comprehensive TeX Archive Network). That page also gives a list of the supported video formats.

Give your PDF reader some time, and it should be able to render your video.

Short Tips on LaTeX

Hi
If you’ve followed the tutorial until here, you definitely should be able to produce really professional reports, and presentations too.

I would just like to add a few tips in this conclusive article.

  1. You can make single tex files for each chapter, bibliography, etc. and then merge them all using the \include{}.
  2. Cite (\cite{}) all your bibliography, DO NOT manually insert numbers. Also refer (\ref{}) to your labels in equations, figures, and tables.
  3. Hyperlinks can be inserted in your document in case necessary. Use package hyperref, and \href{<location>}{<text>}.
  4. Have a good look at the Page Layout given on pp. 119 of lshort. Modify your page dimensions with care. The no. of words used per line has been proven to be the most optimum scientifically.
  5. There exists a \begin{picture} environment, which you may need at times. Use it instead of importing images. Lots of drawing (technical) can be handled by LaTeX itself.
  6. Line spacing can be handled using\linespread{} which affects the entire document. Use {\setlength{\baselineskip}{1.5\baselineskip} and end with \par} instead.
  7. Use \vspace{} and \hspace{} sparingly as far as possible.
  8. You can generate a book like index entry by using the package \usepackage{makeidx} and then using a key like entry pattern \index{key}.
  9. Hyphen sizes can be varied by using them consecutively (max. upto 3).
  10. You can define your own control sequences like macros in C. For example \newcommand{\inftyint}{\int_{-\infty}^{+\infty}} puts the integral from negative infinity to positive infinity just by using \inftyint wherever required.
  11. \LaTeXe or \LaTeX generates the cute looking LaTeX symbol on your document. πŸ™‚

There are a lot of other support packages. Just to mention, some of them would be: games text support, music typesetting, pstricks, biological species names, chemical equations (with the conditions on arrow), etc.

A variety of languages are supported and can be typeset. Don’t be shocked, it includes Sanskrit! too.

For Windows users, install this thing called MikTeX, the compiler + TeXnic Center + Ghostgum & Ghostview (for ps files). Ubuntu (GNU/Linux) users can use texlive or the latex packages existing in their OS’s repositories.

LaTeX and Beamer (Presentations)

LaTeX is not just for reports, but is widely used in the professional (academic) community to make their ppts (in this case pdfs) too. This adaptation of the power of LaTeX is called Beamer.

Getting started with this is very very easy. Pull one of the presentations you find online, and modify the content. Then start modifying the themes, looks, etc. and you’ll find a wide variety of customization is available.

Of course, if you are a genius who can modify or understand .cls and .sty files, then there is nothing like it.

So getting started, the only difference is


\documentclass{beamer}
\usepackage{graphics} % for your images
\usepackage{beamerthemesplit} % this is a theme splitting option
\usepackage{hyperref} % hyperlinks
\usepackage{amsfonts} % advanced math fonts
\usepackage{movie15} % ah! embedding small video clips in pdfs. Yes, new pdf readers do play movies too.
\usepackage[english]{babel}
\usepackage[latin1]{inputenc}
\usepackage{times}
\usepackage[T1]{fontenc}


\usetheme{Darmstadt} % selection of themes
%\usefonttheme[onlylarge]{structurebold}
\setbeamerfont*{frametitle}{size=\normalsize,series=\bfseries}
\setbeamertemplate{navigation symbols}{}

etc. You can addon to these as you wish. Once this is done, you select a theme and then set your templates, as you like.

Again there is the standard \maketitle that can be used as follows.


\title{Project}
\subtitle{on}
\author{auth1 \and auth2}
\institute{XYZ} \\Β  {\includegraphics[height=2.3cm,width=2cm]{logo.ps}} \\Β  % in case you wish to put your institute logo
\date{}
\maketitle

Thats it, and you have your first title page ready. I specially like this arrangement wherein it makes links on top to your section heads in the presentation. Its a very nice concept, and replicating that in Powerpoint is not so easy.

Thats it, you have your base ready. Just start of as shown below and you’ll land with a professional looking (with good looking equations if required) presentation, which you can further Impress others by.


\section{Aim}
\begin{frame}{Slide Head}
\begin{block}{Block – 1}
\begin{itemize}
\item point 1
\item point 2
\end{itemize}
\end{block}
\begin{block}{Block – 2}
\begin{itemize}
\item point 1
\item point 2
\end{itemize}
\end{block}
\end{frame}

Multiple frames (slides) can come in one section, and an ideal of 2 – 3 blocks per frame make your slide really well partitioned and particular. Ofcourse there is no need to use blocks, and you can directly insert text or use itemize. Its up to you!

Note: The file is still called .tex, and is compiled as any other .tex document using any of miktex, latex, pdftex, etc.

Report Writing using LaTeX – III

Once the title page is done, the main part of the report writing is very easy. Start filling in the sections and chapters you’ve created. The main problem that you notice one faces is during insertion of images and tables.

Inserting images and tables in LaTeX is unfortunately a-not-so-trivial job. This is mainly because of the standards that LaTeX specifies for page margins, and borders, etc. Thus, if a figure / table doesn’t fit in, it automatically gets pushed to the next page. Note that, the figure and table has to fit along with the caption. It gets pushed to next page for such reasons too.

So, I generally follow a practice of putting the figures / tables at the beginning of the chapter / section, so as to then let LaTeX adjust with the spacing. Nevertheless, you may find entire single pages (in case your text part is less – like an observations section) containing your figure / table. These will be automatically centered.

Experience will get you approximate estimates, and you’ll start knowing which sort of image / table will fit in which place. So put it accordingly, before you start the text.

Another important point would be to insert a caption, and label for each of these figures and tables. A caption is a must in any sort of technical report. Note that LaTeX takes care of the numbering according to the chapter, automatically. Labels are useful when you want to reference to any figures or tables. So you would want to say, refer to Figure \ref{block_diag}, and it will automatically find the figure / table with label “block_diag” and insert its number in this location.

Similarly, you can also number your equations and refer to them, using \begin{equation} – \end{equation} mode instead of the standard $-based math mode.

You can also refer to sections and chapters, just insert your \label in appropriate places. This referral is a boon since, you may want a slight change in the structure at the end, which may cause a havoc in the numbering.

Report Writing using LaTeX – II

In view of the previous post, the importance of LaTeX for project reports is seen very clearly.

The main struggle will be in making the first page template, as this requires to be painstakingly manually formatted. This needs to be done by trial and error, by checking whether the required titles, or images (college logo, etc.) are fitting entirely or not. But once a general template is ready, one can use the \maketitle command (write a script) or just copy-paste this part of the tex file and change titles, authors, and possibly guides.

Ofcourse, as you would expect, getting all those italics, boldface, etc. changing fonts, changing sizes are an easy job, but need to be written like a script, as it gets processed and your document gets generated. That probably is the only drawback of this system. A powerful WYSIWYG is yet to be successfully implemented.

So once this is done, I would suggest, to start off with making chapters, and dividing your job into parts according to the work. These can be divided into sections, or maybe you want to write some text, and then do the division. Its upto you!

A sample title page would be something like this.


\begin{center}
\textbf{\LARGE{Title of Report}}\\
\vspace{3mm}

% optional
\normalsize{\textbf{Subject – Project REPORT}}\\
\vspace{0.7cm}

\normalsize{\textit{Submitted by}}\\

\begin{table}[h]
\begin{center}
\begin{tabular}{ccc} % no. of columns depending on no. of authors
\large{ABC} & \large{DEF} & \large{GHI} \\
REG1 & REG2 & REG3 \\
\end{tabular}
\end{center}
\end{table}

Under the guidance of \\
\large{\textbf{Prof.~XYZ}} \\
\vspace{1cm}

% College Logo (optional)
\begin{figure}[h]
\begin{center}
\label{nitk_logo}
\includegraphics[height=50mm,width=50mm]{logo.ps}
\end{center}
\end{figure}

\small{
DEPARTMENT~OF~XYZ\\
INSTITUTE~OR~COLLEGE~NAME~and~ADDRESS\\
\vspace{0.5cm}
\textbf{\normalsize{Year}}
}

Report Writing using LaTeX – I

LaTeX is a very famous typesetting tool used widely among technical and scientific report writing. Started by Donald Knuth as TeX, LaTeX is just one of the variants. In essence, it helps convert a normal text like document written in say notepad, to a beautifully formatted pdf, with a lot of functionality.

The main advantages of LaTeX can be put down as:

  1. Layout, Fonts, Tables, etc. remain consistent and you dont have to worry about them.
  2. Writing Mathematical formulae was never so easy πŸ™‚
  3. It generates the Table of Contents, Table of Figures, Footnotes, Bibliography, Citations to Bibliography, Figure and Table numbers, Chapter, Section, Subsection, Equation Numbers, etc. in a aesthetically pleasing and technically right way.
  4. Structuring of documents, purposely inserting page breaks etc. is not an issue anymore.
  5. Specially meant for changing the document style and submitting to journals / conferences which have a specific formatting. Its a change of 1 line job!
  6. And, to top it, its available across all widely used platforms.

The only disadvantages I can think of are:

  • Should have had a nice combination of a WYSIWYG and text mode (try LyX or TeXnic Centre or Kile)
  • Spelling check needs to be integrated (use aspell when on Linux)

This is not meant to be a comprehensive tutorial, as many can be found online, the most famous being

  • Getting started with LaTeX2e – a very good starter’s guide and
  • LaTeX 2e in Short (lshort)