:bulb: When using GitLab, this post fixes the issue where LaTeX inline math expressions (mathematical notation and formatting commands written in LaTeX syntax) in markdown files (.md) are not rendered correctly past a certain count and instead appear as raw commands.

[01] The LaTeX Rendering Limits Issue

Symptom

  • Using LaTeX inline math expressions to apply colors in GitLab markdown documents: ```markdown
    1. I only $\textcolor{orange}{\textsf{use}}$ smartphone these days. ```
    • Past a certain count, color rendering stops working and the raw commands are printed:

    2025-01-10 13 46 22

Cause

  • Excessive use of LaTeX inline math expressions can cause performance issues during page rendering.
  • GitLab limits this by default; if needed, the limit can be removed via a setting change.

[02] Fix (Disabling the Rendering Limit)

This is based on a GitLab instance running locally. The environment runs inside a Docker container.

Access the GitLab Container

1
docker exec -it <gitlab-container-name> /bin/bash

Change the Setting (via GitLab Rails Console)

1
2
3
4
5
6
7
8
9
10
gitlab-rails console

# Console prompt
console> ApplicationSetting.update(math_rendering_limits_enabled: false)
# Verify the change
console> ApplicationSetting.current.math_rendering_limits_enabled
console> exit

# Reconfigure
gitlab-ctl reconfigure
  • Process reference (screenshots):

    2025-01-09 22 04 23

    2025-01-09 22 05 03

Restart the GitLab Container

1
docker restart <gitlab-container-name>

[03] Result

  • Properly rendered output (with color):

    2025-01-09 22 05 29