diff --git a/Common/Context.h b/Common/Context.h
index 4101c531722201b7cdd6f25f5dc0637357113548..627a195d4c1cf41d4c4f53dd3b3c2fe1f045cc5e 100644
--- a/Common/Context.h
+++ b/Common/Context.h
@@ -218,7 +218,7 @@ public :
     int jpeg_quality, jpeg_smoothing;
     int gif_dither, gif_sort, gif_interlace, gif_transparent;
     int geo_labels;
-    int text;
+    int text, tex_as_equation;
   } print;
 
   // color options
diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h
index fa910342e20c60cc81871716551650cd13157d3d..dc1a254d33051c031025bce01917ceee8a29f3e0 100644
--- a/Common/DefaultOptions.h
+++ b/Common/DefaultOptions.h
@@ -1396,6 +1396,8 @@ StringXNumber PrintOptions_Number[] = {
   { F|O, "JpegSmoothing" , opt_print_jpeg_smoothing , 0. ,
     "JPEG smoothing (between 0 and 100)" },
 
+  { F|O, "TexAsEquation" , opt_print_tex_as_equation , 0. ,
+    "Print all TeX strings as equations" },
   { F|O, "Text" , opt_print_text , 1. ,
     "Print text strings?" },
 
diff --git a/Common/Options.cpp b/Common/Options.cpp
index 9ec23026a9b01e4e8fb0d134176b2f77dec2e8f5..3741abb7d9f7333e736913c2dd91bd6edf0c77e1 100644
--- a/Common/Options.cpp
+++ b/Common/Options.cpp
@@ -1,4 +1,4 @@
-// $Id: Options.cpp,v 1.345 2007-05-24 17:34:03 geuzaine Exp $
+// $Id: Options.cpp,v 1.346 2007-06-22 08:07:45 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -7069,6 +7069,13 @@ double opt_print_text(OPT_ARGS_NUM)
   return CTX.print.text;
 }
 
+double opt_print_tex_as_equation(OPT_ARGS_NUM)
+{
+  if(action & GMSH_SET)
+    CTX.print.tex_as_equation = (int)val;
+  return CTX.print.tex_as_equation;
+}
+
 // Color option routines
 
 #if defined(HAVE_FLTK)
diff --git a/Common/Options.h b/Common/Options.h
index 271b7d5422ee7f368916da8224d657afff2cbe23..2115dd4360dce8c76cf3b0425b2cbb79258e6930 100644
--- a/Common/Options.h
+++ b/Common/Options.h
@@ -648,6 +648,7 @@ double opt_print_gif_sort(OPT_ARGS_NUM);
 double opt_print_gif_interlace(OPT_ARGS_NUM);
 double opt_print_gif_transparent(OPT_ARGS_NUM);
 double opt_print_text(OPT_ARGS_NUM);
+double opt_print_tex_as_equation(OPT_ARGS_NUM);
 
 // COLORS
 
diff --git a/Fltk/Callbacks.cpp b/Fltk/Callbacks.cpp
index 83e30ad9a20fe30a655cc075ec0475525c53c494..a9de7b2c082f400c2ee130cfe23ddb3b9632e959 100644
--- a/Fltk/Callbacks.cpp
+++ b/Fltk/Callbacks.cpp
@@ -1,4 +1,4 @@
-// $Id: Callbacks.cpp,v 1.532 2007-05-24 17:34:03 geuzaine Exp $
+// $Id: Callbacks.cpp,v 1.533 2007-06-22 08:07:45 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -676,7 +676,7 @@ int _save_vrml(char *name){ return generic_mesh_dialog(name, "VRML Options", FOR
 int _save_eps(char *name){ return gl2ps_dialog(name, "EPS Options", FORMAT_EPS); }
 int _save_gif(char *name){ return gif_dialog(name); }
 int _save_jpeg(char *name){ return jpeg_dialog(name); }
-int _save_tex(char *name){ CreateOutputFile(name, FORMAT_TEX); return 1; }
+int _save_tex(char *name){ return latex_dialog(name); }
 int _save_pdf(char *name){ return gl2ps_dialog(name, "PDF Options", FORMAT_PDF); }
 int _save_png(char *name){ return generic_bitmap_dialog(name, "PNG Options", FORMAT_PNG); }
 int _save_ps(char *name){ return gl2ps_dialog(name, "PS Options", FORMAT_PS); }
diff --git a/Fltk/GUI_Extras.cpp b/Fltk/GUI_Extras.cpp
index b6c202c0ffc252e4869bf25dd137ee0408b357de..08f7557a9bb0dc07db7544bf972cb744cd1cefec 100644
--- a/Fltk/GUI_Extras.cpp
+++ b/Fltk/GUI_Extras.cpp
@@ -1,4 +1,4 @@
-// $Id: GUI_Extras.cpp,v 1.35 2007-06-12 07:04:08 geuzaine Exp $
+// $Id: GUI_Extras.cpp,v 1.36 2007-06-22 08:07:46 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -271,6 +271,59 @@ int generic_bitmap_dialog(char *name, char *title, int format)
   return 0;
 }
 
+// TeX dialog
+
+int latex_dialog(char *name)
+{
+  struct _latex_dialog{
+    Fl_Window *window;
+    Fl_Check_Button *b;
+    Fl_Button *ok, *cancel;
+  };
+  static _latex_dialog *dialog = NULL;
+
+  const int BH = 2 * GetFontSize() + 1;
+  const int BB = 7 * GetFontSize() + 9;
+  const int WB = 7;
+
+  if(!dialog){
+    dialog = new _latex_dialog;
+    int h = 3 * WB + 2 * BH, w = 2 * BB + 3 * WB, y = WB;
+    // not a "Dialog_Window" since it is modal 
+    dialog->window = new Fl_Double_Window(w, h, "LaTeX Options");
+    dialog->window->box(GMSH_WINDOW_BOX);
+    dialog->b = new Fl_Check_Button(WB, y, 2 * BB + WB, BH, "Print strings as equations"); y += BH;
+    dialog->b->type(FL_TOGGLE_BUTTON);
+    dialog->ok = new Fl_Return_Button(WB, y + WB, BB, BH, "OK");
+    dialog->cancel = new Fl_Button(2 * WB + BB, y + WB, BB, BH, "Cancel");
+    dialog->window->set_modal();
+    dialog->window->end();
+    dialog->window->hotspot(dialog->window);
+  }
+  
+  dialog->b->value(CTX.print.tex_as_equation);
+  dialog->window->show();
+
+  while(dialog->window->shown()){
+    Fl::wait();
+    for (;;) {
+      Fl_Widget* o = Fl::readqueue();
+      if (!o) break;
+      if (o == dialog->ok) {
+	opt_print_tex_as_equation(0, GMSH_SET | GMSH_GUI, (int)dialog->b->value());
+	CreateOutputFile(name, FORMAT_TEX);
+	dialog->window->hide();
+	return 1;
+      }
+      if (o == dialog->window || o == dialog->cancel){
+	dialog->window->hide();
+	return 0;
+      }
+    }
+  }
+  return 0;
+}
+
 // Save jpeg dialog
 
 int jpeg_dialog(char *name)
diff --git a/Fltk/GUI_Extras.h b/Fltk/GUI_Extras.h
index 4836ab0202305acf3751e8a95d976f69ebbf708a..721e63cf2db11832c507236824313fa763f665be 100644
--- a/Fltk/GUI_Extras.h
+++ b/Fltk/GUI_Extras.h
@@ -40,6 +40,7 @@ int msh_dialog(char *filename);
 int unv_dialog(char *filename);
 int bdf_dialog(char *filename);
 int stl_dialog(char *filename);
+int latex_dialog(char *filename);
 
 #endif
 
diff --git a/Fltk/Opengl.cpp b/Fltk/Opengl.cpp
index 4ef2db1d3268275ce0fa2995d0852f9cc2d3d933..2d927d3510d5289cf1bcf4db1cc53efcb5bc4cb9 100644
--- a/Fltk/Opengl.cpp
+++ b/Fltk/Opengl.cpp
@@ -1,4 +1,4 @@
-// $Id: Opengl.cpp,v 1.72 2006-12-12 01:39:15 geuzaine Exp $
+// $Id: Opengl.cpp,v 1.73 2007-06-22 08:07:46 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -53,6 +53,9 @@ void SanitizeTeXString(char *in, char *out)
     strcpy(out, in);
     return;
   }
+
+  if(CTX.print.tex_as_equation) *out++ = '$';
+
   // otherwise, escape the following special characters:
   char bad[8] = { '%', '^', '#', '%', '&', '_', '{', '}' };
   while(*in){
@@ -64,6 +67,9 @@ void SanitizeTeXString(char *in, char *out)
     }
     *out++ = *in++;
   }
+
+  if(CTX.print.tex_as_equation) *out++ = '$';
+
   *out = '\0';
 }
 
diff --git a/utils/converters/autocad/message.c b/utils/converters/autocad/message.c
index b7f33cd76d842a48e1363e99693b8571a358f1d8..51273b80de6e00322ce6eaeed8db22adf519a63e 100644
--- a/utils/converters/autocad/message.c
+++ b/utils/converters/autocad/message.c
@@ -3,7 +3,7 @@
 #include <signal.h>
 #include <stdarg.h>
 
-void Msg(int level, char *fmt, ...)
+void Msg(int level, const char *fmt, ...)
 {
   va_list args;
   va_start(args, fmt);