diff --git a/macros/PGbasicmacros.pl b/macros/PGbasicmacros.pl
index dd6ebb04cf..132cc61d2d 100644
--- a/macros/PGbasicmacros.pl
+++ b/macros/PGbasicmacros.pl
@@ -340,10 +340,23 @@ sub NAMED_ANS_RULE {
my $tcol = $col/2 > 3 ? $col/2 : 3; ## get max
$tcol = $tcol < 40 ? $tcol : 40; ## get min
+ # added for dragmath formula editor
+ my $dragmath = 0;
+ $dragmath = $main::envir{DragMath};
+ $dragmath = 0 unless defined ($dragmath);
+
+ my $add_html = '';
+ if ($dragmath == 1){
+ $add_html = qq!!;
+ }
+
+ # end of addition for dragmath
+
MODES(
TeX => "\\mbox{\\parbox[t]{${tcol}ex}{\\hrulefill}}",
Latex2HTML => qq!\\begin{rawhtml}\\end{rawhtml}!,
HTML => qq!!.
+ $add_html. # added for dragmath
qq!!
);
}