diff --git a/filter/tex/filter.php b/filter/tex/filter.php
index 591b5c2d86f..c29220ee253 100644
--- a/filter/tex/filter.php
+++ b/filter/tex/filter.php
@@ -88,7 +88,7 @@ function tex_filter ($courseid, $text) {
global $CFG;
/// Do a quick check using stripos to avoid unnecessary work
- if (!preg_match('/ TeX expression
// or $$ TeX expression $$
- // or \[ TeX expression \] // original tag of MathType and TeXaide (dlnsk)
- preg_match_all('/(.+?)<\/tex>|\$\$(.+?)\$\$|\\\\\[(.+?)\\\\\]/is', $text, $matches);
+ // or \[ TeX expression \] // original tag of MathType and TeXaide (dlnsk)
+ // or [tex] TeX expression [/tex] // somtime it's more comfortable than (dlnsk)
+ preg_match_all('/(.+?)<\/tex>|\$\$(.+?)\$\$|\\\\\[(.+?)\\\\\]|\\[tex\\](.+?)\\[\/tex\\]/is', $text, $matches);
for ($i=0; $i','',$texexp);
$texexp = str_replace('','',$texexp);
$texexp = str_replace('','',$texexp);
diff --git a/filter/tex/latex.php b/filter/tex/latex.php
index 3cffaa90a96..e9a65179fc1 100644
--- a/filter/tex/latex.php
+++ b/filter/tex/latex.php
@@ -51,7 +51,12 @@
$doc .= $CFG->filter_tex_latexpreamble;
$doc .= "\\pagestyle{empty}\n";
$doc .= "\\begin{document}\n";
- $doc .= "$ {$formula} $\n";
+//dlnsk $doc .= "$ {$formula} $\n";
+ if (preg_match("/^[[:space:]]*\\\\begin\\{(gather|align|alignat|multline).?\\}/i",$formula)) {
+ $doc .= "$formula\n";
+ } else {
+ $doc .= "$ {$formula} $\n";
+ }
$doc .= "\\end{document}\n";
return $doc;
}