I'm trying to use \mathcal and it works for the subscripts, but not for the main letter.

    \caption{Data integration framework}
\begin{tabular}{| l | c | c |}
        & Language & Alphabet \\
    Global schema & \[\mathcal{L}_{\mathcal{G}}\] & \[\mathchal{A}_\mathcal{G}\] \\
    Source schema & \[\mathcal{L}_{\mathcal{S}}\] & \[\mathcal{A}_{\mathcal{S}}\] \\
    Query \[\mathcal{q}_{\mathcal{S}}\] & \[\mathcal{L}_{\mathcal{M},\mathcal{S}}\] & \[\mathcal{A}_{\mathcal{S}}\] \\
    Query \[\mathcal{q}_{\mathcal{G}}\] & \[\mathcal{L}_{\mathcal{M},\mathcal{G} \] & \[\mathcal{A}_{\mathcal{G}}\] \\

I'm using pdflatex and this is the error I am getting

! LaTeX Error: \mathcal allowed only in math mode.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
l.34    Global schema & \[\mathcal
                                {L}_{\mathcal{G}}\] & \[\mathcal{A}_\mathcal...

! Missing $ inserted.
<inserted text> 
l.34    Global schema & \[\mathcal{L}_
                                    {\mathcal{G}}\] & \[\mathcal{A}_\mathcal...

? x

Here the full preamble


\graphicspath{ {images/} }

%%%This is to have the titles of the chapters without the number%%%



I don't understand what is wrong with my use of \[ \].

@quark67 responded in a comment. In this instance, I need to use $...$ instead of \[ \].

  • 1
    Welcome. \[ and \] are for display math (equations displayed on there own line, centered). Replace it by $ for inline math (e.g. $\mathcal{L}_{\mathcal{G}}$ for the first). The error message is not very accurate in this situation. There is also a typo (\mathchal instead \mathcal) in one case, and a wrong usage of \mathcal: it only works with uppercase (e.g. Q) not lowercase (e.g. q).
    – quark67
    Mar 16, 2023 at 15:57

1 Answer 1


The error is a bit subtle. The command \[ does some work and eventually issues $$ to start display math mode (note that $$ should never be used in a LaTeX document environment, but of course display math mode uses it internally).

But what does the $$ do in your case? An alignment cell of type l, c or r (not p) is processed in restricted horizontal mode where display math mode is not allowed and, by rule, $$ simply enters and exits inline math mode. Thus TeX is not in math mode when \mathcal is found. Hence the (admittedly cryptic)

! LaTeX Error: \mathcal allowed only in math mode.

error message. Alas, it might be possible to catch the error of using \[ in a table cell of type l, c or r when TeX is in restricted horizontal mode, but it currently isn't implemented (nor I see any real reason to).

Use inline math mode, either \(...\) or $...$ for this job.

Note also that \mathcal{q} won't produce a sensible output with the font setup you have.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .