\mathcal 無法正常運作

\mathcal 無法正常運作

我正在嘗試使用\mathcal它,它適用於下標,但不適用於主字母。

\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}

我正在使用pdflatex,這是我收到的錯誤

! 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

這是完整的序言

\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}

我不明白我的使用有什麼問題\[ \]

@quark67 在評論中回覆。在這種情況下,我需要使用$...$而不是\[ \].

答案1

這個錯誤有點微妙。該命令\[做了一些工作,並最終$$啟動顯示數學模式(請注意,$$永遠不應該在 LaTeXdocument環境中使用它,但當然顯示數學模式在內部使用它)。

但它對$$你的情況有什麼作用呢?類型為l,cr(not )的對齊單元p在中進行處理受限水平模式其中不允許顯示數學模式,並且按照規則,$$只需進入和退出內聯數學模式。因此 TeX 是不是在數學模式下何時\mathcal找到。因此(誠然是神秘的)

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

錯誤訊息.唉,也許可以捕獲\[在類型為 的表格單元格中使用的錯誤lc或者r當 TeX 處於受限水平模式時,但它目前尚未實現(我也沒有看到任何真正的理由)。

使用內聯數學模式,或\(...\)用於$...$此作業。

另請注意,\mathcal{q}使用您擁有的字體設定不會產生合理的輸出。

相關內容