Documentation / MathType

  • Demos
  • Visit our website
  • Downloads
  • Contact us
  • MathType

    • Wiris Quizzes

      • Learning Lemur

        • CalcMe

          • MathPlayer

            • Store FAQ

              • VPAT for the electronic documentation

                • MathFlow

                  • BF FAQ

                    • Home
                    • MathType
                    • MathType Office Tools
                    • MathType 7 for Windows and Mac
                    • MathType SDK
                    • MathType SDK

                    Extracting baseline info from a GIF file

                    Reading time: 1min

                    Products: MathType (all platforms)

                    MathType inserts a comment describing the distance in points from the bottom of the frame rectangle to the baseline of the equation.  For example: 

                     

                    This information can be made use of by page layout, word processor, or HTML editing programs to ensure proper alignment of the equation baseline with that of a text line in which it is pasted. See Wiris SDK document Interpreting the baseline for information on how to convert this value for use in your application.

                    Starting with MathType 5.0 for Windows, baseline data is embedded into a GIF file as an Application Extension Record. Earlier versions of MathType do not embed this data.

                    The Application Extension Record consists of a 14-byte header (Application Extension Descriptor), followed by the MTEF data. The header contains:

                    Byte Introducer = 0x21;
                    Byte ExtensionLabel = 0xFF;
                    Byte BlockSize = 0x0B;
                    Byte ApplicationId[8] = "MathType";
                    Byte AuthenticationCode[3] = "002";

                    The data follows this header and is written as a series of blocks each containing 255 bytes or less. Each block starts with a single byte count followed by the data. The end is marked as a block with length 0.

                    The header is unique enough that the easiest way to extract the data might be to scan the file for the 14-byte header, then expect the MTEF data blocks to follow. Properly decoding the GIF records isn't that hard either, but obviously requires you read the GIF specification.

                    The actual baseline data is stored within the data part of the Application Extension Record as three 16-bit integer values:

                    Word BaselineDelta;
                    Word LeftSideBearing;
                    Word RightSideBearing;

                    Each of these values is written as two bytes, with the low-order byte first. Each value represents a distance in pixels. The BaselineDelta is measured as in the picture above. The LeftSideBearing and RightSideBearing values are for future use and are currently both zero.

                    MathType internal equation data format, MTEF, is also stored in the GIF file using a similar Application Extension Record as described above, but with an AuthenticationCode of "001". For details, see How MTEF is Stored in Files and Objects.

                    Was this article helpful?

                    Yes
                    No
                    Give feedback about this article

                    Related Articles

                    • Using MathType with other applications and websites
                    • Using MathType with MathJax-enabled applications and websites
                    • Using MathType with WordPress

                    Extracting baseline info from a GIF file

                    Products: MathType (all platforms)

                    Making people’s STEM work more meaningful

                    MathType

                    • MathType for Office Tools
                    • MathType for Mac
                    • MathType for Microsoft 365
                    • MathType for Google Workspace
                    • MathType for LMS
                    • MathType for XML Editors
                    • Arabic notation
                    • Our products accessibility
                    • MathType is online

                    WirisQuizzes

                    Learning Lemur

                    Solutions for Education

                    • Blackboard Learn
                    • Brightspace by D2L
                    • Canvas
                    • Google Classroom
                    • Moodle
                    • Schoology

                    Solutions for Publishing Houses

                    Solutions for Technical Writers

                    Solutions for Chemistry

                    Integrations

                    • HTML Editors
                    • MathType in WordPress

                    Pricing

                    Company

                    Careers

                    Blog

                    Contact Us

                    Buy Now

                    Plugin Downloads

                    © Wiris 2025

                    • Cookie Preferences
                    • Cookie Policy
                    • Terms of Use
                    • Privacy Policy / GDPR
                    • Student Data Privacy
                    • Compliance
                    • Powered by Helpjuice
                    Expand