Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run pdflatex quietly [closed]

Tags:

latex

pdflatex

I'm calling pdflatex from within my (C++) program using system(), needless to say all the garbage pdflatex puts on screen is a bit irritating in this case.

So...how do I encourage pdflatex to forego the lengthy outputs? It would be even better if only errors would be visible...

like image 555
NomeN Avatar asked Jun 24 '09 12:06

NomeN


People also ask

How do I close Pdflatex?

Actually, there is a civilized way to kill LaTeX, as asked by you. Enter x at the prompt, then press Enter . Pressing Ctrl-d may be even faster. Most terminals send en end-of-file with this keystroke, which makes LaTeX react in the same way as if x was entered.

How do I ignore an error in LaTeX?

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.

Is pdfTeX the same as Pdflatex?

are simply macro packages for TeX, they work equally well with pdfTeX. Hence, pdflatex , for example, calls the pdfTeX program using the standard LaTeX macros to typeset LaTeX documents, whereas it is the default rendering engine for ConTeXt documents.

Should I use Pdflatex or XeLaTeX?

PDFLaTeX is faster than XeLaTeX as you've noticed. It also currently has better support for certain advanced microtypographic features. (Margin kerning and the like.) And if you really want to confuse yourself, you could also be considering LuaLaTeX at this point too.


2 Answers

Unfortunately (La)TeX doesn't really abide by the rules of stdout and sterr, owing (I assume) to its origins in the early 80s. But there are some switches you can invoke to alter the amount of information being shown.

Execute latex with either the -interaction=nonstopmode or -interaction=batchmode switches for non-halting behaviour even in the case of a syntax error. nonstopmode will print all usual lines, it just won't stop. batchmode will suppress all but a handful of declarative lines ("this is pdfTeX v3.14...").

These can also be invoked from within the document with \batchmode and \nonstopmode, but this is less useful for the situation you're describing.

like image 175
Will Robertson Avatar answered Sep 22 '22 06:09

Will Robertson


To simply ignore all output, redirect pdflatex stdout to /dev/null:

system("pdflatex yourdocument >/dev/null"); 

You may want to add \nonstopmode at the beginning of your document to instruct tex to keep going even when encountering errors.

To get the error messages, pipe pdflatex output to your program and look for errors around rows starting with !, e.g.

FILE *outputf = popen("pdflatex yourdocument", "r");  // ... read and analyze output from outputf ...  pclose(outputf); 
like image 35
laalto Avatar answered Sep 21 '22 06:09

laalto