Compiling a LaTeX Document.

So having prepared your first tex document I was pretty excited to see the out put. But there was one daunting question !!
Whats the next step ??

Fortunately , I was using KILE so I got my PDF in a click but I wanted to figure out how get the same pdf using command line.
So here is the procedure to do the same:



Suppose the file ``my_report.tex” is the file that contains all the author’s work, i.e., her actual typed words and formulae. It was typed using the text editor vi. Similar text editors include emacs, pico, Notepad (in Windows), and TextEdit (on Macs).

First navigate to the place where the tex file is located using terminal.

Then run the command:

latex my_report.tex

This produces a bunch of files. One of them would be my_report.dvi.
The dvi stands for “device independent”.

The file my_report.dvi is the same regardless of

(1) which computer is used to compile the document,

(2) what kind of printer it is headed for.

In fact, it is too universal to be printed in this form; it must still be translated to a form suitable for a specific kind of printer. (Different printers speak different languages…) You can’t even view the DVI file unless you use a special “DVI Viewer”, such as xdvi on ucsub.


The files“my_report.aux” and  “my_reoprt.log” are two by-products of the compiling command.
The aux file is used if the document contains more complicated stuff, like bibliography and cross-references.

The log file contains a full record of the compilation, including errors you need to correct, e.g., misspelled macros, missing bracket or parenthesis, missing references, etc.



The file “”, a PostScript file, the kind understood by most laser printers.
A printable PostScript file is created from the dvi file by the translating program dvips. On computer run the command

dvips my_report.dvi



The file ``my_report.pdf” is the PDF form of the document.
This is as web-friendly a document as possible. Using Acrobat Reader, any computer can be used to view the document and/or print it. On computer run the command the command

dvipdfm my_report.dvi

translated the DVI file to PDF form.


Thats it !!


Hope it helps. !!

Special Characters and Symbols in LaTeX

Following is the way to use special characters and symbols while creating a document using LaTeX:



Symbol/Character Way to get it in LaTeX
Quotation Marks two ` (grave accent) for opening quotation marks.
two ‘ (vertical quote) for closing quotation marks.

Dashes and Hyphens L TEX knows four kinds of dashes. Access three of them with different number
of consecutive dashes. The fourth sign is actually not a dash at all—it is the
mathematical minus sign.
The names for these dashes are: ‘-’ hyphen, ‘–’ en-dash, ‘—’ em-dash
and ‘−’ minus sign.

Examples of each are shown below:

  • daughter-in-law —-> daughter-in-law
  • pages 13–67 —-> pages 13–67
  • yes—or no? —-> yes—or no?
  • $0$, $1$ and $-1$ —-> 0, 1 and −1
Tilde (∼) $\sim$demo
Slash (/) \slash
Degree Symbol (◦)

The textcomp package makes the degree symbol also available as \textdegree
or in combination with the C by using the \textcelsius.

The Euro Currency Symbol


NOTE: its available in textcomp package

Ellipsis (. . . )

On a typewriter, a comma or a period takes the same amount of space as
any other letter. In book printing, these characters occupy only a little space
and are set very close to the preceding letter. Therefore, entering ‘ellipsis’
by just typing three dots would produce the wrong result. Instead, there is
a special command for these dots. It is called



Some letter combinations are typeset not just by setting the different letters
one after the other, but by actually using special symbols.

These so-called ligatures can be prohibited by inserting an \mbox{} between
the two letters in question. This might be necessary with words built from
two words.

1 \Large Not shelfful\\
2 but shelf\mbox{}ful

1.Not shelfful
2. but shelfful

Western european special characters and how to enter them from your keyboard

HTML Name Code HTML Number Code Glyph MacOS Windows Description
‘ option+] Alt+0145 left single quote
’ shift+option+] Alt+0146 right single quote
‚ single low-9 quote
“ option+[ Alt+0147 left double quote
” shift+option+[ Alt+0148 right double quote
„ shift+option+w double low-9 quote
† option+t Alt+0134 dagger
‡ shift+option+7 Alt+0135 double dagger
option+; horizontal ellipsis
‰ shift+option+r Alt+0137 per mill sign
‹ shift+option+3 Alt+0139 single left-pointing angle quote
› shift+option+4 Alt+0155 single right-pointing angle quote
♠ black spade suit
♣ black club suit
♥ black heart suit
♦ black diamond suit
‾ overline, = spacing overscore
← leftward arrow
↑ upward arrow
→ rightward arrow
↓ downward arrow
™ option+2 Alt+0153 trademark sign
" " double quotation mark
& & & ampersand
&lt; < < less-than sign
&gt; > > greater-than sign
[ [ left square bracket
] ] right square bracket
&ndash; option+hyphen Alt+0150 en dash
&mdash; shift+option+hyphen Alt+0151 em dash
&nbsp;   Alt+0160 nonbreaking space
&iexcl; ¡ ¡ option+1 Alt+0161 inverted exclamation
&cent; ¢ ¢ option+4 Alt+0162 cent sign
&pound; £ £ option+3 Alt+0163 pound sterling
&curren; ¤ ¤ Alt+0164 general currency sign
&yen; ¥ ¥ option+y Alt+0165 yen sign
&brvbar; or &brkbar; ¦ ¦ Alt+0166 broken vertical bar
&sect; § § option+6 Alt+0167 section sign
&uml; or &die; ¨ ¨ shift+option+u Alt+0168 umlaut
&copy; © © option+g Alt+0169 copyright
&ordf; ª ª option+9 Alt+0170 feminine ordinal
&laquo; « « option+\ Alt+0171 left angle quote
&not; ¬ ¬ option+l Alt+0172 not sign
&shy; ­ ­ Alt+0173 soft hyphen
&reg; ® ® option+r Alt+0174 registered trademark
&macr; or &hibar; ¯ ¯ Alt+0175 macron accent
&deg; ° ° shift+option+8 Alt+0176 degree sign
&plusmn; ± ± shift+option+= Alt+0177 plus or minus
&sup2; ² ² Alt+0178 superscript two
&sup3; ³ ³ Alt+0179 superscript three
&acute; ´ ´ shift+option+e Alt+0180 acute accent
&micro; µ µ option+m Alt+0181 micro sign
&para; option+7 Alt+0182 paragraph sign
&middot; · · shift+option+9 Alt+0183 middle dot
&cedil; ¸ ¸ shift+option+z Alt+0184 cedilla
&sup1; ¹ ¹ Alt+0185 superscript one
&ordm; º º option+0 Alt+0186 masculine ordinal
&raquo; » » shift+option+\ Alt+0187 right angle quote
&frac14; ¼ ¼ Alt+0188 one-fourth
&frac12; ½ ½ Alt+0189 one-half
&frac34; ¾ ¾ Alt+0190 three-fourths
&iquest; ¿ ¿ shift+option+? Alt+0191 inverted question mark
&Agrave; À À option+` A Alt+0192 uppercase A, grave accent
&Aacute; Á Á option+e A Alt+0193 uppercase A, acute accent
&Acirc; Â Â option+i A Alt+0194 uppercase A, circumflex accent
&Atilde; Ã Ã option+n A Alt+0195 uppercase A, tilde
&Auml; Ä Ä option+u A Alt+0196 uppercase A, umlaut
&Aring; Å Å shift+option+a Alt+0197 uppercase A, ring
&AElig; Æ Æ shift+option+’ Alt+0198 uppercase AE
&Ccedil; Ç Ç shift+option+c Alt+0199 uppercase C, cedilla
&Egrave; È È option+` E Alt+0200 uppercase E, grave accent
&Eacute; É É option+e E Alt+0201 uppercase E, acute accent
&Ecirc; Ê Ê option+i E Alt+0202 uppercase E, circumflex accent
&Euml; Ë Ë option+u E Alt+0203 uppercase E, umlaut
&Igrave; Ì Ì option+` I Alt+0204 uppercase I, grave accent
&Iacute; Í Í option+e I Alt+0205 uppercase I, acute accent
&Icirc; Î Î option+i I Alt+0206 uppercase I, circumflex accent
&Iuml; Ï Ï option+u I Alt+0207 uppercase I, umlaut
&ETH; Ð Ð Alt+0208 uppercase Eth, Icelandic
&Ntilde; Ñ Ñ option+n N Alt+0209 uppercase N, tilde
&Ograve; Ò Ò option+` O Alt+0210 uppercase O, grave accent
&Oacute; Ó Ó option+e O Alt+0211 uppercase O, acute accent
&Ocirc; Ô Ô option+i O Alt+0212 uppercase O, circumflex accent
&Otilde; Õ Õ option+n O Alt+0213 uppercase O, tilde
&Ouml; Ö Ö option+u O Alt+0214 uppercase O, umlaut
&times; × × Alt+0215 multiplication sign
&Oslash; Ø Ø shift+option+o Alt+0216 uppercase O, slash
&Ugrave; Ù Ù option+` U Alt+0217 uppercase U, grave accent
&Uacute; Ú Ú option+e U Alt+0218 uppercase U, acute accent
&Ucirc; Û Û option+i U Alt+0219 uppercase U, circumflex accent
&Uuml; Ü Ü option+u U Alt+0220 uppercase U, umlaut
&Yacute; Ý Ý Alt+0221 uppercase Y, acute accent
&THORN; Þ Þ Alt+0222 uppercase THORN, Icelandic
&szlig; ß ß option+s Alt+0223 lowercase sharps, German
&agrave; à à option+` a Alt+0224 lowercase a, grave accent
&aacute; á á option+e a Alt+0225 lowercase a, acute accent
&acirc; â â option+i a Alt+0226 lowercase a, circumflex accent
&atilde; ã ã option+n a Alt+0227 lowercase a, tilde
&auml; ä ä option+u a Alt+0228 lowercase a, umlaut
&aring; å å option+a Alt+0229 lowercase a, ring
&aelig; æ æ option+’ Alt+0230 lowercase ae
&ccedil; ç ç option+c Alt+0231 lowercase c, cedilla
&egrave; è è option+` e Alt+0232 lowercase e, grave accent
&eacute; é é option+e e Alt+0233 lowercase e, acute accent
&ecirc; ê ê option+i e Alt+0234 lowercase e, circumflex accent
&euml; ë ë option+u e Alt+0235 lowercase e, umlaut
&igrave; ì ì option+` i Alt+0236 lowercase i, grave accent
&iacute; í í option+e i Alt+0237 lowercase i, acute accent
&icirc; î î option+i i Alt+0238 lowercase i, circumflex accent
&iuml; ï ï option+u i Alt+0239 lowercase i, umlaut
&eth; ð ð Alt+0240 lowercase eth, Icelandic
&ntilde; ñ ñ option+n n Alt+0241 lowercase n, tilde
&ograve; ò ò option+` o Alt+0242 lowercase o, grave accent
&oacute; ó ó option+e o Alt+0243 lowercase o, acute accent
&ocirc; ô ô option+i o Alt+0244 lowercase o, circumflex accent
&otilde; õ õ option+n o Alt+0245 lowercase o, tilde
&ouml; ö ö option+u o Alt+0246 lowercase o, umlaut
&divide; ÷ ÷ Alt+0247 division sign
&oslash; ø ø option+o Alt+0248 lowercase o, slash
&ugrave; ù ù option+` u Alt+0249 lowercase u, grave accent
&uacute; ú ú option+e u Alt+0250 lowercase u, acute accent
&ucirc; û û option+i u Alt+0251 lowercase u, circumflex accent
&uuml; ü ü option+u u Alt+0252 lowercase u, umlaut
&yacute; ý ý Alt+0253 lowercase y, acute accent
&thorn; þ þ Alt+0254 lowercase thorn, Icelandic
&yuml; ÿ ÿ option+u y Alt+0255 lowercase y, umlaut

Basic LaTex document classes

Document Class Name Usage/meaning
 article for articles in scientific journals, presentations, short reports, pro-
gram documentation, invitations, . . .
 proc  a class for proceedings based on the article class.
 minimal is as small as it can get. It only sets a page size and a base font. It
is mainly used for debugging purposes.
 report  for longer reports containing several chapters, small books, PhD
theses, . . .
 book  for real books
 slides   for slides. The class uses big sans serif letters. You might want to
consider using the Beamer class instead.

Standard String Library functions in string.h in C

strlen Finds the length of the string.
strlwr Converts string to lower case.
strupr Converts string to upper case.
strcat Appends one string at end of another.
strncat Appends first n characters of a string at end of another.
strcpy Copies a string to another.
strncpy Copies first n characters of a string into another.
strcmp Compares two strings
strncmp Compares first n characters of two strings.
strcmpi Compares two strings without regards to case.
stricmp Compares two strings without regards to case.
strnicmp Compares first n characters of a string without regards to case.
strdup Duplicates a string.
strchr Finds first occurrence of a given character in a string.
strrchr Finds last occurrence of a given character in a string.
strstr Finds first occurrence of a given string in a string.
strset Sets all characters of a string to given character.


strnset Sets first n characters of a string to given character.
strrev Reverses the string.

Conditional Compilation in C

C provides a very useful and interesting feature called “conditional Compilation

the general structure for doing it:

#ifdef macroname

statement 1;
statement 2;
statement 3;
statement 4;

here if macroname has been #defined then the 4 statements will be compiled otherwise not.

There are 3 scenarios where I see application of this feature:

-> To “comment out” obselete lines of code. It may happen that a program undergoes a change for some reasons.
Here we may not want to delete the old code but add new code.
In this scenario, we can include the old and new code in ifdef block and control the compilation using a single #define statement.


void main()

#ifdef OLD
statement 1;
statement 2;
statement 3;
statement 4;



here , if we define thee macro “OLD” then old code is compiled otherwise, the new code is compiled.

->The other (more sophisticated) use of this feature can be to make the programs more portable.
Thus, we can make use of this feature and make a program work on two completely different computers.


void main()
#ifdef INTEL
code for intel PC
code for motorola PC
code common for both.


This code is pretty self explanatory.
If you want your code to run on INTEL we just need to define a macro.

->A third possible scenario is defining of custom functions.
Lets say we define a function called “my_sample_function()” in a file “file1.h”
Also, “file1.h” is included in “file2.h

If we include both the files, compiler will throw an error saying “multiple declaration of my_sample_function()

To overcome this problem, we can use the following way:

/* file1.h */

#ifndef _file
#define _file
/*some code */

Here when file1.h gets included first time, compiler knows that macro _file is not defined. Thus it gets defined and the rest of code is compiled.
Next time, since the macro stands defines, the function does not get compiled and thus there is no error.

NOTE: #ifndef is exactly opposite of #ifdef


Conditional compilation can also be achieved using #if ,#else #endif statements.

#if is used to evaluate whether a expression evaluated to nonzero value or not.

it is used in the same way as above:



void main(){

if TEST<=5

statment 1;


statement 2;



Ways to include a file in C

There are two ways of including a file in C using #include statement:

#include “filename”

This command would look for the file in the current directory as well as the specified list of directories as mentioned in the include search path that might have been setup.


#include <filename>

This command would look for the file on the specified list of directories only.




Advantages and Disadvantages of LaTex

The main advantages of LaTeX over normal word processors are the following:

  •   Professionally crafted layouts are available, which make a document really look as if “printed.”
  •   The typesetting of mathematical formulae is supported in a convenient way.
  •   Users only need to learn a few easy-to-understand commands that specify the logical structure of a document. They almost never need to tinker with the actual layout of the document.
  •   Even complex structures such as footnotes, references, table of contents, and bibliographies can be generated easily.
  •   Free add-on packages exist for many typographical tasks not directly supported by basic L TEX. For example, packages are available to include PostScript graphics or to typeset bibliographies conforming to exact standards.
  •   LaTeX encourages authors to write well-structured texts, because this is how L TEX works—by specifying structure.TEX, the formatting engine of LaTeX 2ε , is highly portable and free. Therefore the system runs on almost any hardware platform available.

The main dis-advantages of LaTeX over normal word processors are the following:

  • LaTeX does not work well for people who have sold their souls . . .
  •  Although some parameters can be adjusted within a predefined document layout, the design of a whole new layout is difficult and takes a
  • lot of time.
  •  It is very hard to write unstructured and disorganized documents.
  •  Your hamster might, despite some encouraging first steps, never be able to fully grasp the concept of Logical Markup.

Datatypes in C

Datatypes sumary in C:

Data Type Range Bytes Format
 signed char -128 to +127  1 %c
 unsigned char  0 to 255  1 %c
 short signed int -32768 to +32767 2 %d
 short unsigned int 0 to 65535 2 %u
signed int  -32768 to +32767  2 %d
 unsigned int 0 to 65535  2  %u
 long signed int  -2147483648 to +2147483647 4 %ld
 long unsigned int 0 to 4294967295 4 %lu
float  -3.4e38 to +3.4e38  4  %f
 double  -1.7e308 to +1.7e308  8  %lf
 long double  -1.7e4932 to +1.7e4932  10  %Lf
-32768 to +32767 2 %d
The sizes and ranges of int,short and long are compiler dependent. The above data is for 16 bit compiler.

Adding Functions to Library in C

This might be known to many but  I recently tried it and got it working.

Suppose you make a function in C(for example here we take a simple function which calculates the square of a number).

Its a fairly simple one and I want to add in in a library thus making its reuse possible.

(Please note I am taking a very simple scenario because the actual program is not the point of focus here, but the procedure is)

The function:

int square(int n)


return n*n;


Compile the file:

Compile the file in which you have written this function. Lets call it “sqr.c”. A new file called “sqr.obj” is created contained compiled code.

Add the function to Library:

Add the function to the library “maths.lib” using the following command.

C:\>tlib maths.lib + c:\sqr.obj

Please note the paths. Your paths may be different than mine!

here, maths.lib is the library and + is a switch which indicates that we want to add a new function to the library and the object file is at the given path.

Header file:

Add the prototype of square() function in a header file (lets say “square.h”) This file should be included in the program where we want to use the function. we can use it as:

#include “c:\square.h”

Thats all !

Use the function and enjoy !!

Hope it helps.