2

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

\begin{table}[h]
    \centering
    \caption{Data integration framework}
    \label{tab:data_integration}
\begin{tabular}{| l | c | c |}
    \toprule
        & Language & Alphabet \\
    \midrule
    Global schema & \[\mathcal{L}_{\mathcal{G}}\] & \[\mathchal{A}_\mathcal{G}\] \\
    Source schema & \[\mathcal{L}_{\mathcal{S}}\] & \[\mathcal{A}_{\mathcal{S}}\] \\
    \hline
    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}}\] \\
    \bottomrule
    \end{tabular}
\end{table}

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

\documentclass[12pt]{report}

\usepackage[utf8]{inputenc}
\PassOptionsToPackage{
        natbib=true,
    style=authoryear-comp,
        backend=biber,
        url=false,
        doi=false,
        isbn=false,
        eprint=false,
            }{biblatex}
\usepackage[backend=biber,bibencoding=utf8]{biblatex}
\addbibresource{/home/enrico/Università/uni_bib.bib}
\usepackage[bottom]{footmisc}
\usepackage[inline]{enumitem}
\usepackage{hyperref}
\usepackage{array}
\usepackage{svg}
\usepackage{graphicx}
\graphicspath{ {images/} }
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage[T1]{fontenc}
\usepackage{blindtext}
\usepackage[a4paper,width=150mm,top=25mm,bottom=25mm,bindingoffset=6mm]{geometry}
\usepackage[final]{microtype}
\usepackage{setspace}
\onehalfspacing

%%%This is to have the titles of the chapters without the number%%%
\usepackage[raggedright,pagestyles]{titlesec}

\newpagestyle{main}{
  \sethead[\thepage][][\chaptertitle]{\chaptertitle}{}{\thepage}
  \headrule
}
\pagestyle{main}

\titleformat{\chapter}{\normalfont\huge\bfseries}{}{0pt}{\Huge}

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
  • 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

4

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 .