rem: fprintf (out, "\\end{longtable}\n"
add: fprintf (out, "\n\\end{longtable}\n"
context: gint latex_finish (){  fprintf (out, "\\end{longtable}\n"	   "\\end{document}\n");  fclose (out);  if ( system ( "latex -interaction=nonstopmode toto.tex" ) > 0 )    dialogue ( _("LaTeX run was unable to complete, see console output for details.") );  else     system ( "xdvi toto.dvi &" );    return 1;}