Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7547651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T09:30:26+00:00 2026-05-30T09:30:26+00:00

When I use a LaTeX macro (\newcommand for example), it occupies space in the

  • 0

When I use a LaTeX macro (\newcommand for example), it occupies space in the page. Here is an example code to demonstrate the issue I am facing.

URL: http://jsfiddle.net/Lkeus/

Code:

<!DOCTYPE html> 
<html> 
<head> 
<title>MathJax Example</title> 
<script 
type="text/javascript" 
src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=default"> 
</script> 
</head> 
<body> 
<p> 
\(\newcommand{\N}{\mathbb{N}}\) 
\(\newcommand{\R}{\mathbb{R}}\) 
\(\newcommand{\Z}{\mathbb{Z}}\) 
Let \(x \in \N\). Then \(x^2\) is called a perfect square. 
</p> 
<p> 
Let \(x \in \N\). Then \(x^2\) is called a perfect square. 
</p> 
</body> 
</html> 

Here is the output in its own page: http://fiddle.jshell.net/Lkeus/show/

In the output, you can see that the first line begins after some space. This space comes from the use of macros there. Firebug shows this code created by MathJax as the cause of the extra space:

<span class="math" id="MathJax-Span-1"> 
<span style="display: inline-block; position: relative; width: 0em; 
height: 0pt; font-size: 130%;"> 
<span style="position: absolute; top: -1em; left: 0em; clip: 
rect(0.856em, 1000em, 1.144em, -0.433em);"> 
<span class="mrow" id="MathJax-Span-2"></span> 
<span style="display: inline-block; width: 0pt; height: 1em;"></span> 
</span></span> 
<span style="border-left: 0em solid; display: inline-block; overflow: 
hidden; width: 0pt; height: 0em; vertical-align: 0em;"></span></span>

How can I get rid of this extra space?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T09:30:27+00:00Added an answer on May 30, 2026 at 9:30 am

    I learnt a few solutions to this problem from the MathJax community.

    It is possible to minimize the whitespace due to \newcommand by putting all the \newcommands into a single \(…\). Example: http://jsfiddle.net/qQ9P9/

    \(\newcommand{\N}{\mathbb{N}}
    \newcommand{\R}{\mathbb{R}}
    \newcommand{\Z}{\mathbb{Z}}\)
    

    It is possible to remove all the extra whitespace completely by defining the macros in the <head> section of the HTML. Example: http://jsfiddle.net/tVyJz/

    <script type="text/x-mathjax-config"> 
    MathJax.Hub.Config({ 
        TeX: { 
            Macros: { 
                N: "\\mathbb{N}", 
                R: "\\mathbb{R}", 
                Z: "\\mathbb{Z}" 
            } 
        } 
    }); 
    </script> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use latex to typeset lots of code using the minted package. Mainly the
How do I use variables in Latex expressions in R? For example: plot(X, Y,
Not sure this is a programming question, but we use LaTeX for all our
I want to prepare a text for the use in a LaTeX document. I
What Latex styles do you use and where do you find them? The reason
TeX/LaTeX is great, I use it in many ways. Some of its advantages are:
I need to use a font family in my LaTeX documents, that is available
I would like to use some iteration control flow to simplify the following LaTeX
I am wondering how I can get the document title in LaTex, for use
I'm new to textmate and I want to use it to write latex. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.