Search code examples
latexmathjax

How to draw a rectangle in MathJax?


How can I draw a rectangle in MathJax?

width = 5, length = 10 (units = mm)

thanks!


Solution

  • You can use \Rule{10mm}{5mm}{0mm} to get a black rectangle with the given size. Use \color{red}{\Rule{10mm}{5mm}{0mm}} to get a red rectangle.

    <script src="https://cdn.jsdelivr.net/npm/mathjax@2/MathJax.js?config=TeX-AMS_CHTML"></script>
    
    <p>
    Black rectangle: \(\Rule{10mm}{5mm}{0mm}\)
    </p>
    
    <p>
    Red rectangle: \(\color{red}{\Rule{10mm}{5mm}{0mm}}\)
    </p>