How can I ignore latex error while compiling?

What I would advise you is to use this;

latex -interaction nonstopmode -halt-on-error -file-line-error filename.tex

Specifying -interaction nonstopmode is equivalent to using \nonstopmode in your document.

The -halt-on-error option instructs the program to return a non-zero error code when an error is found. This is useful when you are e.g. calling latex from a script or from the make utility. Using make or an equivalent program like e.g. scons is highly recommended for larger documents that have an index or use citations. Because in those cases you will not only have to call LaTeX but also the programs to generate an index and bibliography.

The -file-line-error option is makes it easier to locate errors in your source files, especially when you use \include to e.g. split up a long document into parts (like splitting a book into chapters and putting each chapter in a separate TeX file.

Here is a Makefile fragment that I use for big LaTeX documents;

$(DOCPDF): $(SUBDIR) $(TEXSRC) lbref.bib .git/index
        sh tools/vc -m
        python tools/mkhistory.py hist.tex
        pdflatex --interaction nonstopmode -halt-on-error -file-line-error $*.tex # >/dev/null
        makeindex -c -s myindex.ist $*.idx #2>/dev/null
        bibtex $* #>/dev/null
        pdflatex --interaction nonstopmode -halt-on-error -file-line-error $*.tex #>/dev/null
        makeindex -c -s myindex.ist $*.idx #2>/dev/null
        pdflatex  --interaction nonstopmode -halt-on-error -file-line-error $*.tex #>/dev/null
        rm -f $*.lo* *.aux $*.ilg $*.ind $*.toc $*.bbl $*.blg $*.out *.asc

The first line specifies that the commands have to be carried out when either the tex source document (the TEXSRC variable), the bibliography database (lbref.bib) or the revision control status (.git/index) has changed. The first two commands add the revision number to the document and add a list of changes. After that it calls pdflatex a couple of times interspersed with calls to makeindex and bibtex. Several calls to LaTeX are generally necessary to resolve and stabilize all references when using makeindex.

Edit: I've switched to using latexmk because it will automatically take care of resolving cross-references, bibliographies and such.

So I've modified my Makefile:

SUBDIR= figuren lam calc grafieken
OUTDIR= uitvoer
DOCPDF = $(DOCSRC:.tex=.pdf)

# This is the first target in the Makefile.
all:  $(DOCPDF)

PDFLATEX= xelatex -interaction nonstopmode -halt-on-error -file-line-error
$(DOCPDF): $(SUBDIR) $(TEXSRC) lbref.bib .git/index
        -latexmk -bibtex -recorder -outdir=$(OUTDIR) -auxdir=$(OUTDIR) -pdflatex="$(PDFLATEX)" -pdf $(DOCSRC) 2>&1|grep -C12 '^l\.'
        mv  $(OUTDIR)/$(DOCPDF) .

${SUBDIR}::
        cd ${.TARGET}; make ${.TARGETS}

I've switched to xelatex for its simpler font handling. All the output files are now put in a subfirectory as to not clutter the main directory and for easier cleaning. Only the resulting PDF file is moved to the main directory after it has been created.


Try

latex -interaction=nonstopmode foo.tex