diff --git a/configure.ac b/configure.ac
index a886697..6081415 100644
--- a/configure.ac
+++ b/configure.ac
@@ -177,6 +177,14 @@ if test "x$goffice_with_lasem" = "xtrue" ; then
 	AC_DEFINE(GOFFICE_WITH_LASEM, 1, [Define if Lasem is used])
 	goffice_reqs="$goffice_reqs $lasem >= 0.4.1 "
 	EXTRA_DEPS="$EXTRA_DEPS $lasem"
+dnl check for lsm_itex_to_mathml
+	saved_CFLAGS=$CFLAGS
+	saved_LIBS=$LIBS
+	CFLAGS="$CFLAGS $Lasem_CFLAGS"
+	LIBS="$LIBS $Lasem_LIBS"
+	AC_CHECK_FUNCS(lsm_itex_to_mathml)
+	CFLAGS=$saved_CFLAGS
+	LIBS=$saved_LIBS
 fi
 
 AM_CONDITIONAL(GOFFICE_WITH_LASEM, $goffice_with_lasem)
diff --git a/goffice/utils/go-mml-to-itex.c b/goffice/utils/go-mml-to-itex.c
index 38f8961..54818ed 100644
--- a/goffice/utils/go-mml-to-itex.c
+++ b/goffice/utils/go-mml-to-itex.c
@@ -27,6 +27,70 @@
 #include <libxslt/transform.h>
 #include <libxslt/xsltutils.h>
 #include <string.h>
+
+#ifndef HAVE_LSM_ITEX_TO_MATHML
+/* Lasem - SVG and Mathml library
+ *
+ * Copyright © 2013 Emmanuel Pacaud
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author:
+ * 	Emmanuel Pacaud <emmanuel@gnome.org>
+ */
+
+static char *
+lsm_itex_to_mathml (const char *itex, int size)
+{
+	char *mathml;
+
+	if (itex == NULL)
+		return NULL;
+
+	if (size < 0)
+		size = strlen (itex);
+
+	mathml = itex2MML_parse (itex, size);
+	if (mathml == NULL)
+		return NULL;
+
+	if (mathml[0] == '\0') {
+		itex2MML_free_string (mathml);
+		return NULL;
+	}
+
+	return mathml;
+}
+
+/**
+ * lsm_itex_free_mathml_buffer:
+ * @mathml: (allow-none): a mathml buffer
+ *
+ * Free the buffer returned by @lsm_itex_to_mathml.
+ */
+
+static void
+lsm_itex_free_mathml_buffer (char *mathml)
+{
+	if (mathml == NULL)
+		return;
+
+	itex2MML_free_string (mathml);
+}
+#endif
 
 gboolean
 go_mathml_to_itex (char const *mml, char **buf, int *length, gboolean *compact, GOCmdContext *gcc)
