MicroTeX
A dynamic, cross-platform, and embeddable LaTeX rendering library
Install / Use
/learn @NanoMichael/MicroTeXREADME
It is a dynamic, cross-platform, and embeddable LaTeX rendering library. Its main purpose is to display mathematical formulas written in LaTeX. It can be embedded in applications on various platforms (Android, iOS, Windows, Linux GTK, Qt...). The following pictures demonstrate the application run in Ubuntu (using GTK) and Windows.


Here contains more demos you may want to take a look.
Build demo
First make sure you have a C++ compiler that supports C++ 17 standard. It uses CMake to build the demo, make sure you have it installed. Currently support Windows and Linux on PC, the version on Mac OS is in the plan, and you can find the Android version in here.
CygWinorMinGWis recommended to be installed on Windows, andGdiplusis required.GTKMMandGSVMMmust be installed on Linux for a GTK build.- Qt development packages must be installed for a Qt installation.
After all the dependencies have been satisfied, run the following commands to build:
cd your/project/dir
mkdir build
cd build
cmake ..
make -j32
After all the works have done, run the executable file LaTeX in the directory build to check the demo.
If you wish to build in Qt mode on your plaform add -DQT=ON to the cmake command above.
Headless mode
It supports to run with headless mode (no GUI) on Linux OS, check the scripts below to learn how to do this.
Batch mode:
./LaTeX -headless \
-samples=res/SAMPLES.tex \
-outputdir=samples \
-prefix=sample_ \
# common options
-textsize=14 \
-foreground=black \
-background=white \
-padding=0 \
-maxwidth=720
Single mode:
./LaTeX -headless \
"-input=\sqrt[3]{(x-y)^3}=x-y" \
-output=an_example.svg
# other options...
COMMON OPTIONS
-
-h: show usages and exit -
-headless: tells the application to run with the headless mode, that converts the input LaTeX codes into SVG images -
-textsize: config the font size (in point) to display formulas, the default is 20 -
-foreground: config the foreground color to display formulas; the value can be a color name or in the form of #AARRGGBB; default is black -
-background: config the background color to display formulas; the value can be a color name or in the form of #AARRGGBB; default is transparent -
-padding: config spaces to add to the SVG images, the default is 10 -
-maxwidth: config the max width of the graphics context, the default is 720 pixels; this option has weak limits on the SVG images, thus the width of the SVG image may be wider than the value defined by this option
BATCH MODE OPTIONS
The program will save the SVG images produced by the LaTeX codes that parsed from the given file (specified by the option '-samples') into the directory specified by the option '-outputdir'.
-
-outputdir: indicates the directory to save the SVG images -
-samples: specifies the file that contains several LaTeX codes split by a line that consists of the character '%' only, the default is './res/SAMPLES.tex'; check this file to get more details -
-prefix: specifies the prefix of the filename of the SVG images, the default is ''; for example if 2 pieces of code have given with the option '-prefix=a_', the filename of the SVG images will be 'a_0.svg' and 'a_1.svg'
SINGLE MODE OPTIONS
-
-input: the source code that is written in LaTeX -
-output: indicates where to save the produced SVG image, only works if the option '-input' has given
NOTICE
If both '-outputdir' and '-input' are specified, the '-input' option wins. Run the command
./LaTeX -hto get helps.
Please read this section to learn more.
Compile-time options
The program can be built just fine using the default compilation options. However, if required, the options documented below can be used to omit some features (that can reduce the library size) and to check memory only.
HAVE_LOG
If HAVE_LOG is defined, the program will output some logs (e.g.: the symbols parse result, generated box tree and so on) during runtime to help us to find out if there're issues or bugs, the default is ON. The option will be disabled when building with release mode, you can set it to OFF manually to make double insurance. For example, when parsing the following LaTeX code with the option is defined:
\sqrt[3]{(x-y)^3}=x-y
will produce the following box tree:
0 HBox
1 ├── HBox
2 │ ├── StrutBox
2 │ ├── CharBox
2 │ ├── StrutBox
2 │ └── HBox
3 │ ├── CharBox
3 │ └── OverBar
4 │ ├── StrutBox
4 │ ├── RuleBox
4 │ ├── StrutBox
4 │ └── HBox
5 │ ├── HBox
6 │ │ ├── CharBox
6 │ │ ├── GlueBox
6 │ │ ├── CharBox
6 │ │ ├── GlueBox
6 │ │ ├── CharBox
6 │ │ ├── GlueBox
6 │ │ ├── CharBox
6 │ │ ├── GlueBox
6 │ │ └── HBox
7 │ │ ├── CharBox
7 │ │ ├── HBox
8 │ │ │ ├── CharBox
8 │ │ │ └── StrutBox
7 │ │ └── StrutBox
5 │ └── StrutBox
1 ├── GlueBox
1 ├── CharBox
1 ├── GlueBox
1 ├── CharBox
1 ├── GlueBox
1 ├── CharBox
1 ├── GlueBox
1 └── CharBox
The number represents the depth of the tree node.
GRAPHICS_DEBUG
If this macro is defined, then the custom command \debug and \undebug will be compiled, the default is ON. The program will draw some assisted information to help us to check if there're issues when draw formulas after run \debug, and \undebug will close this feature. For example, parse the LaTeX code below:
\debug
\newcolumntype{s}{>{\color{#1234B6}}c}
\begin{array}{|c|c|c|s|}
\hline
\rowcolor{Tan}\multicolumn{4}{|c|}{\textcolor{white}{\bold{\text{Table Head}}}}\\
\hline
\text{Matrix}&\multicolumn{2}{|c|}{\text{Multicolumns}}&\text{Font size commands}\\
\hline
\begin{pmatrix}
\alpha_{11}&\cdots&\alpha_{1n}\\
\hdotsfor{3}\\
\alpha_{n1}&\cdots&\alpha_{nn}
\end{pmatrix}
&\large \text{Left}&\cellcolor{#00bde5}\small \textcolor{white}{\text{\bold{Right}}}
&\small \text{small Small}\\
\hline
\multicolumn{4}{|c|}{\text{Table Foot}}\\
\hline
\end{array}
will produce:
The red blocks represent the depth of the boxes, and these rectangles represent the boxes' bounds.
MEM_CHECK
Basically, the program implemented an empty graphics interface (check this file), all the other implementations will be ignored if the MEM_CHECK option is defined, the default is OFF. It is useful when using valgrind to detect memory leaks and memory misuse, make sure you have compiled it with the option -DCMAKE_BUILD_TYPE=Debug before using valgrind. The following script shows how to do memory check using valgrind.
cmake
-DCMAKE_BUILD_TYPE=Debug \
-DGRAPHICS_DEBUG=ON \
-DMEM_CHECK=ON \
-DHAVE_LOG=OFF ..
make -j32
valgrind --leak-check=full -v ./LaTeX
will produce:
==26443== HEAP SUMMARY:
==26443== in use at exit: 72,704 bytes in 1 blocks
==26443== total heap usage: 84,520 allocs, 84,519 frees, 12,515,092 bytes allocated
==26443==
==26443== Searching for pointers to 1 not-freed blocks
==26443== Checked 111,952 bytes
==26443==
==26443== LEAK SUMMARY:
==26443== definitely lost: 0 bytes in 0 blocks
==26443== indirectly lost: 0 bytes in 0 blocks
==26443== possibly lost: 0 bytes in 0 blocks
==26443== still reachable: 72,704 bytes in 1 blocks
==26443== suppressed: 0 bytes in 0 blocks
==26443== Reachable blocks (those to which a pointer was found) are not shown.
==26443== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==26443==
==26443== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
Meson build manifest
You can also build the cairo version of cLaTeXMath with Meson:
meson _build -DTARGET_DEMO=NONE # you can specify TARGET_DEMO=GTK if you want a GTK+ GUI to test cLaTeXMath, otherwise only the library (TARGET_DEVEL) will be built.
ninja -C _build
_build/clatexmath
Prebuilt packages
@sp1ritCS maintains more or less upto date packages of cLaTeXMath/cairo for Arch, CentOS, Debian, Fedora, Mageia, SLE, openSUSE & Ubuntu on the openSUSE Buildservice: home:sp1rit:notekit/clatexmath.
The binaries (built packages) are publicly (without SUSE univention account) available here: download.opensuse.org/repositories/home:/sp1rit:/notekit/. Install instructions can be found on openSUSE's software-o-o instance:
- Arch (and SRPMs): software.opensuse.org//download.html?project=home:sp1rit:notekit&package=clatexmath
- RPM (CentOS, Fedora, Mageia, SLE & openSUSE): software.opensuse.org//download.html?project=home:sp1rit:notekit&package=clatexmath-devel
- DPKG (Debian, Raspbian & xUbuntu): software.opensuse.org//download.html?project=home:sp1rit:notekit&package=libclatexmath-dev
If you just w
Related Skills
node-connect
349.0kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
109.4kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
349.0kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
349.0kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
